Skip to content

Commit 7e3996f

Browse files
authored
fix parameterSet ByID compability with previous API versions (#482)
1 parent 1edb9a1 commit 7e3996f

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

Source/Public/Get-VSTeamUserEntitlement.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function Get-VSTeamUserEntitlement {
4646
# or supported version is not correct with the type of API call
4747
$paramCounter = _countParameters -BoundParameters $PSBoundParameters
4848

49-
$paramset = 'PagedParams', 'PagedFilter','ById'
50-
if ($paramCounter -eq 0) {
49+
$paramset = 'PagedParams', 'PagedFilter'
50+
if ($paramCounter -eq 0 -or $PSCmdlet.ParameterSetName -eq 'ByID') {
5151
_supportsMemberEntitlementManagement
5252
} elseif ($paramset -contains $PSCmdlet.ParameterSetName) {
5353
_supportsMemberEntitlementManagement -Onwards '6.0'

Tests/function/tests/Get-VSTeamUserEntitlement.Tests.ps1

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ Describe "VSTeamUserEntitlement" -Tag 'VSTeamUserEntitlement' {
4040
}
4141
}
4242

43+
It 'by Id should return users with projects' {
44+
$user = Get-VSTeamUserEntitlement -Id '00000000-0000-0000-0000-000000000000'
45+
46+
$user.Email | Should -Be 'test@test.com' -Because 'email is from type'
47+
$user.userName | Should -Be 'Donovan Brown' -Because 'userName is from type'
48+
49+
Should -Invoke Invoke-RestMethod -Exactly -Times 1 -Scope It -ParameterFilter {
50+
$Uri -eq "https://vsaex.dev.azure.com/test/_apis/userentitlements/00000000-0000-0000-0000-000000000000?api-version=$(_getApiVersion MemberEntitlementManagement)"
51+
}
52+
}
53+
4354
Context 'Get-VSTeamUserEntitlement up to version 6.0' {
4455
BeforeAll {
4556
Mock _getApiVersion { return '1.0-unitTests' } -ParameterFilter { $Service -eq 'MemberEntitlementManagement' }
@@ -57,17 +68,6 @@ Describe "VSTeamUserEntitlement" -Tag 'VSTeamUserEntitlement' {
5768
}
5869
}
5970

60-
It 'by Id should return users with projects' {
61-
$user = Get-VSTeamUserEntitlement -Id '00000000-0000-0000-0000-000000000000'
62-
63-
$user.Email | Should -Be 'test@test.com' -Because 'email is from type'
64-
$user.userName | Should -Be 'Donovan Brown' -Because 'userName is from type'
65-
66-
Should -Invoke Invoke-RestMethod -Exactly -Times 1 -Scope It -ParameterFilter {
67-
$Uri -eq "https://vsaex.dev.azure.com/test/_apis/userentitlements/00000000-0000-0000-0000-000000000000?api-version=$(_getApiVersion MemberEntitlementManagement)"
68-
}
69-
}
70-
7171
It 'with select for projects should return users with projects' {
7272
Get-VSTeamUserEntitlement -Select Projects
7373

@@ -93,10 +93,6 @@ Describe "VSTeamUserEntitlement" -Tag 'VSTeamUserEntitlement' {
9393
}
9494
}
9595

96-
It 'should throw by ID and version 6.0 onwards' {
97-
{ Get-VSTeamUserEntitlement -Id '00000000-0000-0000-0000-000000000000' } | Should -Throw
98-
}
99-
10096
It "with incorrect case in license parameter should throw" {
10197
{ Get-VSTeamUserEntitlement -License account-Advanced} | Should -Throw
10298
}

0 commit comments

Comments
 (0)