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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

filter Remove-GitHubContext {
<#
Expand Down
2 changes: 1 addition & 1 deletion src/functions/private/Auth/Context/Set-GitHubContext.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

function Set-GitHubContext {
<#
Expand Down
2 changes: 1 addition & 1 deletion src/functions/public/Auth/Context/Get-GitHubContext.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

function Get-GitHubContext {
<#
Expand Down
56 changes: 56 additions & 0 deletions src/functions/public/Auth/Context/Get-GitHubContextInfo.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

function Get-GitHubContextInfo {
<#
.SYNOPSIS
Lists the available GitHub contexts without getting the context data.

.DESCRIPTION
Lists the available GitHub contexts without getting the context data.

.EXAMPLE
Get-GitHubContextInfo

Gets the current GitHub context.

.EXAMPLE
Get-GitHubContextInfo -Name 'github.com*'

Gets the GitHub context that matches the name 'github.com*'.

.EXAMPLE
Get-GitHubContextInfo -Name '*/Organization/*'

Gets the GitHub context that matches the name '*/Organization/*'.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidUsingConvertToSecureStringWithPlainText', '',
Justification = 'Encapsulated in a function. Never leaves as a plain text.'
)]
[OutputType([GitHubContext])]
[CmdletBinding(DefaultParameterSetName = '__AllParameterSets')]
param(
# The name of the context to get.
[Parameter()]
[SupportsWildcards()]
[string] $Name = '*'
)

begin {
$stackPath = Get-PSCallStackPath
Write-Debug "[$stackPath] - Start"
Initialize-GitHubConfig
}

process {
try {
Get-ContextInfo -ID "$($script:GitHub.Config.ID)/$Name"
} catch {
throw $_
}
}

end {
Write-Debug "[$stackPath] - End"
}
}
7 changes: 5 additions & 2 deletions src/functions/public/Auth/Update-GitHubUserAccessToken.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function Update-GitHubUserAccessToken {
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

function Update-GitHubUserAccessToken {
<#
.SYNOPSIS
Updates the GitHub access token.
Expand All @@ -22,7 +24,8 @@
[OutputType([securestring])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'The tokens are recieved as clear text. Mitigating exposure by removing variables and performing garbage collection.')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '',
Justification = 'The tokens are recieved as clear text. Mitigating exposure by removing variables and performing garbage collection.')]
[CmdletBinding(SupportsShouldProcess)]
param(
# The context to run the command in. Used to get the details for the API call.
Expand Down
2 changes: 1 addition & 1 deletion src/functions/public/Config/Get-GitHubConfig.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

function Get-GitHubConfig {
<#
Expand Down
2 changes: 1 addition & 1 deletion src/functions/public/Config/Remove-GitHubConfig.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

function Remove-GitHubConfig {
<#
Expand Down
2 changes: 1 addition & 1 deletion src/functions/public/Config/Set-GitHubConfig.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' }

function Set-GitHubConfig {
<#
Expand Down
8 changes: 4 additions & 4 deletions tests/GitHub.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Describe 'GitHub' {
PrivateKey = $env:TEST_APP_PRIVATE_KEY
}
{ Connect-GitHubAccount @params } | Should -Not -Throw
$contexts = Get-GitHubContext -ListAvailable -Verbose:$false
$contexts = Get-GitHubContextInfo -Verbose:$false
Write-Verbose ($contexts | Out-String) -Verbose
($contexts).Count | Should -Be 3
}
Expand All @@ -72,16 +72,16 @@ Describe 'GitHub' {
PrivateKey = $env:TEST_APP_PRIVATE_KEY
}
{ Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw
$contexts = Get-GitHubContext -ListAvailable -Verbose:$false
$contexts = Get-GitHubContextInfo -Verbose:$false
Write-Verbose ($contexts | Out-String) -Verbose
($contexts).Count | Should -Be 7
}

It 'Can disconnect a specific context' {
{ Disconnect-GitHubAccount -Context 'github.com/psmodule-test-app/Organization/PSModule' -Silent } | Should -Not -Throw
$contexts = Get-GitHubContext -ListAvailable -Verbose:$false
$contexts = Get-GitHubContextInfo -Name 'github.com/psmodule-test-app/*' -Verbose:$false
Write-Verbose ($contexts | Out-String) -Verbose
($contexts).Count | Should -Be 6
($contexts).Count | Should -Be 3
Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY -AutoloadInstallations
$contexts = Get-GitHubContext -ListAvailable -Verbose:$false
Write-Verbose ($contexts | Out-String) -Verbose
Expand Down