From 1d43c5183e34e1848cc64811fd865be08c92497d Mon Sep 17 00:00:00 2001 From: Michael Zanatta Date: Tue, 7 Jan 2025 14:08:05 +1000 Subject: [PATCH 1/5] Code Review Fixes (#7) * Initial Commit * Code Review Adjustments --------- Co-authored-by: Michael Zanatta --- source/Classes/009.AzDoGroupPermission.ps1 | 4 +- source/Classes/011.AzDoOrganizationGroup.ps1 | 2 +- source/Classes/020.AzDoProject.ps1 | 4 +- source/Classes/021.AzDoProjectServices.ps1 | 2 +- source/Classes/022.AzDoProjectGroup.ps1 | 2 +- source/Classes/031.AzDoGroupMember.ps1 | 4 +- source/Classes/040.AzDoGitRepository.ps1 | 4 +- source/Classes/041.AzDoGitPermission.ps1 | 2 +- source/Enum/DescriptorType.ps1 | 1 - .../Examples/Resources/AzDoGitPermission.md | 12 +++--- .../2-UpdateAzDoGitRepository.ps1 | 2 +- .../Examples/Resources/AzDoGroupPermission.md | 2 +- .../Resources/AzDoOrganizationGroup.md | 2 - .../Api/Classes/000.CacheItem.ps1 | 2 +- .../Api/Project/Update-DevOpsProject.ps1 | 8 ---- .../Api/Project/Wait-DevOpsProject.ps1 | 4 +- .../Cache Initalization/0.ProjectCache.ps1 | 4 +- .../Private/Cache/Find-CacheItem.ps1 | 4 +- .../Private/Cache/Get-CacheObject.ps1 | 2 +- .../Private/Cache/Set-CacheObject.ps1 | 4 +- .../Private/Helper/ACL/ConvertTo-ACEList.ps1 | 4 +- .../Private/Helper/ACL/ConvertTo-ACL.ps1 | 4 +- .../Helper/ACL/ConvertTo-FormattedACL.ps1 | 2 +- .../Helper/ACL/Get-BitwiseOrResult.ps1 | 4 +- .../Private/Helper/ConvertTo-Base64String.ps1 | 2 +- .../Private/Helper/Find-Identity.ps1 | 4 +- .../Helper/Invoke-AzDevOpsApiRestMethod.ps1 | 2 +- .../Logging/{Flush-Log.txt => Flush-Log.ps1} | 2 + ...{Initialize-Log.txt => Initialize-Log.ps1} | 2 + .../Logging/{Write-Log.txt => Write-Log.ps1} | 2 + .../Private/Helper/PreCommandLookupAction.ps1 | 30 --------------- .../AzureDevOpsDsc.Common.psm1 | 3 +- .../Get-AzDoOrganizationGroup.ps1 | 9 +---- .../Test-AzDoOrganizationGroup.ps1 | 2 +- .../Functions/Public/Refresh-Cache.ps1 | 1 - tests/DSC/InModuleScope.ps1 | 37 ------------------- .../Resources/AzDoGitPermission.tests.ps1 | 2 - .../Supporting/API/Get-AzDevOpsApiVersion.ps1 | 1 - .../Supporting/API/Invoke-APIRestMethod.ps1 | 1 - .../Supporting/APICalls/List-DevOpsGroups.ps1 | 3 -- .../APICalls/Remove-DevOpsProject.ps1 | 5 +-- .../Functions/SupportingFunctions.ps1 | 4 -- tests/Integration/Supporting/Teardown.ps1 | 1 - 43 files changed, 53 insertions(+), 145 deletions(-) rename source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/{Flush-Log.txt => Flush-Log.ps1} (99%) rename source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/{Initialize-Log.txt => Initialize-Log.ps1} (99%) rename source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/{Write-Log.txt => Write-Log.ps1} (99%) delete mode 100644 source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/PreCommandLookupAction.ps1 delete mode 100644 source/Modules/AzureDevOpsDsc.Common/Services/Functions/Public/Refresh-Cache.ps1 delete mode 100644 tests/DSC/InModuleScope.ps1 diff --git a/source/Classes/009.AzDoGroupPermission.ps1 b/source/Classes/009.AzDoGroupPermission.ps1 index a3b2f6a75..6693563a3 100644 --- a/source/Classes/009.AzDoGroupPermission.ps1 +++ b/source/Classes/009.AzDoGroupPermission.ps1 @@ -6,8 +6,8 @@ The AzDoGroupPermission class is a DSC resource that allows you to manage permissions for a group in an Azure DevOps project. .NOTES - Author: Your Name - Date: Current Date + Author: Michael Zanatta + Date: 2025-01-06 .LINK GitHub Repository: diff --git a/source/Classes/011.AzDoOrganizationGroup.ps1 b/source/Classes/011.AzDoOrganizationGroup.ps1 index 1f404c22c..f8f4e3018 100644 --- a/source/Classes/011.AzDoOrganizationGroup.ps1 +++ b/source/Classes/011.AzDoOrganizationGroup.ps1 @@ -8,7 +8,7 @@ .NOTES Author: Michael Zanatta - Date: 04/19/2024 + Date: 2025-01-06 .LINK GitHub Repository: diff --git a/source/Classes/020.AzDoProject.ps1 b/source/Classes/020.AzDoProject.ps1 index d0bc95d22..0e10dc775 100644 --- a/source/Classes/020.AzDoProject.ps1 +++ b/source/Classes/020.AzDoProject.ps1 @@ -6,8 +6,8 @@ The AzDoProject class is used to define and manage Azure DevOps projects. It inherits from the AzDevOpsDscResourceBase class. .NOTES - Author: Your Name - Date: Current Date + Author: Michael Zanatta + Date: 2025-01-06 .LINK GitHub Repository: diff --git a/source/Classes/021.AzDoProjectServices.ps1 b/source/Classes/021.AzDoProjectServices.ps1 index 805bad0e9..7998e87e9 100644 --- a/source/Classes/021.AzDoProjectServices.ps1 +++ b/source/Classes/021.AzDoProjectServices.ps1 @@ -44,7 +44,7 @@ .NOTES Version: 1.0 - Author: Your Name + Author: Michael Zanatta Required Modules: xAzDevOpsDSC #> diff --git a/source/Classes/022.AzDoProjectGroup.ps1 b/source/Classes/022.AzDoProjectGroup.ps1 index 3927ca579..9fb02a07a 100644 --- a/source/Classes/022.AzDoProjectGroup.ps1 +++ b/source/Classes/022.AzDoProjectGroup.ps1 @@ -7,7 +7,7 @@ .NOTES Author: Michael Zanatta - Date: 04/19/2024 + Date: 2025-01-06 .LINK GitHub Repository: diff --git a/source/Classes/031.AzDoGroupMember.ps1 b/source/Classes/031.AzDoGroupMember.ps1 index b4efc3a37..69c115d41 100644 --- a/source/Classes/031.AzDoGroupMember.ps1 +++ b/source/Classes/031.AzDoGroupMember.ps1 @@ -7,8 +7,8 @@ It inherits from the AzDevOpsDscResourceBase class. .NOTES - Author: Your Name - Date: Current Date + Author: Michael Zanatta + Date: 2025-01-06 .LINK GitHub Repository: diff --git a/source/Classes/040.AzDoGitRepository.ps1 b/source/Classes/040.AzDoGitRepository.ps1 index 80d5f3470..dcd627879 100644 --- a/source/Classes/040.AzDoGitRepository.ps1 +++ b/source/Classes/040.AzDoGitRepository.ps1 @@ -7,8 +7,8 @@ It inherits from the AzDevOpsDscResourceBase class. .NOTES - Author: Your Name - Date: Current Date + Author: Michael Zanatta + Date: 2025-01-06 .LINK GitHub Repository: diff --git a/source/Classes/041.AzDoGitPermission.ps1 b/source/Classes/041.AzDoGitPermission.ps1 index 65a8e51a2..c34f1169e 100644 --- a/source/Classes/041.AzDoGitPermission.ps1 +++ b/source/Classes/041.AzDoGitPermission.ps1 @@ -21,7 +21,7 @@ This class is part of the AzureDevOpsDSC module. .LINK - https://github.com/Azure/AzureDevOpsDSC + https://github.com/dsccommunity/AzureDevOpsDsc .EXAMPLE This example shows how to use the AzDoGitPermission class to manage Git permissions in Azure DevOps. diff --git a/source/Enum/DescriptorType.ps1 b/source/Enum/DescriptorType.ps1 index 608b6027d..fda06bd38 100644 --- a/source/Enum/DescriptorType.ps1 +++ b/source/Enum/DescriptorType.ps1 @@ -130,5 +130,4 @@ Enum DescriptorType { DashboardsPrivileges CSS VersionControlItems - } diff --git a/source/Examples/Resources/AzDoGitPermission.md b/source/Examples/Resources/AzDoGitPermission.md index a87b621de..3cb89a0ea 100644 --- a/source/Examples/Resources/AzDoGitPermission.md +++ b/source/Examples/Resources/AzDoGitPermission.md @@ -37,7 +37,7 @@ AzDoGitPermission/Permissions/Permission ## Permission List -> Either 'Name' or 'DisplayName' can be used +> Either 'Name' or 'DisplayName' can be used, but we Strongly Recommend that you use 'Name' in your configuration. | Name | DisplayName | Values | Note | | ------------- | ------------- | - | - | @@ -92,8 +92,8 @@ Configuration ExampleConfig { Identity = '[ProjectName]\GroupName' Permissions = @{ Read = 'Allow' - "Manage Notes" = 'Allow' - "Contribute" = 'Deny' + ManageNote = 'Allow' + Contribute = 'Deny' } } ) @@ -120,8 +120,8 @@ $properties = @{ Identity = '[ProjectName]\GroupName' Permissions = @{ Read = 'Allow' - "Manage Notes" = 'Allow' - "Contribute" = 'Deny' + ManageNote = 'Allow' + Contribute = 'Deny' } } ) @@ -173,7 +173,7 @@ resources: - Identity: '[$ProjectName]\SampleGroupReadAccess' Permission: Read: "Allow" - "Manage notes": "Allow" + ManageNote: "Allow" ``` LCM Initialization: diff --git a/source/Examples/Resources/AzDoGitRepository/2-UpdateAzDoGitRepository.ps1 b/source/Examples/Resources/AzDoGitRepository/2-UpdateAzDoGitRepository.ps1 index 24c6b5970..64204ba85 100644 --- a/source/Examples/Resources/AzDoGitRepository/2-UpdateAzDoGitRepository.ps1 +++ b/source/Examples/Resources/AzDoGitRepository/2-UpdateAzDoGitRepository.ps1 @@ -3,4 +3,4 @@ This example shows how to update the Git Repository #> -# Not Supported +# Not Currently Supported diff --git a/source/Examples/Resources/AzDoGroupPermission.md b/source/Examples/Resources/AzDoGroupPermission.md index 990575577..4553d0331 100644 --- a/source/Examples/Resources/AzDoGroupPermission.md +++ b/source/Examples/Resources/AzDoGroupPermission.md @@ -1,4 +1,4 @@ -# AzDoGroupPermission Resource Documentation (Currently Disabled) +# AzDoGroupPermission Resource Documentation (Not Currently Supported) ## Overview diff --git a/source/Examples/Resources/AzDoOrganizationGroup.md b/source/Examples/Resources/AzDoOrganizationGroup.md index d9b4d11ca..18e1d63f6 100644 --- a/source/Examples/Resources/AzDoOrganizationGroup.md +++ b/source/Examples/Resources/AzDoOrganizationGroup.md @@ -38,9 +38,7 @@ Configuration ExampleConfig { } } -OrgGroup Start-DscConfiguration -Path ./ExampleConfig -Wait -Verbose - ``` ## Example 2: Sample Configuration using Invoke-DSCResource diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Classes/000.CacheItem.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Classes/000.CacheItem.ps1 index c3ddd5345..abb704c56 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Classes/000.CacheItem.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Classes/000.CacheItem.ps1 @@ -25,7 +25,7 @@ $cacheItem = [CacheItem]::new("exampleKey", "exampleValue") Creates a new CacheItem instance with the key "exampleKey" and the value "exampleValue". .NOTES -Author: Your Name +Author: Michael Zanatta #> class CacheItem diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Update-DevOpsProject.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Update-DevOpsProject.ps1 index e86d666ad..a0fda13cc 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Update-DevOpsProject.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Update-DevOpsProject.ps1 @@ -64,14 +64,6 @@ function Update-DevOpsProject $body = @{ name = $ProjectName visibility = $Visibility - <# - TODO: ISSUE with updating the ProcessTemplateId. - capabilities = @{ - processTemplate = @{ - templateTypeId = $ProcessTemplateId - } - } - #> } # Add the description if provided diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Wait-DevOpsProject.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Wait-DevOpsProject.ps1 index 2cb15cce0..fcc173295 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Wait-DevOpsProject.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Api/Project/Wait-DevOpsProject.ps1 @@ -18,8 +18,8 @@ Wait-DevOpsProject -OrganizationName "MyOrg" -ProjectURL "https://dev.azure.com/MyOrg/MyProject" .NOTES - Author: Your Name - Date: Current Date + Author: Michael Zanatta + Date: 2025-01-06 #> Function Wait-DevOpsProject diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Cache Initalization/0.ProjectCache.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Cache Initalization/0.ProjectCache.ps1 index eb2e787c1..1368700e9 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Cache Initalization/0.ProjectCache.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Cache Initalization/0.ProjectCache.ps1 @@ -19,8 +19,8 @@ None. None. .NOTES -Author: [Author Name] -Date: [Date] +Author: Michael Zanatta +Date: 2025-01-06 #> Function AzDoAPI_0_ProjectCache diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Find-CacheItem.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Find-CacheItem.ps1 index 62e27f068..1b8fe169b 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Find-CacheItem.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Find-CacheItem.ps1 @@ -22,8 +22,8 @@ $filteredCacheItem # Returns the CacheItem with the name 'MyCacheItem' from the list of cache items. .NOTES -Author: Your Name -Date: Today's Date +Author: Michael Zanatta +Date: 2025-01-06 #> Function Find-CacheItem { diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Get-CacheObject.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Get-CacheObject.ps1 index df2490662..f6c32a2d8 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Get-CacheObject.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Get-CacheObject.ps1 @@ -29,7 +29,7 @@ The cache object of the specified type. This function is part of the AzureDevOpsDsc module. .LINK -https://github.com/Azure/AzureDevOpsDsc +https://github.com/dsccommunity/AzureDevOpsDsc #> function Get-CacheObject diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Set-CacheObject.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Set-CacheObject.ps1 index 8dce154f3..9f455c199 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Set-CacheObject.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Cache/Set-CacheObject.ps1 @@ -29,8 +29,8 @@ None. None. .NOTES -Author: Your Name -Date: MM/DD/YYYY +Author: Michael Zanatta +Date: 2025-01-06 #> function Set-CacheObject diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACEList.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACEList.ps1 index 654737a41..d83f2d523 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACEList.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACEList.ps1 @@ -23,8 +23,8 @@ ConvertTo-ACEList -SecurityNamespace "Namespace" -Identity "User1" -Permissions This example converts the permissions "Read" and "Write" for the identity "User1" in the specified security namespace and organization name to an ACE token. .NOTES -Author: Your Name -Date: Today's Date +Author: Michael Zanatta +Date: 2025-01-06 #> Function ConvertTo-ACEList diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACL.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACL.ps1 index 1567b962b..d57b20d83 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACL.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-ACL.ps1 @@ -38,8 +38,8 @@ System.Collections.Generic.List[HashTable] A list of Access Control Lists (ACLs) created from the provided permissions. .NOTES -Author: Your Name -Date: Today's Date +Author: Michael Zanatta +Date: 2025-01-06 #> Function ConvertTo-ACL { diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-FormattedACL.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-FormattedACL.ps1 index a47c66246..48ca8293a 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-FormattedACL.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/ConvertTo-FormattedACL.ps1 @@ -26,7 +26,7 @@ A list of formatted ACLs. .NOTES Author: Michael Zanatta -Date: 06/26/2024 +Date: 2025-01-06 #> Function ConvertTo-FormattedACL diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/Get-BitwiseOrResult.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/Get-BitwiseOrResult.ps1 index 9385cee09..998433216 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/Get-BitwiseOrResult.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ACL/Get-BitwiseOrResult.ps1 @@ -21,8 +21,8 @@ # Output: 15 .NOTES - Author: Your Name - Date: Current Date + Author: Michael Zanatta + Date: 2025-01-06 #> Function Get-BitwiseOrResult { diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ConvertTo-Base64String.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ConvertTo-Base64String.ps1 index 4ec6bbbd3..b55aed41a 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ConvertTo-Base64String.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/ConvertTo-Base64String.ps1 @@ -16,7 +16,7 @@ $base64String .NOTES Author: GitHub Copilot -Date: September 2021 +Date: 2025-01-06 #> function ConvertTo-Base64String { diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.ps1 index a994eca8d..ddd94ecac 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.ps1 @@ -20,8 +20,8 @@ Returns the ACLIdentity object of the found identity. If no identity is found, null is returned. .NOTES - Author: Your Name - Date: Current Date + Author: Michael Zanatta + Date: 2025-01-06 .EXAMPLE Find-Identity -Name "JohnDoe" diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Invoke-AzDevOpsApiRestMethod.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Invoke-AzDevOpsApiRestMethod.ps1 index fb3f36225..011ab6108 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Invoke-AzDevOpsApiRestMethod.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Invoke-AzDevOpsApiRestMethod.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - This is a light, generic, wrapper proceedure around 'Invoke-RestMethod' to handle + This is a light, generic, wrapper around 'Invoke-RestMethod' to handle multiple retries and error/exception handling. This function makes no assumptions around the versions of the API used, the resource diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Flush-Log.txt b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Flush-Log.ps1 similarity index 99% rename from source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Flush-Log.txt rename to source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Flush-Log.ps1 index 4d6507145..3694487af 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Flush-Log.txt +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Flush-Log.ps1 @@ -1,3 +1,4 @@ +<# Function Flush-Log { [CmdletBinding()] @@ -34,3 +35,4 @@ Function Flush-Log Write-Verbose "[Flush-Log] Log messages written to log files." } +#> diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Initialize-Log.txt b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Initialize-Log.ps1 similarity index 99% rename from source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Initialize-Log.txt rename to source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Initialize-Log.ps1 index a907109d2..f8ba02bb6 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Initialize-Log.txt +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Initialize-Log.ps1 @@ -1,3 +1,4 @@ +<# Function Initialize-Log { [CmdletBinding()] param ( @@ -30,3 +31,4 @@ Function Initialize-Log { # Initialize the log files Write-Verbose "[Initialize-Log] Log files initialized at: $LogDirectory" } +#> diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Write-Log.txt b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Write-Log.ps1 similarity index 99% rename from source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Write-Log.txt rename to source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Write-Log.ps1 index 23295de1a..0aa72b804 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Write-Log.txt +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Write-Log.ps1 @@ -1,3 +1,4 @@ +<# Function Write-Log { [CmdletBinding()] @@ -49,3 +50,4 @@ Function Write-Log Write-Verbose "[Write-Log] Log message written to log file." } +#> diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/PreCommandLookupAction.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/PreCommandLookupAction.ps1 deleted file mode 100644 index fe89f743e..000000000 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/PreCommandLookupAction.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# -$ExecutionContext.InvokeCommand.PreCommandLookupAction = { - param($command, $commandScriptBlock) - - # - # If the Command is 'Add-AuthenticationHTTPHeader' and is called outside of 'Invoke-AzDevOpsApiRestMethod' function - - if ($command -eq 'Add-AuthenticationHTTPHeader' -and $MyInvocation.MyCommand.Name -ne 'Invoke-AzDevOpsApiRestMethod') - { - throw "The function 'Add-AuthenticationHTTPHeader' can only be called inside of 'Invoke-AzDevOpsApiRestMethod' function." - } - - # - # Any export function used within Invoke-AzDevOpsApiRestMethod is not allowed. - - if ($command -match 'Export-') - { - throw "The command '$command' is not allowed to be used within 'Invoke-AzDevOpsApiRestMethod' function." - } - - # - # Any attempt of using [System.Runtime.InteropServices.Marshal] outside of 'AuthenticationToken' class is not allowed. - - if ($command -match 'System.Runtime.InteropServices.Marshal' -and $MyInvocation.MyCommand.Name -ne 'AuthenticationToken') - { - throw "The command '$command' is not allowed to be used outside of 'AuthenticationToken' class." - } - -} -#> diff --git a/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 b/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 index e1fb7c2e8..492ffb6a2 100644 --- a/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 +++ b/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 @@ -4,7 +4,8 @@ param ( [Switch] $isClass ) -#using module AzureDevOpsDsc +using module AzureDevOpsDsc + # Setup/Import 'DscResource.Common' helper module #$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' #Import-Module -Name $script:resourceHelperModulePath diff --git a/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Get-AzDoOrganizationGroup.ps1 b/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Get-AzDoOrganizationGroup.ps1 index de551dde8..c4ea98412 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Get-AzDoOrganizationGroup.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Get-AzDoOrganizationGroup.ps1 @@ -120,8 +120,6 @@ Function Get-AzDoOrganizationGroup { # Update the Result $getGroupResult.status = [DSCGetSummaryState]::Changed - # Add the reason - #$getGroupResult.Reasons += [DscResourceReason]::New('AzDoOrganizationGroup:AzDoOrganizationGroup:Deleted&ReCreate', 'The group was deleted and recreated with another group. The properties have changed') } else { @@ -157,11 +155,8 @@ Function Get-AzDoOrganizationGroup } ) - if ($getGroupResult.status -eq [DSCGetSummaryState]::Changed) + if ($getGroupResult.status -ne [DSCGetSummaryState]::Changed) { - # Add the reason - #$getGroupResult.Reasons += [DscResourceReason]::New('AzDoOrganizationGroup:AzDoOrganizationGroup:Changed', 'The group has changed') - } else { $getGroupResult.Ensure = [Ensure]::Present } @@ -230,8 +225,6 @@ Function Get-AzDoOrganizationGroup { $getGroupResult.status = [DSCGetSummaryState]::NotFound $getGroupResult.propertiesChanged = @('description', 'displayName') - # Add the reason - #$getGroupResult.Reasons += [DscResourceReason]::New('AzDoOrganizationGroup:AzDoOrganizationGroup:NotFound', 'The group is not found') return $getGroupResult } diff --git a/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Test-AzDoOrganizationGroup.ps1 b/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Test-AzDoOrganizationGroup.ps1 index ed7c35cd4..25d41b5d9 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Test-AzDoOrganizationGroup.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Resources/Functions/Public/AzDoOrganizationGroup/Test-AzDoOrganizationGroup.ps1 @@ -48,7 +48,7 @@ Function Test-AzDoOrganizationGroup ) # Firstly we need to compare to see if the group names are the same. If so we can return $false. - if ($GetReslut.Status -eq [DSCGetSummaryState]::Unchanged ) + if ($GetResult.Status -eq [DSCGetSummaryState]::Unchanged ) { $result = $true diff --git a/source/Modules/AzureDevOpsDsc.Common/Services/Functions/Public/Refresh-Cache.ps1 b/source/Modules/AzureDevOpsDsc.Common/Services/Functions/Public/Refresh-Cache.ps1 deleted file mode 100644 index 792d60054..000000000 --- a/source/Modules/AzureDevOpsDsc.Common/Services/Functions/Public/Refresh-Cache.ps1 +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/tests/DSC/InModuleScope.ps1 b/tests/DSC/InModuleScope.ps1 deleted file mode 100644 index d4c4a4802..000000000 --- a/tests/DSC/InModuleScope.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -$VerbosePreference = 'Continue' -$ErrorActionPreference = 'Break' - -Get-ChildItem -LiteralPath 'C:\Temp\AzureDevOpsDSC\source\Enum' -File | ForEach-Object { - Write-Verbose "Dot Sourcing $($_.FullName)" - . $_.FullName -} -Get-ChildItem -LiteralPath 'C:\Temp\AzureDevOpsDSC\source\Classes' -File | ForEach-Object { - Write-Verbose "Dot Sourcing $($_.FullName)" - # Read the file and remove [DscResource()] attribute - $file = Get-Command $_.FullName - # Remove [DscResource()] attribute - $content = $file.ScriptContents -replace '\[DscResource\(\)\]', '' - # Conver the string array into ScriptBlock - $scriptBlock = [ScriptBlock]::Create($content) - # Dot source the script block - . $scriptBlock - -} - - -Get-ChildItem -LiteralPath 'C:\Temp\AzureDevOpsDSC\source\Modules\AzureDevOpsDsc.Common\Resources\Functions' -Recurse -File | ForEach-Object { - Write-Verbose "Dot Sourcing $($_.FullName)" - . $_.FullName -} -Get-ChildItem -LiteralPath 'C:\Temp\AzureDevOpsDSC\source\Modules\AzureDevOpsDsc.Common\Api' -Recurse -File | ForEach-Object { - Write-Verbose "Dot Sourcing $($_.FullName)" - . $_.FullName -} - -$ModuleRoot = 'C:\Temp\AzureDevOpsDSC\source\Modules\AzureDevOpsDsc.Common\' - -# Initalize the Cache -'LiveGroups', 'LiveProjects', 'Project','Team', 'Group', 'SecurityDescriptor' | ForEach-Object { - Initialize-CacheObject -CacheType $_ -} - diff --git a/tests/Integration/Resources/AzDoGitPermission.tests.ps1 b/tests/Integration/Resources/AzDoGitPermission.tests.ps1 index d1fc8312e..9a3820b69 100644 --- a/tests/Integration/Resources/AzDoGitPermission.tests.ps1 +++ b/tests/Integration/Resources/AzDoGitPermission.tests.ps1 @@ -1,5 +1,3 @@ - - Describe "AzDoGitPermission Integration Tests" { BeforeAll { diff --git a/tests/Integration/Supporting/API/Get-AzDevOpsApiVersion.ps1 b/tests/Integration/Supporting/API/Get-AzDevOpsApiVersion.ps1 index 84e5b10f7..afeb07a88 100644 --- a/tests/Integration/Supporting/API/Get-AzDevOpsApiVersion.ps1 +++ b/tests/Integration/Supporting/API/Get-AzDevOpsApiVersion.ps1 @@ -1,4 +1,3 @@ - function Get-AzDevOpsApiVersion { [CmdletBinding()] diff --git a/tests/Integration/Supporting/API/Invoke-APIRestMethod.ps1 b/tests/Integration/Supporting/API/Invoke-APIRestMethod.ps1 index de3035d33..b54f6f6f4 100644 --- a/tests/Integration/Supporting/API/Invoke-APIRestMethod.ps1 +++ b/tests/Integration/Supporting/API/Invoke-APIRestMethod.ps1 @@ -1,4 +1,3 @@ - function Invoke-APIRestMethod { [CmdletBinding()] diff --git a/tests/Integration/Supporting/APICalls/List-DevOpsGroups.ps1 b/tests/Integration/Supporting/APICalls/List-DevOpsGroups.ps1 index 77b54ed7d..47b649ab9 100644 --- a/tests/Integration/Supporting/APICalls/List-DevOpsGroups.ps1 +++ b/tests/Integration/Supporting/APICalls/List-DevOpsGroups.ps1 @@ -25,9 +25,6 @@ Function List-DevOpsGroups { return $null } - # - # Perform a lookup to get the group - # # Return the groups from the cache return $groups.Value diff --git a/tests/Integration/Supporting/APICalls/Remove-DevOpsProject.ps1 b/tests/Integration/Supporting/APICalls/Remove-DevOpsProject.ps1 index 8b1d6d8ed..029218014 100644 --- a/tests/Integration/Supporting/APICalls/Remove-DevOpsProject.ps1 +++ b/tests/Integration/Supporting/APICalls/Remove-DevOpsProject.ps1 @@ -49,9 +49,8 @@ function Remove-DevOpsProject try { # Invoke the Azure DevOps REST API to create the project - $response = Invoke-APIRestMethod @params - # Output the response which contains the created project details - return $response + return (Invoke-APIRestMethod @params) + } catch { Write-Error "[Remove-DevOpsProject] Failed to create the Azure DevOps project: $_" diff --git a/tests/Integration/Supporting/Functions/SupportingFunctions.ps1 b/tests/Integration/Supporting/Functions/SupportingFunctions.ps1 index e05415d5d..083092867 100644 --- a/tests/Integration/Supporting/Functions/SupportingFunctions.ps1 +++ b/tests/Integration/Supporting/Functions/SupportingFunctions.ps1 @@ -1,5 +1,3 @@ - - Function New-Project { param( [string]$ProjectName @@ -46,8 +44,6 @@ Function New-Repository { } - - Function New-Group { param( [string]$ProjectName, diff --git a/tests/Integration/Supporting/Teardown.ps1 b/tests/Integration/Supporting/Teardown.ps1 index 83ffc0ee1..220fe5203 100644 --- a/tests/Integration/Supporting/Teardown.ps1 +++ b/tests/Integration/Supporting/Teardown.ps1 @@ -46,4 +46,3 @@ if ($ClearAll -or $ClearOrganizationGroups) Remove-DevOpsGroup -GroupDescriptor $_.descriptor -OrganizationName $OrganizationName } } - From 28f2a0c794e59a264c53d7c514a894a940eb60ae Mon Sep 17 00:00:00 2001 From: Michael Zanatta Date: Wed, 8 Jan 2025 08:56:27 +1000 Subject: [PATCH 2/5] Replace comment with amended version --- source/Classes/002.PersonalAccessToken.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/Classes/002.PersonalAccessToken.ps1 b/source/Classes/002.PersonalAccessToken.ps1 index da231279e..85bd85c5c 100644 --- a/source/Classes/002.PersonalAccessToken.ps1 +++ b/source/Classes/002.PersonalAccessToken.ps1 @@ -38,7 +38,10 @@ class PersonalAccessToken : AuthenticationToken } [Bool]isExpired() { - # Personal Access Tokens do not expire. + + # Personal Access Tokens don't contain expiry information. Without performing a global lookup of PAT tokens, + # we can't determine if a PAT is expired Therefore, we always return $false. + return $false } From 747efa72c0197e96bd109b4d069f29deae8fecce Mon Sep 17 00:00:00 2001 From: Michael Zanatta Date: Wed, 8 Jan 2025 09:39:31 +1000 Subject: [PATCH 3/5] Adding Install-Module and Install-PSResource commands. --- USAGE.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/USAGE.md b/USAGE.md index 6b35a35d6..4fa772c7b 100644 --- a/USAGE.md +++ b/USAGE.md @@ -26,6 +26,56 @@ Ensure you have the following prerequisites before proceeding: - `Sampler` - `xDSCResourceDesigner` +__Using Install-Module__ + +``` PowerShell +# Run as Administrator +Install-Module -Scope AllUsers -Name @( + 'ChangelogManagement' + 'Configuration' + 'DscResource.AnalyzerRules' + 'DscResource.Common' + 'DscResource.DocGenerator' + 'DscResource.Test' + 'InvokeBuild' + 'MarkdownLinkCheck' + 'Metadata' + 'ModuleBuilder' + 'Pester' + 'Plaster' + 'PSDepend' + 'PSDscResources' + 'PSScriptAnalyzer' + 'Sampler' + 'xDSCResourceDesigner' +) +``` + +__Using Install-PSResource__ + +``` PowerShell +# Run as Administrator +Install-PSResource @( + 'ChangelogManagement' + 'Configuration' + 'DscResource.AnalyzerRules' + 'DscResource.Common' + 'DscResource.DocGenerator' + 'DscResource.Test' + 'InvokeBuild' + 'MarkdownLinkCheck' + 'Metadata' + 'ModuleBuilder' + 'Pester' + 'Plaster' + 'PSDepend' + 'PSDscResources' + 'PSScriptAnalyzer' + 'Sampler' + 'xDSCResourceDesigner' +) +``` + ### *AZDODSC_CACHE_DIRECTORY* Environment Variable The system environment variable `AZDODSC_CACHE_DIRECTORY` is used by the module From 2f1f8324098798cce0c301e9a93aafa36b3225c5 Mon Sep 17 00:00:00 2001 From: Michael Zanatta Date: Wed, 8 Jan 2025 01:47:06 +0000 Subject: [PATCH 4/5] Bug Fixes --- .build/tasks/1.PreLoad.ps1 | 30 +++++++++++++++++++ build.yaml | 2 ++ .../Logging/Proxy Functions/Write-Error.ps1 | 2 +- .../Logging/Proxy Functions/Write-Verbose.ps1 | 2 +- .../Logging/Proxy Functions/Write-Warning.ps1 | 2 +- .../AzureDevOpsDsc.Common.psm1 | 2 -- 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 .build/tasks/1.PreLoad.ps1 diff --git a/.build/tasks/1.PreLoad.ps1 b/.build/tasks/1.PreLoad.ps1 new file mode 100644 index 000000000..dc2ae836a --- /dev/null +++ b/.build/tasks/1.PreLoad.ps1 @@ -0,0 +1,30 @@ +task PreLoad { + + # Write a script to check the PSModule Path and add the output/ + # folder to the PSModule Path + + # Get the output directory + $RepositoryRoot = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent + $outputDir = Join-Path -Path $RepositoryRoot -ChildPath 'output' + $supportingModules = Join-Path -Path $RepositoryRoot -ChildPath 'output/AzureDevOpsDsc/0.0.1/Modules' + + # Test if the output and supporting modules directories exist in the PSModulePath + if (-not $IsWindows) { + $modulelist = ($env:PSModulePath -split ":") + $delimiter = ":" + } else { + $modulelist = ($env:PSModulePath -split ";") + $delimiter = ";" + } + + # Check if the output directory is in the moduleList + if ($moduleList -notcontains $outputDir) { + $env:PSModulePath = "{0}{1}{2}" -f $env:PSModulePath, $delimiter, $outputDir + Write-Host "Adding $outputDir to PSModulePath" + } + if ($moduleList -notcontains $supportingModules) { + $env:PSModulePath = "{0}{1}{2}" -f $env:PSModulePath, $delimiter, $supportingModules + Write-Host "Adding $supportingModules to PSModulePath" + } + +} diff --git a/build.yaml b/build.yaml index d725e206f..18816b55e 100644 --- a/build.yaml +++ b/build.yaml @@ -31,6 +31,7 @@ BuildWorkflow: - test build: + - PreLoad - Clean - Build_Module_ModuleBuilder - Build_NestedModules_ModuleBuilder @@ -46,6 +47,7 @@ BuildWorkflow: - DscResource_Tests_Stop_On_Fail test: + - PreLoad - Pester_Tests_Stop_On_Fail - Pester_if_Code_Coverage_Under_Threshold diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Error.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Error.ps1 index 9f2331e4b..cc95a6848 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Error.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Error.ps1 @@ -41,7 +41,7 @@ Function Write-Error $VerbosePreference = $originalPreference # Test if the env:enableVerboseLogging variable is set to true - if ($null -ne $LogFilePath) + if (-not [String]::IsNullOrEmpty($LogFilePath)) { # Append the message to the log file $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Verbose.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Verbose.ps1 index a9eea4170..358b4f743 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Verbose.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Verbose.ps1 @@ -35,7 +35,7 @@ Function Write-Verbose Microsoft.PowerShell.Utility\Write-Verbose $Message # Test if the env:enableVerboseLogging variable is set to true - if ($null -ne $LogFilePath) + if (-not [String]::IsNullOrEmpty($LogFilePath)) { # Append the message to the log file $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" diff --git a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Warning.ps1 b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Warning.ps1 index 3a285c46e..ff5a80dc0 100644 --- a/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Warning.ps1 +++ b/source/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Logging/Proxy Functions/Write-Warning.ps1 @@ -41,7 +41,7 @@ Function Write-Warning Microsoft.PowerShell.Utility\Write-Warning $Message $VerbosePreference = $originalPreference - if ($null -ne $LogFilePath) + if (-not [String]::IsNullOrEmpty($LogFilePath)) { # Append the message to the log file $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" diff --git a/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 b/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 index 492ffb6a2..380a2fc75 100644 --- a/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 +++ b/source/Modules/AzureDevOpsDsc.Common/AzureDevOpsDsc.Common.psm1 @@ -4,13 +4,11 @@ param ( [Switch] $isClass ) -using module AzureDevOpsDsc # Setup/Import 'DscResource.Common' helper module #$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' #Import-Module -Name $script:resourceHelperModulePath - $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $ModuleRoot = $PSScriptRoot From 11848332f6ee44fb3dde76ef1e7f5ab42156858f Mon Sep 17 00:00:00 2001 From: Michael Zanatta Date: Wed, 8 Jan 2025 12:08:39 +1000 Subject: [PATCH 5/5] Big Fixes with Unit Tests --- .../Api/Functions/Private/Helper/Find-Identity.tests.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Unit/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.tests.ps1 b/tests/Unit/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.tests.ps1 index 2b400c4a9..b6081be97 100644 --- a/tests/Unit/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.tests.ps1 +++ b/tests/Unit/Modules/AzureDevOpsDsc.Common/Api/Functions/Private/Helper/Find-Identity.tests.ps1 @@ -105,10 +105,8 @@ Describe 'Find-Identity Function Tests' { } - it 'Should write a non-terminating error when the SearchType is incorrect' { - Mock Write-Error -Verifiable + it 'Should write a terminating error when the SearchType is incorrect' { { Find-Identity -Name 'groupDescriptor' -OrganizationName 'TestOrg' -SearchType 'invalidType' } | Should -Throw - $result | Should -BeNullOrEmpty } it 'Should return a value for the search-type ' -TestCases $params {