diff --git a/GitHubConfiguration.ps1 b/GitHubConfiguration.ps1 index 2097a7f5..32599fac 100644 --- a/GitHubConfiguration.ps1 +++ b/GitHubConfiguration.ps1 @@ -481,6 +481,9 @@ function Reset-GitHubConfiguration Reset-GitHubConfiguration Deletes the local configuration file and loads in all default configration values. + + .NOTES + This command will not clear your authentication token. Please use Clear-GitHubAuthentication to accomplish that. #> [CmdletBinding(SupportsShouldProcess)] param( @@ -504,7 +507,7 @@ function Reset-GitHubConfiguration Initialize-GitHubConfiguration - Write-Log -Message "This has not cleared your authentication token. Call Clear-GitHubAuthentication to accomplish that." -Level Warning + Write-Log -Message "This has not cleared your authentication token. Call Clear-GitHubAuthentication to accomplish that." -Level Verbose } function Read-GitHubConfiguration @@ -909,6 +912,9 @@ function Clear-GitHubAuthentication Clear-GitHubAuthentication Clears out any GitHub API token from memory, as well as from local file storage. + + .NOTES + This command will not clear your configuration settings. Please use Reset-GitHubConfiguration to accomplish that. #> [CmdletBinding(SupportsShouldProcess)] param( @@ -937,7 +943,7 @@ function Clear-GitHubAuthentication } } - Write-Log -Message "This has not cleared your configuration settings. Call Reset-GitHubConfiguration to accomplish that." -Level Warning + Write-Log -Message "This has not cleared your configuration settings. Call Reset-GitHubConfiguration to accomplish that." -Level Verbose } function Get-AccessToken diff --git a/Tests/Common.ps1 b/Tests/Common.ps1 index a6786925..ac4aef90 100644 --- a/Tests/Common.ps1 +++ b/Tests/Common.ps1 @@ -33,10 +33,15 @@ function Initialize-CommonTestSetup param() $moduleRootPath = Split-Path -Path $PSScriptRoot -Parent - . (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Config\Settings.ps1') + $settingsPath = Join-Path -Path $moduleRootPath -ChildPath 'Tests\Config\Settings.ps1' + . $settingsPath Import-Module -Name (Join-Path -Path $moduleRootPath -ChildPath 'PowerShellForGitHub.psd1') -Force - if ([string]::IsNullOrEmpty($env:ciAccessToken)) + $originalSettingsSha256Hash = "944D5BB450AD2C49F77DAE6C472FEF774B108CD2CB6A0DBF45EF4BBB7FE25D56" + $currentSettingsSha256Hash = (Get-FileHash -Path $settingsPath -Algorithm SHA256).Hash + $isSettingsUnaltered = $originalSettingsSha256Hash -eq $currentSettingsSha256Hash + + if ([string]::IsNullOrEmpty($env:ciAccessToken) -and $isSettingsUnaltered) { $message = @( 'The tests are using the configuration settings defined in Tests\Config\Settings.ps1.', @@ -48,14 +53,16 @@ function Initialize-CommonTestSetup } else { - $secureString = $env:ciAccessToken | ConvertTo-SecureString -AsPlainText -Force - $cred = New-Object System.Management.Automation.PSCredential "", $secureString - Set-GitHubAuthentication -Credential $cred + if(-not [string]::IsNullOrEmpty($env:ciAccessToken)) { + $secureString = $env:ciAccessToken | ConvertTo-SecureString -AsPlainText -Force + $cred = New-Object System.Management.Automation.PSCredential "", $secureString + Set-GitHubAuthentication -Credential $cred - $script:ownerName = $env:ciOwnerName - $script:organizationName = $env:ciOrganizationName + $script:ownerName = $env:ciOwnerName + $script:organizationName = $env:ciOrganizationName - Write-Warning -Message 'This run is being executed in the Azure Dev Ops environment.' + Write-Warning -Message 'This run is being executed in the Azure Dev Ops environment.' + } } $script:accessTokenConfigured = Test-GitHubAuthenticationConfigured