Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7c1a76d
🪲 [Fix]: Refactor response handling in GitHub app installation functi…
MariusStorhaug Jun 25, 2025
192b63b
🪲 [Fix]: Update installation handling in Get-GitHubEnterpriseOrganiza…
MariusStorhaug Jun 25, 2025
83e3211
🪲 [Fix]: Enhance GitHubAppInstallation constructor to accept target a…
MariusStorhaug Jun 25, 2025
f8d9846
Add initial test scripts for GitHub API interactions
MariusStorhaug Jun 25, 2025
a6ff73a
🪲 [Fix]: Add test case for GitHub App Enterprise authentication with …
MariusStorhaug Jun 25, 2025
c1bd5fe
🪲 [Fix]: Update owner in PEM + IAT test case for Enterprise account a…
MariusStorhaug Jun 25, 2025
e826659
🪲 [Fix]: Update Apps.Tests to enhance GitHub App installation tests a…
MariusStorhaug Jun 25, 2025
edeccc9
🪲 [Fix]: Update test case for GitHub App installation to use correct …
MariusStorhaug Jun 25, 2025
68c7161
🪲 [Fix]: Change InstallationID type to uint64 and update related test…
MariusStorhaug Jun 25, 2025
bda131d
🪲 [Fix]: Add test case for GitHub App installation retrieval for orga…
MariusStorhaug Jun 25, 2025
cdd352f
[Fix]: Remove redundant '-Default' parameter from Connect-GitHubApp c…
MariusStorhaug Jun 25, 2025
86e5b98
🪲 [Fix]: Refactor Get-GitHubAppInstallation tests to use dynamic owne…
MariusStorhaug Jun 25, 2025
f38dd34
[Fix]: Update Get-GitHubAppInstallation test to correctly filter inst…
MariusStorhaug Jun 25, 2025
c6bcd40
[Fix]: Remove redundant section for GitHub Actions tests in Apps.Tests
MariusStorhaug Jun 25, 2025
287c77a
Add initial test scripts for GitHub API interactions
MariusStorhaug Jun 25, 2025
70a043f
[Fix]: Update tests to handle both 'repository' and 'enterprise' owne…
MariusStorhaug Jun 25, 2025
ace7d9b
[Fix]: Update Get-GitHubOrganization test to correctly skip based on …
MariusStorhaug Jun 25, 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
Prev Previous commit
Next Next commit
[Fix]: Update tests to handle both 'repository' and 'enterprise' owne…
…r types in various test files
  • Loading branch information
MariusStorhaug committed Jun 25, 2025
commit 70a043f526b6a3a94b2bc57e33a330b60c0baa8d
64 changes: 32 additions & 32 deletions tests/Data/AuthCases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,6 @@
Token = $env:GITHUB_TOKEN
}
}
@{
AuthType = 'App'
Type = 'a GitHub App from an Enterprise'
Case = 'PEM + IAT'
TokenType = 'APP_ENT'
Target = 'organization account'
Owner = 'psmodule-test-org3'
OwnerType = 'organization'
ConnectParams = @{
ClientID = $env:TEST_APP_ENT_CLIENT_ID
PrivateKey = $env:TEST_APP_ENT_PRIVATE_KEY
}
ConnectAppParams = @{
Organization = 'psmodule-test-org3'
}
}
@{
AuthType = 'App'
Type = 'a GitHub App from an Enterprise'
Case = 'PEM + IAT'
TokenType = 'APP_ENT'
Target = 'Enterprise account'
Owner = 'msx'
OwnerType = 'enterprise'
ConnectParams = @{
ClientID = $env:TEST_APP_ENT_CLIENT_ID
PrivateKey = $env:TEST_APP_ENT_PRIVATE_KEY
}
ConnectAppParams = @{
Enterprise = 'msx'
}
}
@{
AuthType = 'App'
Type = 'a GitHub App from an Organization'
Expand All @@ -97,3 +65,35 @@
}
}
)
@{
AuthType = 'App'
Type = 'a GitHub App from an Enterprise'
Case = 'PEM + IAT'
TokenType = 'APP_ENT'
Target = 'organization account'
Owner = 'psmodule-test-org3'
OwnerType = 'organization'
ConnectParams = @{
ClientID = $env:TEST_APP_ENT_CLIENT_ID
PrivateKey = $env:TEST_APP_ENT_PRIVATE_KEY
}
ConnectAppParams = @{
Organization = 'psmodule-test-org3'
}
}
@{
AuthType = 'App'
Type = 'a GitHub App from an Enterprise'
Case = 'PEM + IAT'
TokenType = 'APP_ENT'
Target = 'enterprise account'
Owner = 'msx'
OwnerType = 'enterprise'
ConnectParams = @{
ClientID = $env:TEST_APP_ENT_CLIENT_ID
PrivateKey = $env:TEST_APP_ENT_PRIVATE_KEY
}
ConnectAppParams = @{
Enterprise = 'msx'
}
}
22 changes: 11 additions & 11 deletions tests/Environments.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ Describe 'Environments' {
Write-Host ('-' * 60)
}

