Skip to content
Closed
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
10 changes: 8 additions & 2 deletions GitHubConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
23 changes: 15 additions & 8 deletions Tests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand All @@ -48,14 +53,16 @@ function Initialize-CommonTestSetup
}
else
{
$secureString = $env:ciAccessToken | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential "<username is ignored>", $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 "<username is ignored>", $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
Expand Down