Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ All notable changes to this project will be documented in this file.

### What's Changed
- feat(Get-AdoUser): Add user support (#124)
- fix(Get-AdoUserEntitlement): Correct error handling (#128)

### Breaking Changes
- _None_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
} while ($continuationToken)

} catch {
if ($_.ErrorDetails.Message -match 'MemberNotFoundException') {
Write-Warning "Identity not found with ID $UserId, skipping."
if ($_.ErrorDetails.Message -match 'UserEntitlementNotFoundException') {
Write-Warning "User entitlement not found for ID $UserId, skipping."
} else {
throw $_
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ Describe 'Get-AdoUserEntitlement' {
Mock -ModuleName Azure.DevOps.PSModule Confirm-Default { }
}

It 'Should warn when user does not exist (MemberNotFoundException)' {
$exception = New-Object System.Management.Automation.RuntimeException('MemberNotFoundException: User not found')
$errorRecord = New-Object System.Management.Automation.ErrorRecord($exception, 'UserNotFound', 'ObjectNotFound', $null)
$errorRecord.ErrorDetails = New-Object System.Management.Automation.ErrorDetails('MemberNotFoundException: User not found')
It 'Should warn when user entitlement does not exist (UserEntitlementNotFoundException)' {
$exception = New-Object System.Management.Automation.RuntimeException('UserEntitlementNotFoundException: User entitlement not found')
$errorRecord = New-Object System.Management.Automation.ErrorRecord($exception, 'UserEntitlementNotFoundException', 'ObjectNotFound', $null)
$errorRecord.ErrorDetails = New-Object System.Management.Automation.ErrorDetails('UserEntitlementNotFoundException: User entitlement not found')

Mock -ModuleName Azure.DevOps.PSModule Invoke-AdoRestMethod { throw $errorRecord }

Expand Down