It 'Get-GitHubEnvironment - should return an empty list when no environments exist' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubEnvironment - should return an empty list when no environments exist' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Get-GitHubEnvironment -Owner $owner -Repository $repoName
LogGroup 'Environment' {
Write-Host ($result | Format-Table | Out-String)
}
$result | Should -BeNullOrEmpty
}
It 'Get-GitHubEnvironment - should return null when retrieving a non-existent environment' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubEnvironment - should return null when retrieving a non-existent environment' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Get-GitHubEnvironment -Owner $owner -Repository $repoName -Name $environmentName
LogGroup 'Environment' {
Write-Host ($result | Format-Table | Out-String)
}
$result | Should -BeNullOrEmpty
}
It 'Set-GitHubEnvironment - should successfully create an environment with a wait timer of 10' -Skip:($OwnerType -eq 'repository') {
It 'Set-GitHubEnvironment - should successfully create an environment with a wait timer of 10' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Set-GitHubEnvironment -Owner $owner -Repository $repoName -Name $environmentName -WaitTimer 10
LogGroup 'Environment' {
Write-Host ($result | Format-List | Out-String)
Expand All @@ -96,53 +96,53 @@ Describe 'Environments' {
$result.Name | Should -Be $environmentName
$result.ProtectionRules.wait_timer | Should -Be 10
}
It 'Get-GitHubEnvironment - should retrieve the environment that was created' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubEnvironment - should retrieve the environment that was created' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Get-GitHubEnvironment -Owner $owner -Repository $repoName -Name $environmentName
LogGroup 'Environment' {
Write-Host ($result | Format-List | Out-String)
}
$result | Should -Not -BeNullOrEmpty
$result.Name | Should -Be $environmentName
}
It 'Set-GitHubEnvironment - should successfully create an environment with a slash in its name' -Skip:($OwnerType -eq 'repository') {
It 'Set-GitHubEnvironment - should successfully create an environment with a slash in its name' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Set-GitHubEnvironment -Owner $owner -Repository $repoName -Name "$environmentName/$os"
LogGroup 'Environment' {
Write-Host ($result | Format-List | Out-String)
}
$result | Should -Not -BeNullOrEmpty
$result.Name | Should -Be "$environmentName/$os"
}
It 'Get-GitHubEnvironment - should retrieve the environment with a slash in its name' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubEnvironment - should retrieve the environment with a slash in its name' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Get-GitHubEnvironment -Owner $owner -Repository $repoName -Name "$environmentName/$os"
LogGroup 'Environment' {
Write-Host ($result | Format-Table | Out-String)
}
$result | Should -Not -BeNullOrEmpty
$result.Name | Should -Be "$environmentName/$os"
}
It 'Remove-GitHubEnvironment - should delete the environment with a slash in its name without errors' -Skip:($OwnerType -eq 'repository') {
It 'Remove-GitHubEnvironment - should delete the environment with a slash in its name without errors' -Skip:($OwnerType -in ('repository', 'enterprise')) {
{
Get-GitHubEnvironment -Owner $owner -Repository $repoName -Name "$environmentName/$os" | Remove-GitHubEnvironment -Confirm:$false
} | Should -Not -Throw
}
It 'Get-GitHubEnvironment - should return null when retrieving the deleted environment with a slash in its name' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubEnvironment - should return null when retrieving the deleted environment with a slash in its name' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Get-GitHubEnvironment -Owner $owner -Repository $repoName -Name "$environmentName/$os"
LogGroup 'Environment' {
Write-Host ($result | Format-Table | Out-String)
}
$result | Should -BeNullOrEmpty
}
It 'Get-GitHubEnvironment - should list one remaining environment' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubEnvironment - should list one remaining environment' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Get-GitHubEnvironment -Owner $owner -Repository $repoName
LogGroup 'Environment' {
Write-Host ($result | Format-Table | Out-String)
}
$result.Count | Should -Be 1
}
It 'Remove-GitHubEnvironment - should delete the remaining environment without errors' -Skip:($OwnerType -eq 'repository') {
It 'Remove-GitHubEnvironment - should delete the remaining environment without errors' -Skip:($OwnerType -in ('repository', 'enterprise')) {
{ Remove-GitHubEnvironment -Owner $owner -Repository $repoName -Name $environmentName -Confirm:$false } | Should -Not -Throw
}
It 'Get-GitHubEnvironment - should return null when retrieving an environment that does not exist' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubEnvironment - should return null when retrieving an environment that does not exist' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$result = Get-GitHubEnvironment -Owner $owner -Repository $repoName -Name $environmentName
LogGroup 'Environment' {
Write-Host ($result | Format-Table | Out-String)
Expand Down
18 changes: 7 additions & 11 deletions tests/Organizations.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,17 @@ Describe 'Organizations' {
}
$organizations | Should -Not -BeNullOrEmpty
}
if ($OwnerType -ne 'user') {
It 'Get-GitHubOrganizationMember - Gets the members of a specific organization' {
$members = Get-GitHubOrganizationMember -Organization $owner
LogGroup 'Members' {
Write-Host ($members | Select-Object * | Out-String)
}
$members | Should -Not -BeNullOrEmpty
It 'Get-GitHubOrganizationMember - Gets the members of a specific organization' -Skip:($OwnerType -in ('user', 'enterprise')) {
$members = Get-GitHubOrganizationMember -Organization $owner
LogGroup 'Members' {
Write-Host ($members | Select-Object * | Out-String)
}
$members | Should -Not -BeNullOrEmpty
}

# Tests for IAT UAT and PAT goes here
if ($OwnerType -eq 'user') {
It 'Get-GitHubOrganization - Gets the organizations for the authenticated user' {
{ Get-GitHubOrganization } | Should -Not -Throw
}
It 'Get-GitHubOrganization - Gets the organizations for the authenticated user' -Skip:($OwnerType -in ('user')) {
{ Get-GitHubOrganization } | Should -Not -Throw
}

if ($OwnerType -eq 'organization' -and $Type -ne 'GitHub Actions') {
Expand Down
4 changes: 2 additions & 2 deletions tests/Releases.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Describe 'Releases' {
Write-Host ('-' * 60)
}

Context 'Releases' -Skip:($OwnerType -eq 'repository') {
Context 'Releases' -Skip:($OwnerType -in ('repository', 'enterprise')) {
It 'New-GitHubRelease - Creates a new release' {
$release = New-GitHubRelease -Owner $Owner -Repository $repo -Tag 'v1.0' -Latest
LogGroup 'Release' {
Expand Down Expand Up @@ -316,7 +316,7 @@ Describe 'Releases' {
$notes.Notes | Should -Match $releaseTag
}
}
Context 'Release Assets' -Skip:($OwnerType -eq 'repository') {
Context 'Release Assets' -Skip:($OwnerType -in ('repository', 'enterprise')) {
BeforeAll {
$testFolderGuid = [Guid]::NewGuid().ToString().Substring(0, 8)
$testFolderName = "GHAssetTest-$testFolderGuid"
Expand Down
30 changes: 15 additions & 15 deletions tests/Repositories.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Describe 'Repositories' {
Write-Host ('-' * 60)
}

It 'New-GitHubRepository - Creates a new repository' -Skip:($OwnerType -eq 'repository') {
It 'New-GitHubRepository - Creates a new repository' -Skip:($OwnerType -in ('repository', 'enterprise')) {
LogGroup 'Repository - Creation' {
$params = @{
Name = $repoName
Expand Down Expand Up @@ -111,7 +111,7 @@ Describe 'Repositories' {
$repo.IsArchived | Should -Be $false
}
}
It 'New-GitHubRepository - Creates a new repository with settings' -Skip:($OwnerType -eq 'repository') {
It 'New-GitHubRepository - Creates a new repository with settings' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$name = "$repoName-settings"
LogGroup 'Repository - Creation + Settings' {
$params = @{
Expand Down Expand Up @@ -179,7 +179,7 @@ Describe 'Repositories' {
$repo.Homepage | Should -Be 'https://example.com'
}
}
It 'New-GitHubRepository - Creates a new repository from a template' -Skip:($OwnerType -eq 'repository') {
It 'New-GitHubRepository - Creates a new repository from a template' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$name = "$repoName-template"
LogGroup 'Repository - Template' {
$params = @{
Expand Down Expand Up @@ -228,7 +228,7 @@ Describe 'Repositories' {
$repo.IsArchived | Should -Be $false
}
}
It 'New-GitHubRepository - Creates a new repository as a fork' -Skip:($OwnerType -eq 'repository') {
It 'New-GitHubRepository - Creates a new repository as a fork' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$name = "$repoName-fork"
LogGroup 'Repository - Fork' {
$params = @{
Expand Down Expand Up @@ -297,7 +297,7 @@ Describe 'Repositories' {
}
$repos | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubRepository - Gets a specific repository' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubRepository - Gets a specific repository' -Skip:($OwnerType -in ('repository', 'enterprise')) {
LogGroup 'Repository' {
switch ($OwnerType) {
'user' {
Expand All @@ -311,7 +311,7 @@ Describe 'Repositories' {
}
$repo | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubRepository - Gets repositories with properties' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubRepository - Gets repositories with properties' -Skip:($OwnerType -in ('repository', 'enterprise')) {
LogGroup 'Repository - Property' {
switch ($OwnerType) {
'user' {
Expand All @@ -333,7 +333,7 @@ Describe 'Repositories' {
$item.Owner | Should -BeNullOrEmpty
}
}
It 'Get-GitHubRepository - Gets repositories with additional properties' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubRepository - Gets repositories with additional properties' -Skip:($OwnerType -in ('repository', 'enterprise')) {
LogGroup 'Repository - AdditionalProperty' {
switch ($OwnerType) {
'user' {
Expand All @@ -349,7 +349,7 @@ Describe 'Repositories' {
$repo.CreatedAt | Should -Not -BeNullOrEmpty
$repo.UpdatedAt | Should -Not -BeNullOrEmpty
}
It 'Get-GitHubRepository - Gets repositories with properties - only name' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubRepository - Gets repositories with properties - only name' -Skip:($OwnerType -in ('repository', 'enterprise')) {
LogGroup 'Repository - Property' {
switch ($OwnerType) {
'user' {
Expand Down Expand Up @@ -386,7 +386,7 @@ Describe 'Repositories' {
}
$repos.Count | Should -BeGreaterThan 0
}
It 'Set-GitHubRepository - Updates an existing repository' -Skip:($OwnerType -eq 'repository') {
It 'Set-GitHubRepository - Updates an existing repository' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$description = 'Updated description'
LogGroup 'Repository - Set update' {
switch ($OwnerType) {
Expand All @@ -412,7 +412,7 @@ Describe 'Repositories' {
$changedProps.Count | Should -Be 2
}
}
It 'Set-GitHubRepository - Creates a new repository when missing' -Skip:($OwnerType -eq 'repository') {
It 'Set-GitHubRepository - Creates a new repository when missing' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$newRepoName = "$repoName-new"
LogGroup 'Repository - Set create' {
switch ($OwnerType) {
Expand All @@ -433,7 +433,7 @@ Describe 'Repositories' {
$repo | Should -Not -BeNullOrEmpty
}
}
It 'Update-GitHubRepository - Renames a repository' -Skip:($OwnerType -eq 'repository') {
It 'Update-GitHubRepository - Renames a repository' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$newName = "$repoName-newname"
LogGroup 'Repository - Renamed' {
switch ($OwnerType) {
Expand Down Expand Up @@ -465,7 +465,7 @@ Describe 'Repositories' {
$changedProps.Count | Should -Be 8
}
}
It 'Remove-GitHubRepository - Removes all repositories' -Skip:($OwnerType -eq 'repository') {
It 'Remove-GitHubRepository - Removes all repositories' -Skip:($OwnerType -in ('repository', 'enterprise')) {
switch ($OwnerType) {
'user' {
Get-GitHubRepository | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false
Expand All @@ -476,7 +476,7 @@ Describe 'Repositories' {
}
}
}
It 'Get-GitHubRepository - Gets none repositories after removal' -Skip:($OwnerType -eq 'repository') {
It 'Get-GitHubRepository - Gets none repositories after removal' -Skip:($OwnerType -in ('repository', 'enterprise')) {
switch ($OwnerType) {
'user' {
$repos = Get-GitHubRepository -Username $Owner | Where-Object { $_.name -like "$repoName*" }
Expand All @@ -490,7 +490,7 @@ Describe 'Repositories' {
$repos | Should -BeNullOrEmpty
}
}
It 'Set-GitHubRepository - Creates and updates a repository from a template' -Skip:($OwnerType -eq 'repository') {
It 'Set-GitHubRepository - Creates and updates a repository from a template' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$templateRepoName = "$repoName-template"
$templateParams = @{
Name = $templateRepoName
Expand Down Expand Up @@ -541,7 +541,7 @@ Describe 'Repositories' {
$changedProps.Count | Should -Be 4
}
}
It 'Set-GitHubRepository - Creates and updates a repository as a fork' -Skip:($OwnerType -eq 'repository') {
It 'Set-GitHubRepository - Creates and updates a repository as a fork' -Skip:($OwnerType -in ('repository', 'enterprise')) {
$name = "$repoName-fork3"
$forkParams = @{
Name = $name
Expand Down
4 changes: 2 additions & 2 deletions tests/Secrets.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Describe 'Secrets' {
}
}

Context 'Repository' -Skip:($OwnerType -eq 'repository') {
Context 'Repository' -Skip:($OwnerType -in ('repository', 'enterprise')) {
BeforeAll {
$scope = @{
Owner = $owner
Expand Down Expand Up @@ -420,7 +420,7 @@ Describe 'Secrets' {
}
}

Context 'Environment' -Skip:($OwnerType -eq 'repository') {
Context 'Environment' -Skip:($OwnerType -in ('repository', 'enterprise')) {
BeforeAll {
$scope = @{
Owner = $owner
Expand Down
4 changes: 2 additions & 2 deletions tests/Variables.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Describe 'Variables' {
}
}

Context 'Repository' -Skip:($OwnerType -eq 'repository') {
Context 'Repository' -Skip:($OwnerType -in ('repository', 'enterprise')) {
BeforeAll {
$scope = @{
Owner = $owner
Expand Down Expand Up @@ -447,7 +447,7 @@ Describe 'Variables' {
}
}

Context 'Environment' -Skip:($OwnerType -eq 'repository') {
Context 'Environment' -Skip:($OwnerType -in ('repository', 'enterprise')) {
BeforeAll {
$scope = @{
Owner = $owner
Expand Down