Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
18502e7
🚀 [Feature]: Add comprehensive authentication tests for GitHub accoun…
MariusStorhaug Mar 20, 2025
c281be0
🩹 [Patch]: Refactor connection parameter variable names in authentica…
MariusStorhaug Mar 20, 2025
8a6c5dd
🩹 [Patch]: Rename variable for authentication test cases and enhance …
MariusStorhaug Mar 20, 2025
ba92286
🩹 [Patch]: Add debug output for context in authentication test cases
MariusStorhaug Mar 20, 2025
5d0602d
🩹 [Patch]: Enhance login feedback for GitHub account connections and …
MariusStorhaug Mar 20, 2025
1593fc5
🩹 [Patch]: Update logging and test descriptions for GitHub account co…
MariusStorhaug Mar 20, 2025
5aa1172
🩹 [Patch]: Improve logging for GitHub account connection and enhance …
MariusStorhaug Mar 20, 2025
71d197a
🩹 [Patch]: Enhance login and logout messages with color formatting fo…
MariusStorhaug Mar 20, 2025
c585d03
🩹 [Patch]: Simplify login and connection messages by removing unneces…
MariusStorhaug Mar 20, 2025
438df9d
🩹 [Patch]: Update authentication tests to use silent mode for GitHub …
MariusStorhaug Mar 20, 2025
6907b56
🩹 [Patch]: Update Disconnect-GitHubAccount test to suppress warnings …
MariusStorhaug Mar 20, 2025
8d0c719
🩹 [Patch]: Refactor authentication tests to remove redundant contexts…
MariusStorhaug Mar 20, 2025
36e9736
🩹 [Patch]: Refactor Connect-GitHubApp test to improve context handlin…
MariusStorhaug Mar 20, 2025
16e612d
🩹 [Patch]: Suppress Write-Host warnings in test files to improve logg…
MariusStorhaug Mar 20, 2025
83679eb
🩹 [Patch]: Simplify Connect-GitHubApp invocation in authentication te…
MariusStorhaug Mar 20, 2025
244cb72
🩹 [Patch]: Refactor authentication tests to enhance context handling …
MariusStorhaug Mar 20, 2025
fea5849
🩹 [Patch]: Remove obsolete Auth2.Tests.ps1 file to streamline test suite
MariusStorhaug Mar 20, 2025
c0d308e
🩹 [Feature]: Add Switch-GitHubContext function to set the default Git…
MariusStorhaug Mar 20, 2025
764cece
🩹 [Patch]: Update Connect-GitHubApp invocation to include Silent para…
MariusStorhaug Mar 20, 2025
ae8a13a
🩹 [Patch]: Remove unnecessary blank line in Auth.Tests.ps1 to improve…
MariusStorhaug Mar 20, 2025
8ce8afe
🩹 [Patch]: Update Disconnect-GitHubAccount to conditionally display w…
MariusStorhaug Mar 20, 2025
3bacabb
🩹 [Refactor]: Move AuthCases to Data directory and update test script…
MariusStorhaug Mar 20, 2025
7197bd4
🩹 [Patch]: Simplify Set-GitHubContext by removing redundant AuthType …
MariusStorhaug Mar 20, 2025
c8e1f9f
🩹 [Patch]: Update Assert-GitHubContext to support multiple AuthType v…
MariusStorhaug Mar 20, 2025
5e707da
🩹 [Refactor]: Streamline Emoji tests by consolidating contexts and en…
MariusStorhaug Mar 20, 2025
3895281
🩹 [Fix]: Correct log function name and update test description for cl…
MariusStorhaug Mar 20, 2025
7aa46df
🩹 [Fix]: Correct formatting in Emojis test to enhance readability and…
MariusStorhaug Mar 20, 2025
14796d8
🩹 [Refactor]: Simplify Emoji tests by removing unnecessary code block…
MariusStorhaug Mar 20, 2025
9abd6a4
<describe the changes made in the code>
MariusStorhaug Mar 20, 2025
af4ff25
🩹 [Add]: Introduce new test for New-GitHubRepository to validate beha…
MariusStorhaug Mar 20, 2025
495a79f
🩹 [Enhance]: Add OwnerType property to authentication cases for impro…
MariusStorhaug Mar 20, 2025
6ee2eb8
🩹 [Refactor]: Streamline repository access tests by consolidating use…
MariusStorhaug Mar 21, 2025
4503824
🩹 [Refactor]: Add AfterAll cleanup to disconnect GitHub accounts in m…
MariusStorhaug Mar 21, 2025
a5644a6
🩹 [Refactor]: Improve test structure for Get-GitHubUser and email man…
MariusStorhaug Mar 21, 2025
23fdd77
🩹 [Refactor]: Remove redundant AfterAll cleanup from multiple test fi…
MariusStorhaug Mar 21, 2025
92b5c97
🩹 [Enhance]: Add BeforeAll setup and new tests for repository creatio…
MariusStorhaug Mar 21, 2025
6d3e55f
🩹 [Fix]: Update repository name generation to include operating syste…
MariusStorhaug Mar 21, 2025
5dde242
🩹 [Refactor]: Rename repository suffix to prefix and standardize vari…
MariusStorhaug Mar 21, 2025
87570e0
🩹 [Enhance]: Update parameter attributes in Remove-GitHubRepository t…
MariusStorhaug Mar 21, 2025
86b9fff
🩹 [Fix]: Update Get-GitHubRepository call to use Username parameter f…
MariusStorhaug Mar 21, 2025
197cb32
🩹 [Fix]: Replace Context with Get-Context in tests and simplify repos…
MariusStorhaug Mar 21, 2025
a7a8926
🩹 [Fix]: Replace Get-Context with Context in tests for improved clarity
MariusStorhaug Mar 21, 2025
5fbeb7d
[Fix]: Update Get-GitHubRepository call to use Owner parameter for ac…
MariusStorhaug Mar 21, 2025
d9ee7e3
🩹 [Fix]: Update test output formatting in Get-GitHubRepository tests …
MariusStorhaug Mar 21, 2025
d2d4877
🩹 [Fix]: Replace Get-Context with Context in tests for improved clari…
MariusStorhaug Mar 21, 2025
0298d62
[Fix]: Update repository prefix in tests for consistency and clarity
MariusStorhaug Mar 22, 2025
d1d95aa
[Fix]: Replace Get-Context with Context in template tests for improve…
MariusStorhaug Mar 22, 2025
970bff3
[Fix]: Add test to verify Get-GitHubRepository returns no repositorie…
MariusStorhaug Mar 22, 2025
917942d
[Fix]: Remove SkipTest comments for Get-GitHubRepository, New-GitHubR…
MariusStorhaug Mar 22, 2025
83c3ad2
[Fix]: Remove commented-out test runners in User.Tests and add Organi…
MariusStorhaug Mar 22, 2025
246234e
Fix: Rename variable for repository prefix to improve clarity and con…
MariusStorhaug Mar 22, 2025
ebd9bca
Fix: Update tests for Get-GitHubOrganization to ensure valid organiza…
MariusStorhaug Mar 22, 2025
4394e9e
Fix: Remove redundant owner assignment in Get-GitHubOrganization for …
MariusStorhaug Mar 22, 2025
b53d7b8
Fix: Remove unnecessary piping in Get-GitHubOrganization for improved…
MariusStorhaug Mar 22, 2025
8303722
Fix: Uncomment organization configuration tests in Organizations.Test…
MariusStorhaug Mar 22, 2025
0e6c498
Fix: Enhance organization invitation tests for improved coverage and …
MariusStorhaug Mar 22, 2025
cbdb021
Fix: Add test for Get-GitHubOrganizationMember to validate member ret…
MariusStorhaug Mar 22, 2025
51fb494
Fix: Add test for Get-GitHubOrganization to validate retrieval of aut…
MariusStorhaug Mar 22, 2025
d2f4596
Fix: Update organization tests to correctly validate member retrieval…
MariusStorhaug Mar 22, 2025
247ef8f
Fix: Correct condition in organization member retrieval test to ensur…
MariusStorhaug Mar 22, 2025
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
4 changes: 1 addition & 3 deletions src/functions/private/Auth/Context/Set-GitHubContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,8 @@ function Set-GitHubContext {
Set-GitHubDefaultContext -Context $contextObj['Name']
}
if ($script:GitHub.EnvironmentType -eq 'GHA') {
if ($contextObj['AuthType'] -eq 'IAT') {
Set-GitHubGitConfig -Context $contextObj['Name']
}
if ($contextObj['AuthType'] -ne 'APP') {
Set-GitHubGitConfig -Context $contextObj['Name']
Connect-GitHubCli -Context $contextObj
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/functions/public/Auth/Connect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,14 @@
Write-Verbose ($contextObj | Format-List | Out-String)
if (-not $Silent) {
$name = $contextObj.Username
Write-Host '✓ ' -ForegroundColor Green -NoNewline
Write-Host "Logged in as $name!"
if ($script:GitHub.EnvironmentType -eq 'GHA') {
$green = $PSStyle.Foreground.Green
$reset = $PSStyle.Reset
Write-Host "$green✓$reset Logged in as $name!"
} else {
Write-Host '✓ ' -ForegroundColor Green -NoNewline
Write-Host "Logged in as $name!"
}
}
if ($PassThru) {
Write-Debug "Passing context [$contextObj] to the pipeline."
Expand All @@ -303,7 +309,7 @@

if ($authType -eq 'App' -and $AutoloadInstallations) {
Write-Verbose 'Loading GitHub App Installation contexts...'
Connect-GitHubApp
Connect-GitHubApp -Silent:$Silent
}

} catch {
Expand Down
10 changes: 8 additions & 2 deletions src/functions/public/Auth/Connect-GitHubApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,14 @@
Write-Verbose ($contextObj | Format-List | Out-String)
if (-not $Silent) {
$name = $contextObj.name
Write-Host '✓ ' -ForegroundColor Green -NoNewline
Write-Host "Connected $name!"
if ($script:GitHub.EnvironmentType -eq 'GHA') {
$green = $PSStyle.Foreground.Green
$reset = $PSStyle.Reset
Write-Host "$green✓$reset Connected $name!"
} else {
Write-Host '✓ ' -ForegroundColor Green -NoNewline
Write-Host "Connected $name!"
}
}
if ($PassThru) {
Write-Debug "Passing context [$contextObj] to the pipeline."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Set-GitHubDefaultContext {
function Switch-GitHubContext {
<#
.SYNOPSIS
Set the default context.
Expand All @@ -7,8 +7,9 @@
Set the default context for the GitHub module.

.EXAMPLE
Set-GitHubDefaultContext -Context 'github.com/Octocat'
Switch-GitHubContext -Context 'github.com/Octocat'
#>
[Alias('Set-GitHubDefaultContext')]
[CmdletBinding(SupportsShouldProcess)]
param(
# The context to run the command in. Used to get the details for the API call.
Expand Down
16 changes: 12 additions & 4 deletions src/functions/public/Auth/Disconnect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,21 @@
$isDefaultContext = $contextItem.Name -eq $script:GitHub.Config.DefaultContext
if ($isDefaultContext) {
Remove-GitHubConfig -Name 'DefaultContext'
Write-Warning 'There is no longer a default context!'
Write-Warning "Please set a new default context using 'Set-GitHubDefaultContext -Name <context>'"
if (-not $Silent) {
Write-Warning 'There is no longer a default context!'
Write-Warning "Please set a new default context using 'Set-GitHubDefaultContext -Name <context>'"
}
}

if (-not $Silent) {
Write-Host '✓ ' -ForegroundColor Green -NoNewline
Write-Host "Logged out of GitHub! [$contextItem]"
if ($script:GitHub.EnvironmentType -eq 'GHA') {
$green = $PSStyle.Foreground.Green
$reset = $PSStyle.Reset
Write-Host "$green✓$reset Logged out of GitHub! [$contextItem]"
} else {
Write-Host '✓ ' -ForegroundColor Green -NoNewline
Write-Host "Logged out of GitHub! [$contextItem]"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/functions/public/Git/Set-GitHubGitConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$stackPath = Get-PSCallStackPath
Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
Assert-GitHubContext -Context $Context -AuthType IAT
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}

process {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@
Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT

if ([string]::IsNullOrEmpty($Owner)) {
$Owner = $Context.Owner
}
Write-Debug "Owner: [$Owner]"
}

process {
Expand All @@ -100,7 +95,7 @@
Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context
}
default {
Get-GitHubMyOrganization -PerPage $PerPage -Context $Context | Get-GitHubOrganizationByName -Context $Context
Get-GitHubMyOrganization -PerPage $PerPage -Context $Context
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,3 @@ filter Get-GitHubRepository {
Write-Debug "[$stackPath] - End"
}
}

#SkipTest:FunctionTest:Will add a test for this function in a future PR
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,3 @@ filter New-GitHubRepository {
Write-Debug "[$stackPath] - End"
}
}

#SkipTest:FunctionTest:Will add a test for this function in a future PR
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(Mandatory)]
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
[Alias('Organization')]
[Alias('User')]
[string] $Owner,

# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter(Mandatory)]
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
[string] $Name,

# The context to run the command in. Used to get the details for the API call.
Expand Down Expand Up @@ -60,5 +66,3 @@
Write-Debug "[$stackPath] - End"
}
}

#SkipTest:FunctionTest:Will add a test for this function in a future PR
1 change: 1 addition & 0 deletions src/loader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Write-Verbose "Path: $scriptFilePath"

switch ($script:GitHub.EnvironmentType) {
'GHA' {
$PSStyle.OutputRendering = 'Ansi'
Write-Verbose 'Detected running on a GitHub Actions runner, preparing environment...'
$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/'
Set-GitHubEnvironmentVariable -Name 'GITHUB_REPOSITORY_NAME' -Value $env:GITHUB_REPOSITORY_NAME
Expand Down
Loading