From 3af88dba521da1523d1fab6f84b53fc295b31a69 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 20 Dec 2024 21:08:11 +0100 Subject: [PATCH 01/41] Enable tests --- .github/workflows/Process-PSModule.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 0739b4def..447c6bf6d 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -34,7 +34,3 @@ jobs: Process-PSModule: uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v3 secrets: inherit - with: - SkipTests: SourceCode - Debug: true - Verbose: true From 4dd8b6b4cfde411253e1966d6a1726b288312f26 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 20 Dec 2024 21:08:20 +0100 Subject: [PATCH 02/41] Refactor test suite --- tests/GitHub.Tests.ps1 | 182 +++++++++++++++++++++++++---------------- 1 file changed, 111 insertions(+), 71 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 192e0ccaa..29b99d3ad 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -18,6 +18,33 @@ Describe 'GitHub' { $config | Should -Not -BeNullOrEmpty } } + Context 'Meta' { + It 'Get-GitHubRoot' { + $root = Get-GitHubRoot + Write-Verbose ($root | Format-Table | Out-String) -Verbose + $root | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubApiVersion' { + $apiVersion = Get-GitHubApiVersion + Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose + $apiVersion | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubMeta' { + $meta = Get-GitHubMeta + Write-Verbose ($meta | Format-Table | Out-String) -Verbose + $meta | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubOctocat' { + $octocat = Get-GitHubOctocat + Write-Verbose ($octocat | Format-Table | Out-String) -Verbose + $octocat | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubZen' { + $zen = Get-GitHubZen + Write-Verbose ($zen | Format-Table | Out-String) -Verbose + $zen | Should -Not -BeNullOrEmpty + } + } Context 'Auth' { It 'Can connect and disconnect without parameters in GitHubActions' { { Connect-GitHubAccount } | Should -Not -Throw @@ -66,6 +93,7 @@ Describe 'GitHub' { Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 3 } + It 'Can be called with a GitHub App and autoload installations' { $params = @{ ClientID = $env:TEST_APP_CLIENT_ID @@ -129,51 +157,36 @@ Describe 'GitHub' { $config.ID | Should -Be 'PSModule.GitHub' } } - Context 'Meta' { - It 'Get-GitHubRoot' { - $root = Get-GitHubRoot - Write-Verbose ($root | Format-Table | Out-String) -Verbose - $root | Should -Not -BeNullOrEmpty + Context 'Status' { + It 'Can be called with no parameters' { + { Get-GitHubScheduledMaintenance } | Should -Not -Throw } - It 'Get-GitHubApiVersion' { - $apiVersion = Get-GitHubApiVersion - Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose - $apiVersion | Should -Not -BeNullOrEmpty + It 'Can be called with Active parameter' { + { Get-GitHubScheduledMaintenance -Active } | Should -Not -Throw } - It 'Get-GitHubMeta' { - $meta = Get-GitHubMeta - Write-Verbose ($meta | Format-Table | Out-String) -Verbose - $meta | Should -Not -BeNullOrEmpty + It 'Can be called with Upcoming parameter' { + { Get-GitHubScheduledMaintenance -Upcoming } | Should -Not -Throw } - It 'Get-GitHubOctocat' { - $octocat = Get-GitHubOctocat - Write-Verbose ($octocat | Format-Table | Out-String) -Verbose - $octocat | Should -Not -BeNullOrEmpty + It 'Can be called with no parameters' { + { Get-GitHubStatus } | Should -Not -Throw } - It 'Get-GitHubZen' { - $zen = Get-GitHubZen - Write-Verbose ($zen | Format-Table | Out-String) -Verbose - $zen | Should -Not -BeNullOrEmpty + It 'Can be called with Summary parameter' { + { Get-GitHubStatus -Summary } | Should -Not -Throw } - } - Context 'Git' { - It 'Set-GitHubGitConfig sets the Git configuration' { - { Set-GitHubGitConfig } | Should -Not -Throw - $gitConfig = Get-GitHubGitConfig - Write-Verbose ($gitConfig | Format-Table | Out-String) -Verbose - - $gitConfig | Should -Not -BeNullOrEmpty - $gitConfig.'user.name' | Should -Not -BeNullOrEmpty - $gitConfig.'user.email' | Should -Not -BeNullOrEmpty + It 'Function exists' { + Get-Command Get-GitHubStatusComponent | Should -Not -BeNullOrEmpty } - } - Context 'API' { - It 'Can be called directly to get ratelimits' { - { - $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' - Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose - } | Should -Not -Throw - + It 'Can be called with no parameters' { + { Get-GitHubStatusComponent } | Should -Not -Throw + } + It 'Function exists' { + Get-Command Get-GitHubStatusIncident | Should -Not -BeNullOrEmpty + } + It 'Can be called with no parameters' { + { Get-GitHubStatusIncident } | Should -Not -Throw + } + It 'Can be called with Unresolved parameter' { + { Get-GitHubStatusIncident -Unresolved } | Should -Not -Throw } } Context 'Commands' { @@ -197,6 +210,28 @@ Describe 'GitHub' { } | Should -Not -Throw } } + + Context 'Git' { + It 'Set-GitHubGitConfig sets the Git configuration' { + { Set-GitHubGitConfig } | Should -Not -Throw + $gitConfig = Get-GitHubGitConfig + Write-Verbose ($gitConfig | Format-Table | Out-String) -Verbose + + $gitConfig | Should -Not -BeNullOrEmpty + $gitConfig.'user.name' | Should -Not -BeNullOrEmpty + $gitConfig.'user.email' | Should -Not -BeNullOrEmpty + } + } + Context 'API' { + It 'Can be called directly to get ratelimits' { + { + $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' + Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + + } + } + Context 'Rate-Limit' { It 'Can be called with no parameters' { { Get-GitHubRateLimit } | Should -Not -Throw @@ -241,38 +276,7 @@ Describe 'GitHub' { { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw } } - Context 'Status' { - It 'Can be called with no parameters' { - { Get-GitHubScheduledMaintenance } | Should -Not -Throw - } - It 'Can be called with Active parameter' { - { Get-GitHubScheduledMaintenance -Active } | Should -Not -Throw - } - It 'Can be called with Upcoming parameter' { - { Get-GitHubScheduledMaintenance -Upcoming } | Should -Not -Throw - } - It 'Can be called with no parameters' { - { Get-GitHubStatus } | Should -Not -Throw - } - It 'Can be called with Summary parameter' { - { Get-GitHubStatus -Summary } | Should -Not -Throw - } - It 'Function exists' { - Get-Command Get-GitHubStatusComponent | Should -Not -BeNullOrEmpty - } - It 'Can be called with no parameters' { - { Get-GitHubStatusComponent } | Should -Not -Throw - } - It 'Function exists' { - Get-Command Get-GitHubStatusIncident | Should -Not -BeNullOrEmpty - } - It 'Can be called with no parameters' { - { Get-GitHubStatusIncident } | Should -Not -Throw - } - It 'Can be called with Unresolved parameter' { - { Get-GitHubStatusIncident -Unresolved } | Should -Not -Throw - } - } + Context 'Disconnect' { It 'Can disconnect without parameters' { { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } | Should -Not -Throw @@ -280,3 +284,39 @@ Describe 'GitHub' { } } } + +Describe 'As a user - Fine-grained PAT token' { + BeforeAll { + Connect-GitHubAccount -Token $env:TEST_FG_PAT + } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount + } +} + +Describe 'As a user - Classic PAT token' { + BeforeAll { + Connect-GitHubAccount -Token $env:TEST_PAT + } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount + } +} + +Describe 'As GitHub Actions' { + BeforeAll { + Connect-GitHubAccount + } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount + } +} + +Describe 'As a GitHub App' { + BeforeAll { + Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY + } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount + } +} From 767b44ad4e006b2e5ad79ac23d62f6dadc71f7b2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 20 Dec 2024 23:17:36 +0100 Subject: [PATCH 03/41] Improve code readability by formatting comments and function definitions across multiple scripts --- .../Utilities/PowerShell/Get-PSCallStackPath.ps1 | 3 ++- src/functions/public/Auth/Connect-GitHubApp.ps1 | 2 +- .../public/Auth/Update-GitHubUserAccessToken.ps1 | 11 ++++------- src/functions/public/Commands/Set-GitHubOutput.ps1 | 3 ++- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/functions/private/Utilities/PowerShell/Get-PSCallStackPath.ps1 b/src/functions/private/Utilities/PowerShell/Get-PSCallStackPath.ps1 index ab2b3e97e..8fe32f238 100644 --- a/src/functions/private/Utilities/PowerShell/Get-PSCallStackPath.ps1 +++ b/src/functions/private/Utilities/PowerShell/Get-PSCallStackPath.ps1 @@ -13,7 +13,8 @@ Get-PSCallStackPath First-Function\Second-Function\Third-Function - Shows the call stack of the last function called, Third-Function, with the first () and last (Get-PSCallStackPath) functions removed. + Shows the call stack of the last function called, Third-Function, with the first () + and last (Get-PSCallStackPath) functions removed. .EXAMPLE Get-PSCallStackPath -SkipFirst 0 diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 0942fb41b..d2ba3e23c 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -1,4 +1,4 @@ -function Connect-GitHubApp { +function Connect-GitHubApp { <# .SYNOPSIS Connects to GitHub as a installation using a GitHub App. diff --git a/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1 b/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1 index bbce1c0c2..ccf985237 100644 --- a/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.5' } - -function Update-GitHubUserAccessToken { +function Update-GitHubUserAccessToken { <# .SYNOPSIS Updates the GitHub access token. @@ -21,12 +19,11 @@ function Update-GitHubUserAccessToken { .NOTES [Refreshing user access tokens](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens) #> + [CmdletBinding(SupportsShouldProcess)] [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.')] - [CmdletBinding(SupportsShouldProcess)] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'The tokens are recieved as clear text. Mitigating exposure by removing variables and performing garbage collection.')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Scope = 'Function', Justification = 'Reason for suppressing')] param( # The context to run the command in. Used to get the details for the API call. # Can be either a string or a GitHubContext object. diff --git a/src/functions/public/Commands/Set-GitHubOutput.ps1 b/src/functions/public/Commands/Set-GitHubOutput.ps1 index b29f7a575..f3d54d5f2 100644 --- a/src/functions/public/Commands/Set-GitHubOutput.ps1 +++ b/src/functions/public/Commands/Set-GitHubOutput.ps1 @@ -60,7 +60,8 @@ Write-Verbose "Output: [$Name] = [$Value]" - # If the script is running in a GitHub composite action, accumulate the output under the 'result' key, else append the key-value pair directly. + # If the script is running in a GitHub composite action, accumulate the output under the 'result' key, + # else append the key-value pair directly. if ($env:PSMODULE_GITHUB_SCRIPT) { if (-not $outputs.result) { $outputs.result = @{ From d122f2f44ffd8582360041e71c75ad8cc14916d2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 20 Dec 2024 23:23:05 +0100 Subject: [PATCH 04/41] Fix --- .../Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 index 3e09fe391..2b9cf17c6 100644 --- a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 +++ b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 @@ -33,7 +33,7 @@ Creates an installation access token for the installation with the ID `12345678`. .EXAMPLE - Connect-GitHub -ClientID $ClientID -PrivateKey $PrivateKey -Verbose + Connect-GitHub -ClientID $ClientID -PrivateKey $PrivateKey Get-GitHubAppInstallation | New-GitHubAppInstallationAccessToken Gets the GitHub App installations and creates an installation access token for each installation. From 89117fbe87eaab09c4c81c10597e4025ccaba725 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 01:07:09 +0100 Subject: [PATCH 05/41] Add Command tests --- tests/GitHub.Tests.ps1 | 77 +++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 29b99d3ad..6088d6f35 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -173,15 +173,9 @@ Describe 'GitHub' { It 'Can be called with Summary parameter' { { Get-GitHubStatus -Summary } | Should -Not -Throw } - It 'Function exists' { - Get-Command Get-GitHubStatusComponent | Should -Not -BeNullOrEmpty - } It 'Can be called with no parameters' { { Get-GitHubStatusComponent } | Should -Not -Throw } - It 'Function exists' { - Get-Command Get-GitHubStatusIncident | Should -Not -BeNullOrEmpty - } It 'Can be called with no parameters' { { Get-GitHubStatusIncident } | Should -Not -Throw } @@ -190,18 +184,25 @@ Describe 'GitHub' { } } Context 'Commands' { - It "Start-LogGroup 'MyGroup' should not throw" { + It "Start-GitHubLogGroup 'MyGroup' should not throw" { { - Start-LogGroup 'MyGroup' + Start-GitHubLogGroup 'MyGroup' } | Should -Not -Throw } It 'Stop-LogGroup should not throw' { { - Stop-LogGroup + Stop-GitHubLogGroup } | Should -Not -Throw } + It "Set-GitHubLogGroup 'MyGroup' should not throw" { + { + Set-GitHubLogGroup -Name 'MyGroup' -ScriptBlock { + Get-ChildItem env: | Select-Object Name, Value | Format-Table -AutoSize + } + } | Should -Not -Throw + } It "LogGroup 'MyGroup' should not throw" { { LogGroup 'MyGroup' { @@ -209,6 +210,61 @@ Describe 'GitHub' { } } | Should -Not -Throw } + It 'Add-GitHubMask should not throw' { + { + Add-GitHubMask -Value 'taskmaster' + } | Should -Not -Throw + } + It 'Add-GitHubSystemPath should not throw' { + { + Add-GitHubPath -Path $pwd.ToString() + } | Should -Not -Throw + $env:Path | Should -Contain $pwd.ToString() + } + It 'Disable-GitHubCommand should not throw' { + { + Disable-GitHubCommand -String 'MyString' + } | Should -Not -Throw + } + It 'Enable-GitHubCommand should not throw' { + { + Enable-GitHubCommand -String 'MyString' + } | Should -Not -Throw + } + It 'Set-GitHubNoCommandGroup should not throw' { + { + Set-GitHubNoCommandGroup { + Write-Output 'Hello, World!' + } + } | Should -Not -Throw + } + It 'Set-GitHubOutput should not throw' { + { + Set-GitHubOutput -Name 'MyName' -Value 'MyValue' + } | Should -Not -Throw + } + It 'Get-GitHubOutput should not throw' { + { + Get-GitHubOutput + } | Should -Not -Throw + } + It 'Set-GitHubEnvironmentVariable should not throw' { + { + Set-GitHubEnvironmentVariable -Name 'MyName' -Value 'MyValue' + } | Should -Not -Throw + $env:MyName | Should -Be 'MyValue' + } + It 'Set-GitHubStepSummary should not throw' { + { + Set-GitHubStepSummary -Summary 'MySummary' + } | Should -Not -Throw + } + It 'Write-GitHub* should not throw' { + { Write-GitHubDebug 'Debug' } | Should -Not -Throw + { Write-GitHubError 'Error' } | Should -Not -Throw + { Write-GitHubNotice 'Notice' } | Should -Not -Throw + { Write-GitHubWarning 'Warning' } | Should -Not -Throw + } } Context 'Git' { @@ -238,9 +294,6 @@ Describe 'GitHub' { } } Context 'Repository' { - It 'Function exists' { - Get-Command Get-GitHubRepository | Should -Not -BeNullOrEmpty - } # Context 'Parameter Set: MyRepos_Type' { # It 'Can be called with no parameters' { From a4600660235154c22f4091a8370ec609cac978d0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 01:31:30 +0100 Subject: [PATCH 06/41] Add config tests --- tests/GitHub.Tests.ps1 | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 6088d6f35..9320d4220 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -12,11 +12,25 @@ BeforeAll { Describe 'GitHub' { Context 'Config' { - It 'Can get the configuration' { + It 'Get-GitHubConfig - Can get the configuration' { $config = Get-GitHubConfig Write-Verbose ($config | Format-Table | Out-String) -Verbose $config | Should -Not -BeNullOrEmpty } + It 'Set-GitHubConfig - Can set the configuration' { + Set-GitHubConfig -Name 'MyName' -Value 'MyValue' + Get-GitHubConfig -Name 'MyName' | Should -Be 'MyValue' + } + It 'Remove-GetGitHubConfig - Can remove the configuration' { + Remove-GitHubConfig -Name 'MyName' + { Get-GitHubConfig -Name 'MyName' } | Should -BeNullOrEmpty + } + It 'Reset-GitHubConfig - Can reset the configuration' { + Set-GitHubConfig -Name HostName -Value 'msx.ghe.com' + Get-GitHubConfig -Name HostName | Should -Be 'msx.ghe.com' + Reset-GitHubConfig + Get-GitHubConfig -Name HostName | Should -Be 'github.com' + } } Context 'Meta' { It 'Get-GitHubRoot' { @@ -189,13 +203,11 @@ Describe 'GitHub' { Start-GitHubLogGroup 'MyGroup' } | Should -Not -Throw } - It 'Stop-LogGroup should not throw' { { Stop-GitHubLogGroup } | Should -Not -Throw } - It "Set-GitHubLogGroup 'MyGroup' should not throw" { { Set-GitHubLogGroup -Name 'MyGroup' -ScriptBlock { @@ -266,7 +278,6 @@ Describe 'GitHub' { { Write-GitHubWarning 'Warning' } | Should -Not -Throw } } - Context 'Git' { It 'Set-GitHubGitConfig sets the Git configuration' { { Set-GitHubGitConfig } | Should -Not -Throw @@ -287,7 +298,6 @@ Describe 'GitHub' { } } - Context 'Rate-Limit' { It 'Can be called with no parameters' { { Get-GitHubRateLimit } | Should -Not -Throw @@ -329,7 +339,6 @@ Describe 'GitHub' { { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw } } - Context 'Disconnect' { It 'Can disconnect without parameters' { { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } | Should -Not -Throw From a3a6ee7f5bf0683fe1624a69e12628b4fbad49cd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 17:52:06 +0100 Subject: [PATCH 07/41] Fix --- src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 | 4 ++-- src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 | 4 ++-- ...hookDelivery.ps1 => Invoke-GitHubAppWebhookReDelivery.ps1} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename src/functions/public/Apps/Webhooks/{Redeliver-GitHubAppWebhookDelivery.ps1 => Invoke-GitHubAppWebhookReDelivery.ps1} (100%) diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index 437c83b70..a7fc5d519 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeamByName { +function Get-GitHubRESTTeamByName { <# .SYNOPSIS Get a team by name @@ -8,7 +8,7 @@ and replaces spaces with a - separator. For example, "My TEam Näme" would become my-team-name. .EXAMPLE - Get-GitHubTeamByName -Organization 'github' -Name 'my-team-name' + Get-GitHubRESTTeamByName -Organization 'github' -Name 'my-team-name' #> [OutputType([void])] [CmdletBinding()] diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index fb8cf4ec1..4575a53b2 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeamListByOrg { +function Get-GitHubRESTTeamListByOrg { <# .SYNOPSIS List teams @@ -7,7 +7,7 @@ Lists all teams in an organization that are visible to the authenticated user. .EXAMPLE - Get-GitHubTeamListByOrg -Organization 'github' + Get-GitHubRESTTeamListByOrg -Organization 'github' .NOTES [List teams](https://docs.github.com/rest/teams/teams#list-teams) diff --git a/src/functions/public/Apps/Webhooks/Redeliver-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 similarity index 100% rename from src/functions/public/Apps/Webhooks/Redeliver-GitHubAppWebhookDelivery.ps1 rename to src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 From 3e2e18531596debcacb969d9b89d34fc7e5afd47 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 18:10:01 +0100 Subject: [PATCH 08/41] Add parameter attributes to Invoke-GitHubGraphQLQuery for improved validation --- src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 index 49e6a8871..a34a49d2d 100644 --- a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 +++ b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 @@ -12,11 +12,14 @@ .NOTES [GitHub GraphQL API documentation](https://docs.github.com/graphql) #> + [CmdletBinding()] param( # The GraphQL query to execute. + [Parameter(Mandatory)] [string] $Query, # The variables to pass to the query. + [Parameter()] [hashtable] $Variables, # The context to run the command in. Used to get the details for the API call. From 94a078ba3eeb9bb774facd9f98fb10d427edfd20 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 18:52:36 +0100 Subject: [PATCH 09/41] Add context assertion for GitHub authentication in Set-GitHubGitConfig --- src/functions/public/Git/Set-GitHubGitConfig.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/functions/public/Git/Set-GitHubGitConfig.ps1 b/src/functions/public/Git/Set-GitHubGitConfig.ps1 index 3778ca7b7..f224edf05 100644 --- a/src/functions/public/Git/Set-GitHubGitConfig.ps1 +++ b/src/functions/public/Git/Set-GitHubGitConfig.ps1 @@ -28,6 +28,7 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context + Assert-GitHubContext -Context $Context -AuthType IAT } process { From 193d9c6406ed160cbe451a10fdb72ebd7cd1f91b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 18:52:42 +0100 Subject: [PATCH 10/41] Reorganize rate-limit tests in GitHub.Tests.ps1 for improved clarity and structure --- tests/GitHub.Tests.ps1 | 69 +++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 9320d4220..0b4837c0a 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -289,20 +289,6 @@ Describe 'GitHub' { $gitConfig.'user.email' | Should -Not -BeNullOrEmpty } } - Context 'API' { - It 'Can be called directly to get ratelimits' { - { - $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' - Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose - } | Should -Not -Throw - - } - } - Context 'Rate-Limit' { - It 'Can be called with no parameters' { - { Get-GitHubRateLimit } | Should -Not -Throw - } - } Context 'Repository' { # Context 'Parameter Set: MyRepos_Type' { @@ -354,6 +340,20 @@ Describe 'As a user - Fine-grained PAT token' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Not -Throw + } + } + Context 'API' { + It 'Can be called directly to get ratelimits' { + { + $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' + Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + + } + } } Describe 'As a user - Classic PAT token' { @@ -363,6 +363,20 @@ Describe 'As a user - Classic PAT token' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Not -Throw + } + } + Context 'API' { + It 'Can be called directly to get ratelimits' { + { + $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' + Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + + } + } } Describe 'As GitHub Actions' { @@ -372,6 +386,20 @@ Describe 'As GitHub Actions' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Not -Throw + } + } + Context 'API' { + It 'Can be called directly to get ratelimits' { + { + $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' + Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + + } + } } Describe 'As a GitHub App' { @@ -381,4 +409,17 @@ Describe 'As a GitHub App' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Throw + } + } + Context 'API' { + It 'Can be called directly to get ratelimits' { + { + $app = Invoke-GitHubAPI -ApiEndpoint '/app' + Write-Verbose ($app | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + } + } } From 20790baecdd7217a226f750c5821c5c7f8a47b7f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 19:22:54 +0100 Subject: [PATCH 11/41] Enhance GitHub status tests by adding 'Stamp' parameter and introduce GraphQL context tests for viewer retrieval --- tests/GitHub.Tests.ps1 | 52 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 0b4837c0a..734c976b3 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -171,30 +171,30 @@ Describe 'GitHub' { $config.ID | Should -Be 'PSModule.GitHub' } } - Context 'Status' { + Context 'Status' -ForEach @('public', 'eu') { It 'Can be called with no parameters' { - { Get-GitHubScheduledMaintenance } | Should -Not -Throw + { Get-GitHubScheduledMaintenance -Stamp $_ } | Should -Not -Throw } It 'Can be called with Active parameter' { - { Get-GitHubScheduledMaintenance -Active } | Should -Not -Throw + { Get-GitHubScheduledMaintenance -Stamp $_ -Active } | Should -Not -Throw } It 'Can be called with Upcoming parameter' { - { Get-GitHubScheduledMaintenance -Upcoming } | Should -Not -Throw + { Get-GitHubScheduledMaintenance -Stamp $_ -Upcoming } | Should -Not -Throw } It 'Can be called with no parameters' { - { Get-GitHubStatus } | Should -Not -Throw + { Get-GitHubStatus -Stamp $_ } | Should -Not -Throw } It 'Can be called with Summary parameter' { - { Get-GitHubStatus -Summary } | Should -Not -Throw + { Get-GitHubStatus -Stamp $_ -Summary } | Should -Not -Throw } It 'Can be called with no parameters' { - { Get-GitHubStatusComponent } | Should -Not -Throw + { Get-GitHubStatusComponent -Stamp $_ } | Should -Not -Throw } It 'Can be called with no parameters' { - { Get-GitHubStatusIncident } | Should -Not -Throw + { Get-GitHubStatusIncident -Stamp $_ } | Should -Not -Throw } It 'Can be called with Unresolved parameter' { - { Get-GitHubStatusIncident -Unresolved } | Should -Not -Throw + { Get-GitHubStatusIncident -Stamp $_ -Unresolved } | Should -Not -Throw } } Context 'Commands' { @@ -229,7 +229,7 @@ Describe 'GitHub' { } It 'Add-GitHubSystemPath should not throw' { { - Add-GitHubPath -Path $pwd.ToString() + Add-GitHubSystemPath -Path $pwd.ToString() } | Should -Not -Throw $env:Path | Should -Contain $pwd.ToString() } @@ -354,6 +354,14 @@ Describe 'As a user - Fine-grained PAT token' { } } + Context 'GraphQL' { + It 'Can be called directly to get viewer' { + { + $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' + Write-Verbose ($viewer | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + } + } } Describe 'As a user - Classic PAT token' { @@ -377,6 +385,14 @@ Describe 'As a user - Classic PAT token' { } } + Context 'GraphQL' { + It 'Can be called directly to get viewer' { + { + $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' + Write-Verbose ($viewer | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + } + } } Describe 'As GitHub Actions' { @@ -400,6 +416,14 @@ Describe 'As GitHub Actions' { } } + Context 'GraphQL' { + It 'Can be called directly to get viewer' { + { + $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' + Write-Verbose ($viewer | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + } + } } Describe 'As a GitHub App' { @@ -422,4 +446,12 @@ Describe 'As a GitHub App' { } | Should -Not -Throw } } + Context 'GraphQL' { + It 'Can be called directly to get viewer' { + { + $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' + Write-Verbose ($viewer | Format-Table | Out-String) -Verbose + } | Should -Throw + } + } } From fbb3ab091dd32258a1bf178edff3a9e95694eced Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 19:37:59 +0100 Subject: [PATCH 12/41] Remove unnecessary blank line in Get-GitHubLicense.ps1 for improved readability --- .../public/License/Get-GitHubLicense.ps1 | 1 - tests/GitHub.Tests.ps1 | 267 +++++++++++------- 2 files changed, 165 insertions(+), 103 deletions(-) diff --git a/src/functions/public/License/Get-GitHubLicense.ps1 b/src/functions/public/License/Get-GitHubLicense.ps1 index 1b3bd66b3..230734a85 100644 --- a/src/functions/public/License/Get-GitHubLicense.ps1 +++ b/src/functions/public/License/Get-GitHubLicense.ps1 @@ -32,7 +32,6 @@ filter Get-GitHubLicense { [Get a license](https://docs.github.com/rest/licenses/licenses#get-a-license) [Get all commonly used licenses](https://docs.github.com/rest/licenses/licenses#get-all-commonly-used-licenses) [Get the license for a repository](https://docs.github.com/rest/licenses/licenses#get-the-license-for-a-repository) - #> [CmdletBinding(DefaultParameterSetName = 'List')] param( diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 734c976b3..48802af7a 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -32,33 +32,6 @@ Describe 'GitHub' { Get-GitHubConfig -Name HostName | Should -Be 'github.com' } } - Context 'Meta' { - It 'Get-GitHubRoot' { - $root = Get-GitHubRoot - Write-Verbose ($root | Format-Table | Out-String) -Verbose - $root | Should -Not -BeNullOrEmpty - } - It 'Get-GitHubApiVersion' { - $apiVersion = Get-GitHubApiVersion - Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose - $apiVersion | Should -Not -BeNullOrEmpty - } - It 'Get-GitHubMeta' { - $meta = Get-GitHubMeta - Write-Verbose ($meta | Format-Table | Out-String) -Verbose - $meta | Should -Not -BeNullOrEmpty - } - It 'Get-GitHubOctocat' { - $octocat = Get-GitHubOctocat - Write-Verbose ($octocat | Format-Table | Out-String) -Verbose - $octocat | Should -Not -BeNullOrEmpty - } - It 'Get-GitHubZen' { - $zen = Get-GitHubZen - Write-Verbose ($zen | Format-Table | Out-String) -Verbose - $zen | Should -Not -BeNullOrEmpty - } - } Context 'Auth' { It 'Can connect and disconnect without parameters in GitHubActions' { { Connect-GitHubAccount } | Should -Not -Throw @@ -278,53 +251,6 @@ Describe 'GitHub' { { Write-GitHubWarning 'Warning' } | Should -Not -Throw } } - Context 'Git' { - It 'Set-GitHubGitConfig sets the Git configuration' { - { Set-GitHubGitConfig } | Should -Not -Throw - $gitConfig = Get-GitHubGitConfig - Write-Verbose ($gitConfig | Format-Table | Out-String) -Verbose - - $gitConfig | Should -Not -BeNullOrEmpty - $gitConfig.'user.name' | Should -Not -BeNullOrEmpty - $gitConfig.'user.email' | Should -Not -BeNullOrEmpty - } - } - Context 'Repository' { - - # Context 'Parameter Set: MyRepos_Type' { - # It 'Can be called with no parameters' { - # { Get-GitHubRepository - } | Should -Not -Throw - # } - - # It 'Can be called with Type parameter' { - # { Get-GitHubRepository -Type 'public' } | Should -Not -Throw - # } - # } - - # Context 'Parameter Set: MyRepos_Aff-Vis' { - # It 'Can be called with Visibility and Affiliation parameters' { - # { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw - # } - # } - - It 'Can be called with Owner and Repo parameters' { - { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw - } - - # Context 'Parameter Set: ListByID' { - # It 'Can be called with SinceID parameter' { - # { Get-GitHubRepository -SinceID 123456789 } | Select-Object -First 10 | Should -Not -Throw - # } - # } - - It 'Can be called with Owner parameter' { - { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw - } - - It 'Can be called with Username parameter' { - { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw - } - } Context 'Disconnect' { It 'Can disconnect without parameters' { { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } | Should -Not -Throw @@ -340,11 +266,6 @@ Describe 'As a user - Fine-grained PAT token' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } - Context 'Rate-Limit' { - It 'Can be called with no parameters' { - { Get-GitHubRateLimit } | Should -Not -Throw - } - } Context 'API' { It 'Can be called directly to get ratelimits' { { @@ -362,6 +283,74 @@ Describe 'As a user - Fine-grained PAT token' { } | Should -Not -Throw } } + Context 'Meta' { + It 'Get-GitHubRoot' { + $root = Get-GitHubRoot + Write-Verbose ($root | Format-Table | Out-String) -Verbose + $root | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubApiVersion' { + $apiVersion = Get-GitHubApiVersion + Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose + $apiVersion | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubMeta' { + $meta = Get-GitHubMeta + Write-Verbose ($meta | Format-Table | Out-String) -Verbose + $meta | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubOctocat' { + $octocat = Get-GitHubOctocat + Write-Verbose ($octocat | Format-Table | Out-String) -Verbose + $octocat | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubZen' { + $zen = Get-GitHubZen + Write-Verbose ($zen | Format-Table | Out-String) -Verbose + $zen | Should -Not -BeNullOrEmpty + } + } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Not -Throw + } + } + Context 'License' { + It 'Can be called with no parameters' { + { Get-GitHubLicense } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw + } + It 'Can be called with Repository parameter' { + { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + } + } + Context 'Repository' { + Context 'Parameter Set: MyRepos_Type' { + It 'Can be called with no parameters' { + { Get-GitHubRepository - } | Should -Not -Throw + } + + It 'Can be called with Type parameter' { + { Get-GitHubRepository -Type 'public' } | Should -Not -Throw + } + } + Context 'Parameter Set: MyRepos_Aff-Vis' { + It 'Can be called with Visibility and Affiliation parameters' { + { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw + } + } + It 'Can be called with Owner and Repo parameters' { + { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + } + It 'Can be called with Owner parameter' { + { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw + } + It 'Can be called with Username parameter' { + { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw + } + } } Describe 'As a user - Classic PAT token' { @@ -371,11 +360,6 @@ Describe 'As a user - Classic PAT token' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } - Context 'Rate-Limit' { - It 'Can be called with no parameters' { - { Get-GitHubRateLimit } | Should -Not -Throw - } - } Context 'API' { It 'Can be called directly to get ratelimits' { { @@ -393,6 +377,49 @@ Describe 'As a user - Classic PAT token' { } | Should -Not -Throw } } + Context 'Meta' { + It 'Get-GitHubRoot' { + $root = Get-GitHubRoot + Write-Verbose ($root | Format-Table | Out-String) -Verbose + $root | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubApiVersion' { + $apiVersion = Get-GitHubApiVersion + Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose + $apiVersion | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubMeta' { + $meta = Get-GitHubMeta + Write-Verbose ($meta | Format-Table | Out-String) -Verbose + $meta | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubOctocat' { + $octocat = Get-GitHubOctocat + Write-Verbose ($octocat | Format-Table | Out-String) -Verbose + $octocat | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubZen' { + $zen = Get-GitHubZen + Write-Verbose ($zen | Format-Table | Out-String) -Verbose + $zen | Should -Not -BeNullOrEmpty + } + } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Not -Throw + } + } + Context 'License' { + It 'Can be called with no parameters' { + { Get-GitHubLicense } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw + } + It 'Can be called with Repository parameter' { + { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + } + } } Describe 'As GitHub Actions' { @@ -402,11 +429,6 @@ Describe 'As GitHub Actions' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } - Context 'Rate-Limit' { - It 'Can be called with no parameters' { - { Get-GitHubRateLimit } | Should -Not -Throw - } - } Context 'API' { It 'Can be called directly to get ratelimits' { { @@ -424,6 +446,60 @@ Describe 'As GitHub Actions' { } | Should -Not -Throw } } + Context 'Git' { + It 'Set-GitHubGitConfig sets the Git configuration' { + { Set-GitHubGitConfig } | Should -Not -Throw + $gitConfig = Get-GitHubGitConfig + Write-Verbose ($gitConfig | Format-Table | Out-String) -Verbose + + $gitConfig | Should -Not -BeNullOrEmpty + $gitConfig.'user.name' | Should -Not -BeNullOrEmpty + $gitConfig.'user.email' | Should -Not -BeNullOrEmpty + } + } + Context 'Meta' { + It 'Get-GitHubRoot' { + $root = Get-GitHubRoot + Write-Verbose ($root | Format-Table | Out-String) -Verbose + $root | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubApiVersion' { + $apiVersion = Get-GitHubApiVersion + Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose + $apiVersion | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubMeta' { + $meta = Get-GitHubMeta + Write-Verbose ($meta | Format-Table | Out-String) -Verbose + $meta | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubOctocat' { + $octocat = Get-GitHubOctocat + Write-Verbose ($octocat | Format-Table | Out-String) -Verbose + $octocat | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubZen' { + $zen = Get-GitHubZen + Write-Verbose ($zen | Format-Table | Out-String) -Verbose + $zen | Should -Not -BeNullOrEmpty + } + } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Not -Throw + } + } + Context 'License' { + It 'Can be called with no parameters' { + { Get-GitHubLicense } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw + } + It 'Can be called with Repository parameter' { + { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + } + } } Describe 'As a GitHub App' { @@ -433,11 +509,6 @@ Describe 'As a GitHub App' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } - Context 'Rate-Limit' { - It 'Can be called with no parameters' { - { Get-GitHubRateLimit } | Should -Throw - } - } Context 'API' { It 'Can be called directly to get ratelimits' { { @@ -446,12 +517,4 @@ Describe 'As a GitHub App' { } | Should -Not -Throw } } - Context 'GraphQL' { - It 'Can be called directly to get viewer' { - { - $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' - Write-Verbose ($viewer | Format-Table | Out-String) -Verbose - } | Should -Throw - } - } } From b7ba42e2c61e62b3bbd8505766d5fba6e0f17b13 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 19:45:33 +0100 Subject: [PATCH 13/41] MAke UpdateGitHubUserAccessToken private --- .../Auth/DeviceFlow}/Update-GitHubUserAccessToken.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/functions/{public/Auth => private/Auth/DeviceFlow}/Update-GitHubUserAccessToken.ps1 (100%) diff --git a/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 similarity index 100% rename from src/functions/public/Auth/Update-GitHubUserAccessToken.ps1 rename to src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 From 1b267d880f0d24c9bc8ae1d7f6f398f0d0f41fd8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 19:45:41 +0100 Subject: [PATCH 14/41] Rename Invoke-GitHubGraphQL to Invoke-GitHubGraphQLQuery for consistency in GraphQL viewer tests --- tests/GitHub.Tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 48802af7a..ef1a1d220 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -278,7 +278,7 @@ Describe 'As a user - Fine-grained PAT token' { Context 'GraphQL' { It 'Can be called directly to get viewer' { { - $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' + $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose } | Should -Not -Throw } @@ -372,7 +372,7 @@ Describe 'As a user - Classic PAT token' { Context 'GraphQL' { It 'Can be called directly to get viewer' { { - $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' + $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose } | Should -Not -Throw } @@ -441,7 +441,7 @@ Describe 'As GitHub Actions' { Context 'GraphQL' { It 'Can be called directly to get viewer' { { - $viewer = Invoke-GitHubGraphQL -Query 'query { viewer { login } }' + $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' Write-Verbose ($viewer | Format-Table | Out-String) -Verbose } | Should -Not -Throw } From bb77f7f6df79125573c6c007095d2b6bd042ae4b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 19:52:31 +0100 Subject: [PATCH 15/41] Add tests for Get-GitHubEmojis and GitHub App JWT retrieval --- tests/GitHub.Tests.ps1 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index ef1a1d220..ff4195546 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -326,6 +326,14 @@ Describe 'As a user - Fine-grained PAT token' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } + Context 'Emojis' { + It 'Can be called with no parameters' { + { Get-GitHubEmojis } | Should -Not -Throw + } + It 'Can be download the emojis' { + { Get-GitHubEmojis -Destination $env:TEMP } | Should -Not -Throw + } + } Context 'Repository' { Context 'Parameter Set: MyRepos_Type' { It 'Can be called with no parameters' { @@ -420,6 +428,14 @@ Describe 'As a user - Classic PAT token' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } + Context 'Emojis' { + It 'Can be called with no parameters' { + { Get-GitHubEmojis } | Should -Not -Throw + } + It 'Can be download the emojis' { + { Get-GitHubEmojis -Destination $env:TEMP } | Should -Not -Throw + } + } } Describe 'As GitHub Actions' { @@ -500,6 +516,14 @@ Describe 'As GitHub Actions' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } + Context 'Emojis' { + It 'Can be called with no parameters' { + { Get-GitHubEmojis } | Should -Not -Throw + } + It 'Can be download the emojis' { + { Get-GitHubEmojis -Destination $env:TEMP } | Should -Not -Throw + } + } } Describe 'As a GitHub App' { @@ -509,6 +533,18 @@ Describe 'As a GitHub App' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } + Context 'App' { + It 'Can get a JWT for the app' { + $jwt = Get-GitHubAppJSONWebToken -ClientId $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY + Write-Verbose ($jwt | Format-Table | Out-String) -Verbose + $jwt | Should -Not -BeNullOrEmpty + } + It 'Can get app details' { + $app = Get-GitHubApp + Write-Verbose ($app | Format-Table | Out-String) -Verbose + $app | Should -Not -BeNullOrEmpty + } + } Context 'API' { It 'Can be called directly to get ratelimits' { { From ea8513451b4dfd3fe00802061d5238a4871aabf9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 19:55:18 +0100 Subject: [PATCH 16/41] Rename Get-GitHubEmojis to Get-GitHubEmoji for consistency in tests --- tests/GitHub.Tests.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index ff4195546..514765047 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -326,12 +326,12 @@ Describe 'As a user - Fine-grained PAT token' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } - Context 'Emojis' { + Context 'Emoji' { It 'Can be called with no parameters' { - { Get-GitHubEmojis } | Should -Not -Throw + { Get-GitHubEmoji } | Should -Not -Throw } It 'Can be download the emojis' { - { Get-GitHubEmojis -Destination $env:TEMP } | Should -Not -Throw + { Get-GitHubEmoji -Destination $env:TEMP } | Should -Not -Throw } } Context 'Repository' { @@ -428,12 +428,12 @@ Describe 'As a user - Classic PAT token' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } - Context 'Emojis' { + Context 'Emoji' { It 'Can be called with no parameters' { - { Get-GitHubEmojis } | Should -Not -Throw + { Get-GitHubEmoji } | Should -Not -Throw } It 'Can be download the emojis' { - { Get-GitHubEmojis -Destination $env:TEMP } | Should -Not -Throw + { Get-GitHubEmoji -Destination $env:TEMP } | Should -Not -Throw } } } @@ -516,12 +516,12 @@ Describe 'As GitHub Actions' { { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw } } - Context 'Emojis' { + Context 'Emoji' { It 'Can be called with no parameters' { - { Get-GitHubEmojis } | Should -Not -Throw + { Get-GitHubEmoji } | Should -Not -Throw } It 'Can be download the emojis' { - { Get-GitHubEmojis -Destination $env:TEMP } | Should -Not -Throw + { Get-GitHubEmoji -Destination $env:TEMP } | Should -Not -Throw } } } From 47d881be1ce158f1ea2dce5042aa9e624b7f3753 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 20:07:46 +0100 Subject: [PATCH 17/41] Add tests for Get-GitHubGitignore function with parameter handling --- .../public/Gitignore/Get-GitHubGitignore.ps1 | 1 - tests/GitHub.Tests.ps1 | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 index 70ae5b2f1..7fca1570e 100644 --- a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 +++ b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 @@ -22,7 +22,6 @@ filter Get-GitHubGitignore { .NOTES [Get a gitignore template](https://docs.github.com/rest/gitignore/gitignore#get-a-gitignore-template) [Get all gitignore templates](https://docs.github.com/rest/gitignore/gitignore#get-all-gitignore-templates) - #> [CmdletBinding(DefaultParameterSetName = 'List')] param( diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 514765047..86366e2c4 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -359,6 +359,14 @@ Describe 'As a user - Fine-grained PAT token' { { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw } } + Context 'GitIgnore' { + It 'Can be called with no parameters' { + { Get-GitHubGitignore } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw + } + } } Describe 'As a user - Classic PAT token' { @@ -436,6 +444,14 @@ Describe 'As a user - Classic PAT token' { { Get-GitHubEmoji -Destination $env:TEMP } | Should -Not -Throw } } + Context 'GitIgnore' { + It 'Can be called with no parameters' { + { Get-GitHubGitignore } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw + } + } } Describe 'As GitHub Actions' { @@ -524,6 +540,14 @@ Describe 'As GitHub Actions' { { Get-GitHubEmoji -Destination $env:TEMP } | Should -Not -Throw } } + Context 'GitIgnore' { + It 'Can be called with no parameters' { + { Get-GitHubGitignore } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw + } + } } Describe 'As a GitHub App' { From dc221d146d6d7b4da9cc88cac043a79cdf74e662 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 20:23:34 +0100 Subject: [PATCH 18/41] Add tests for GitHub App functionalities including JWT retrieval, app details, installations, and webhook configurations --- tests/GitHub.Tests.ps1 | 50 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 86366e2c4..3563802b7 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -557,18 +557,50 @@ Describe 'As a GitHub App' { AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount } - Context 'App' { - It 'Can get a JWT for the app' { - $jwt = Get-GitHubAppJSONWebToken -ClientId $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY - Write-Verbose ($jwt | Format-Table | Out-String) -Verbose - $jwt | Should -Not -BeNullOrEmpty + Context 'Apps' { + Context 'GitHub Apps' { + It 'Can get a JWT for the app' { + $jwt = Get-GitHubAppJSONWebToken -ClientId $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY + Write-Verbose ($jwt | Format-Table | Out-String) -Verbose + $jwt | Should -Not -BeNullOrEmpty + } + It 'Can get app details' { + $app = Get-GitHubApp + Write-Verbose ($app | Format-Table | Out-String) -Verbose + $app | Should -Not -BeNullOrEmpty + } + It 'Can get app installations' { + $installations = Get-GitHubAppInstallation + Write-Verbose ($installations | Format-Table | Out-String) -Verbose + $installations | Should -Not -BeNullOrEmpty + } + It 'Can get app installation access tokens' { + $installations = Get-GitHubAppInstallation + $installations | ForEach-Object { + $token = New-GitHubAppInstallationAccessToken -InstallationID $_.id + Write-Verbose ($token | Format-Table | Out-String) -Verbose + $token | Should -Not -BeNullOrEmpty + } + } } - It 'Can get app details' { - $app = Get-GitHubApp - Write-Verbose ($app | Format-Table | Out-String) -Verbose - $app | Should -Not -BeNullOrEmpty + Context 'Webhooks' { + It 'Can get the webhook configuration' { + $webhooks = Get-GitHubAppWebhookConfiguration + Write-Verbose ($webhooks | Format-Table | Out-String) -Verbose + $webhooks | Should -Not -BeNullOrEmpty + } + It 'Can update the webhook configuration' { + { Update-GitHubAppWebhookConfiguration -ContentType 'form' } | Should -Not -Throw + { Update-GitHubAppWebhookConfiguration -ContentType 'json' } | Should -Not -Throw + } + It 'Can get webhook deliveries' { + $deliveries = Get-GitHubAppWebhookDelivery + Write-Verbose ($deliveries | Format-Table | Out-String) -Verbose + $deliveries | Should -Not -BeNullOrEmpty + } } } + Context '' Context 'API' { It 'Can be called directly to get ratelimits' { { From d5e7ea6243bd1aafe8945346c6e5f32f9d46ad5a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 20:28:00 +0100 Subject: [PATCH 19/41] Add test for webhook redelivery functionality in GitHub App --- tests/GitHub.Tests.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 3563802b7..cb022ec71 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -598,9 +598,12 @@ Describe 'As a GitHub App' { Write-Verbose ($deliveries | Format-Table | Out-String) -Verbose $deliveries | Should -Not -BeNullOrEmpty } + It 'Can redeliver a webhook delivery' { + $deliveries = Get-GitHubAppWebhookDelivery | Select-Object -First 1 + { Invoke-GitHubAppWebhookReDelivery -ID $deliveries.id } | Should -Not -Throw + } } } - Context '' Context 'API' { It 'Can be called directly to get ratelimits' { { From 924b28e11534fd02579afd4cee43124f6e5e0007 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 20:45:37 +0100 Subject: [PATCH 20/41] Fix --- .../public/Actions/Disable-GitHubWorkflow.ps1 | 3 +- .../public/Actions/Enable-GitHubWorkflow.ps1 | 3 +- .../public/Actions/Get-GitHubWorkflow.ps1 | 3 +- .../public/Actions/Get-GitHubWorkflowRun.ps1 | 3 +- .../Actions/Get-GitHubWorkflowUsage.ps1 | 3 +- .../Actions/Remove-GitHubWorkflowRun.ps1 | 3 +- .../public/Actions/Start-GitHubWorkflow.ps1 | 3 +- .../Actions/Start-GitHubWorkflowReRun.ps1 | 3 +- .../public/Actions/Stop-GitHubWorkflowRun.ps1 | 3 +- .../public/Branches/Get-GitHubRepoBranch.ps1 | 3 +- ...itHubEnterpriseInstallableOrganization.ps1 | 3 +- .../Get-GitHubEnterpriseOrganization.ps1 | 3 +- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 3 +- .../public/Markdown/Get-GitHubMarkdown.ps1 | 2 +- tests/GitHub.Tests.ps1 | 33 +++++++++++++++++++ 15 files changed, 60 insertions(+), 14 deletions(-) diff --git a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 index 62baac086..c42f8e202 100644 --- a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 @@ -1,4 +1,5 @@ -filter Disable-GitHubWorkflow { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Disable-GitHubWorkflow { <# .NOTES [Disable a workflow](https://docs.github.com/en/rest/actions/workflows#disable-a-workflow) diff --git a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 index 45c72dfba..fd46bce76 100644 --- a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 @@ -1,4 +1,5 @@ -filter Enable-GitHubWorkflow { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Enable-GitHubWorkflow { <# .NOTES [Enable a workflow](https://docs.github.com/en/rest/actions/workflows#enable-a-workflow) diff --git a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Get-GitHubWorkflow.ps1 index fb86ae7b4..a6e2172a3 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Get-GitHubWorkflow.ps1 @@ -1,4 +1,5 @@ -filter Get-GitHubWorkflow { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Get-GitHubWorkflow { <# .SYNOPSIS Lists the workflows in a repository. diff --git a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 index ca87abfd7..5d8047175 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 @@ -1,4 +1,5 @@ -filter Get-GitHubWorkflowRun { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Get-GitHubWorkflowRun { <# .SYNOPSIS List workflow runs for a repository or a workflow diff --git a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 index 47fa47ad3..f63e196ce 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 +++ b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 @@ -1,4 +1,5 @@ -filter Get-GitHubWorkflowUsage { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Get-GitHubWorkflowUsage { <# .SYNOPSIS Short description diff --git a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 index 230f5094c..6777eaf03 100644 --- a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 @@ -1,4 +1,5 @@ -filter Remove-GitHubWorkflowRun { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Remove-GitHubWorkflowRun { <# .SYNOPSIS Delete a workflow run diff --git a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Start-GitHubWorkflow.ps1 index 67cae215c..2dd261791 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Start-GitHubWorkflow.ps1 @@ -1,4 +1,5 @@ -filter Start-GitHubWorkflow { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Start-GitHubWorkflow { <# .SYNOPSIS Start a workflow run using the workflow's ID. diff --git a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 index 183775e2e..e64cf9d62 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 +++ b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 @@ -1,4 +1,5 @@ -filter Start-GitHubWorkflowReRun { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Start-GitHubWorkflowReRun { <# .SYNOPSIS Re-run a workflow diff --git a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 index 57ee67c68..4ce58b55f 100644 --- a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 @@ -1,4 +1,5 @@ -filter Stop-GitHubWorkflowRun { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Stop-GitHubWorkflowRun { <# .SYNOPSIS Cancel a workflow run diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 index eea9e1b8e..623a0fd9f 100644 --- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 +++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 @@ -1,4 +1,5 @@ -filter Get-GitHubRepoBranch { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +filter Get-GitHubRepoBranch { <# .SYNOPSIS List branches diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 index 526e69389..505864abe 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 +++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 @@ -1,4 +1,5 @@ -function Get-GitHubEnterpriseInstallableOrganization { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +function Get-GitHubEnterpriseInstallableOrganization { <# .SYNOPSIS Get enterprise-owned organizations that can have GitHub Apps installed diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 index adbb0debb..ac83d2f7f 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 @@ -1,4 +1,5 @@ -function Get-GitHubEnterpriseOrganization { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +function Get-GitHubEnterpriseOrganization { <# .SYNOPSIS Get the list of organizations in a GitHub Enterprise instance. diff --git a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 index 3b6d6df52..8954183f2 100644 --- a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -1,4 +1,5 @@ -function Install-GitHubAppOnEnterpriseOrganization { +#SkipTest:FunctionTest:Will add a test for this function in a future PR +function Install-GitHubAppOnEnterpriseOrganization { <# .SYNOPSIS Install an app on an Enterprise-owned organization diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index bf7a64ddb..f1be7cd37 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -29,7 +29,7 @@ # The rendering mode. [Parameter()] [ValidateSet('markdown', 'gfm')] - [string] $Mode, + [string] $Mode = 'markdown', # The repository context to use when creating references in `gfm` mode. For example, setting `context` to `octo-org/octo-repo` will change the # text `#42` into an HTML link to issue 42 in the `octo-org/octo-repo` repository. diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index cb022ec71..57f442217 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -367,6 +367,17 @@ Describe 'As a user - Fine-grained PAT token' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } + Context 'Markdown' { + It 'Can be called with Text parameter' { + { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw + } + It 'Can be called with Text parameter and GitHub Format Mardown' { + { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw + } + It 'Raw - Can be called with Text parameter' { + { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw + } + } } Describe 'As a user - Classic PAT token' { @@ -452,6 +463,17 @@ Describe 'As a user - Classic PAT token' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } + Context 'Markdown' { + It 'Can be called with Text parameter' { + { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw + } + It 'Can be called with Text parameter and GitHub Format Mardown' { + { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw + } + It 'Raw - Can be called with Text parameter' { + { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw + } + } } Describe 'As GitHub Actions' { @@ -548,6 +570,17 @@ Describe 'As GitHub Actions' { { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw } } + Context 'Markdown' { + It 'Can be called with Text parameter' { + { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw + } + It 'Can be called with Text parameter and GitHub Format Mardown' { + { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw + } + It 'Raw - Can be called with Text parameter' { + { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw + } + } } Describe 'As a GitHub App' { From 37626da970bc8e1fc5ccd62c6b67ad70a7948304 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 20:56:09 +0100 Subject: [PATCH 21/41] Add skip test comments for workflow-related functions in preparation for future tests --- .../public/Actions/Disable-GitHubWorkflow.ps1 | 4 ++-- .../public/Actions/Enable-GitHubWorkflow.ps1 | 4 ++-- .../public/Actions/Get-GitHubWorkflow.ps1 | 4 ++-- .../public/Actions/Get-GitHubWorkflowRun.ps1 | 4 ++-- .../public/Actions/Get-GitHubWorkflowUsage.ps1 | 4 ++-- .../Actions/Remove-GitHubWorkflowRun.ps1 | 4 ++-- .../public/Actions/Start-GitHubWorkflow.ps1 | 4 ++-- .../Actions/Start-GitHubWorkflowReRun.ps1 | 4 ++-- .../public/Actions/Stop-GitHubWorkflowRun.ps1 | 4 ++-- .../public/Branches/Get-GitHubRepoBranch.ps1 | 4 ++-- ...GitHubEnterpriseInstallableOrganization.ps1 | 4 ++-- .../Get-GitHubEnterpriseOrganization.ps1 | 4 ++-- ...stall-GitHubAppOnEnterpriseOrganization.ps1 | 18 +++++++++--------- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 index c42f8e202..172263a5a 100644 --- a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 @@ -1,9 +1,9 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Disable-GitHubWorkflow { +filter Disable-GitHubWorkflow { <# .NOTES [Disable a workflow](https://docs.github.com/en/rest/actions/workflows#disable-a-workflow) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 index fd46bce76..511bb9a41 100644 --- a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 @@ -1,9 +1,9 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Enable-GitHubWorkflow { +filter Enable-GitHubWorkflow { <# .NOTES [Enable a workflow](https://docs.github.com/en/rest/actions/workflows#enable-a-workflow) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( [Parameter()] diff --git a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Get-GitHubWorkflow.ps1 index a6e2172a3..132daed5f 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Get-GitHubWorkflow.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Get-GitHubWorkflow { +filter Get-GitHubWorkflow { <# .SYNOPSIS Lists the workflows in a repository. @@ -22,6 +21,7 @@ filter Get-GitHubWorkflow { .NOTES [List repository workflows](https://docs.github.com/rest/actions/workflows?apiVersion=2022-11-28#list-repository-workflows) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(DefaultParameterSetName = 'ByName')] param( [Parameter()] diff --git a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 index 5d8047175..a43c41e0e 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Get-GitHubWorkflowRun { +filter Get-GitHubWorkflowRun { <# .SYNOPSIS List workflow runs for a repository or a workflow @@ -37,6 +36,7 @@ filter Get-GitHubWorkflowRun { [List workflow runs for a workflow](https://docs.github.com/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow) [List workflow runs for a repository](https://docs.github.com/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'Event', diff --git a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 index f63e196ce..584bec134 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 +++ b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Get-GitHubWorkflowUsage { +filter Get-GitHubWorkflowUsage { <# .SYNOPSIS Short description @@ -13,6 +12,7 @@ filter Get-GitHubWorkflowUsage { .NOTES [Get workflow usage](https://docs.github.com/en/rest/actions/workflows#get-workflow-usage) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding( DefaultParameterSetName = 'ByName' )] diff --git a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 index 6777eaf03..14b36045e 100644 --- a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Remove-GitHubWorkflowRun { +filter Remove-GitHubWorkflowRun { <# .SYNOPSIS Delete a workflow run @@ -17,6 +16,7 @@ filter Remove-GitHubWorkflowRun { .NOTES [Delete a workflow run](https://docs.github.com/rest/actions/workflow-runs#delete-a-workflow-run) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Start-GitHubWorkflow.ps1 index 2dd261791..6609c9c27 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Start-GitHubWorkflow.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Start-GitHubWorkflow { +filter Start-GitHubWorkflow { <# .SYNOPSIS Start a workflow run using the workflow's ID. @@ -18,6 +17,7 @@ filter Start-GitHubWorkflow { .NOTES [Create a workflow dispatch event](https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 index e64cf9d62..4871bfbe3 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 +++ b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Start-GitHubWorkflowReRun { +filter Start-GitHubWorkflowReRun { <# .SYNOPSIS Re-run a workflow @@ -13,6 +12,7 @@ filter Start-GitHubWorkflowReRun { .NOTES [Re-run a workflow](https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-workflow) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 index 4ce58b55f..ff3c6c0df 100644 --- a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Stop-GitHubWorkflowRun { +filter Stop-GitHubWorkflowRun { <# .SYNOPSIS Cancel a workflow run @@ -15,6 +14,7 @@ filter Stop-GitHubWorkflowRun { .NOTES [Cancel a workflow run](https://docs.github.com/en/rest/actions/workflow-runs#cancel-a-workflow-run) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [alias('Cancel-GitHubWorkflowRun')] param( diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 index 623a0fd9f..5a1a8b59a 100644 --- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 +++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -filter Get-GitHubRepoBranch { +filter Get-GitHubRepoBranch { <# .SYNOPSIS List branches @@ -15,6 +14,7 @@ filter Get-GitHubRepoBranch { .NOTES [List branches](https://docs.github.com/rest/branches/branches#list-branches) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 index 505864abe..d0fe0ffb5 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 +++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -function Get-GitHubEnterpriseInstallableOrganization { +function Get-GitHubEnterpriseInstallableOrganization { <# .SYNOPSIS Get enterprise-owned organizations that can have GitHub Apps installed @@ -13,6 +12,7 @@ function Get-GitHubEnterpriseInstallableOrganization { .EXAMPLE Get-GitHubEnterpriseInstallableOrganization -Enterprise 'msx' #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The enterprise slug or ID. diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 index ac83d2f7f..e932623f9 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 @@ -1,5 +1,4 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -function Get-GitHubEnterpriseOrganization { +function Get-GitHubEnterpriseOrganization { <# .SYNOPSIS Get the list of organizations in a GitHub Enterprise instance. @@ -10,6 +9,7 @@ function Get-GitHubEnterpriseOrganization { .EXAMPLE Get-GitHubEnterpriseOrganization -Enterprise 'msx' #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( [Parameter()] diff --git a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 index 8954183f2..3d04b23c5 100644 --- a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -1,17 +1,17 @@ -#SkipTest:FunctionTest:Will add a test for this function in a future PR -function Install-GitHubAppOnEnterpriseOrganization { +function Install-GitHubAppOnEnterpriseOrganization { <# - .SYNOPSIS - Install an app on an Enterprise-owned organization + .SYNOPSIS + Install an app on an Enterprise-owned organization - .DESCRIPTION - Installs the provided GitHub App on the specified organization owned by the enterprise. + .DESCRIPTION + Installs the provided GitHub App on the specified organization owned by the enterprise. - The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/organization_installations (write) permission. + The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/organization_installations (write) permission. - .EXAMPLE - Install-GitHubAppOnEnterpriseOrganization -Enterprise 'msx' -Organization 'org' -ClientID '123456' + .EXAMPLE + Install-GitHubAppOnEnterpriseOrganization -Enterprise 'msx' -Organization 'org' -ClientID '123456' #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The enterprise slug or ID. From ba659cbc1d3b0404066c6e20a28974340345b555 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 21:32:59 +0100 Subject: [PATCH 22/41] Add skip test comments for GitHub team and user functions in preparation for future tests --- src/functions/public/Teams/Get-GitHubTeam.ps1 | 1 + src/functions/public/Teams/New-GitHubTeam.ps1 | 1 + src/functions/public/Teams/Remove-GitHubTeam.ps1 | 1 + src/functions/public/Teams/Update-GitHubTeam.ps1 | 1 + src/functions/public/Users/Blocking/Block-GitHubUser.ps1 | 1 + src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 | 1 + src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 | 1 + src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 | 1 + src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 | 2 +- src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 | 2 +- src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 | 2 +- .../public/Users/Emails/Set-GitHubUserEmailVisibility.ps1 | 2 +- .../public/Users/Followers/Add-GitHubUserFollowing.ps1 | 2 +- src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 | 1 + .../public/Users/Followers/Get-GitHubUserFollowing.ps1 | 2 +- .../public/Users/Followers/Remove-GitHubUserFollowing.ps1 | 1 + .../public/Users/Followers/Test-GitHubUserFollowing.ps1 | 2 +- src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 | 2 +- src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 | 2 +- src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 | 2 +- src/functions/public/Users/Get-GitHubUser.ps1 | 1 + src/functions/public/Users/Get-GitHubUserCard.ps1 | 2 +- src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 | 2 +- src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 | 2 +- src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 | 2 +- .../public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 | 2 +- .../public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 | 2 +- .../Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 | 2 +- src/functions/public/Users/Set-GitHubUser.ps1 | 1 + .../public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 | 1 + .../public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 | 1 + 31 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/functions/public/Teams/Get-GitHubTeam.ps1 b/src/functions/public/Teams/Get-GitHubTeam.ps1 index 37b7347a8..55db7e43f 100644 --- a/src/functions/public/Teams/Get-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Get-GitHubTeam.ps1 @@ -18,6 +18,7 @@ Gets the team with the slug 'my-team-name' in the `github` organization. #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([GitHubTeam])] [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1 index 8ec457a84..87224bb86 100644 --- a/src/functions/public/Teams/New-GitHubTeam.ps1 +++ b/src/functions/public/Teams/New-GitHubTeam.ps1 @@ -27,6 +27,7 @@ .NOTES [Create a team](https://docs.github.com/rest/teams/teams#create-a-team) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([GitHubTeam])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1 index 389b1fd42..a9853ca8b 100644 --- a/src/functions/public/Teams/Remove-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1 @@ -13,6 +13,7 @@ .NOTES [Delete a team](https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([void])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1 index 7a43dcfc4..767c44d3a 100644 --- a/src/functions/public/Teams/Update-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Update-GitHubTeam.ps1 @@ -25,6 +25,7 @@ .NOTES [Update a team](https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([GitHubTeam])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 index 8a5eb8455..2bcd5186a 100644 --- a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 +++ b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 @@ -23,6 +23,7 @@ [Block a user](https://docs.github.com/rest/users/blocking#block-a-user) [Block a user from an organization](https://docs.github.com/rest/orgs/blocking#block-a-user-from-an-organization) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([bool])] [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( diff --git a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 index b375ab44b..8cc0dde2d 100644 --- a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 +++ b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 @@ -20,6 +20,7 @@ [List users blocked by the authenticated user](https://docs.github.com/rest/users/blocking#list-users-blocked-by-the-authenticated-user) [List users blocked by an organization](https://docs.github.com/rest/orgs/blocking#list-users-blocked-by-an-organization) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 index cf829991f..2e575f408 100644 --- a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 +++ b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 @@ -23,6 +23,7 @@ [Check if a user is blocked by the authenticated user](https://docs.github.com/rest/users/blocking#check-if-a-user-is-blocked-by-the-authenticated-user) [Check if a user is blocked by an organization](https://docs.github.com/rest/orgs/blocking#check-if-a-user-is-blocked-by-an-organization) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([bool])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding()] diff --git a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 index 38b54124b..563cd550f 100644 --- a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 +++ b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 @@ -22,6 +22,7 @@ [Unblock a user](https://docs.github.com/rest/users/blocking#unblock-a-user) [Unblock a user from an organization](https://docs.github.com/rest/orgs/blocking#unblock-a-user-from-an-organization) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([bool])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 index 04609a71f..35acd71b9 100644 --- a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 @@ -13,8 +13,8 @@ .NOTES [Add an email address for the authenticated user](https://docs.github.com/rest/users/emails#add-an-email-address-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 index fa10cebc1..29400d72b 100644 --- a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 @@ -21,8 +21,8 @@ .NOTES [List email addresses for the authenticated user](https://docs.github.com/rest/users/emails#list-email-addresses-for-the-authenticated-user) [List public email addresses for the authenticated user](https://docs.github.com/en/rest/users/emails#list-public-email-addresses-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding()] diff --git a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 index c08841752..66afec31a 100644 --- a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 @@ -13,8 +13,8 @@ .NOTES [Delete an email address for the authenticated user](https://docs.github.com/rest/users/emails#delete-an-email-address-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1 b/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1 index 24a61cc41..1ed7a68be 100644 --- a/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1 +++ b/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1 @@ -18,8 +18,8 @@ .NOTES [Set primary email visibility for the authenticated user](https://docs.github.com/rest/users/emails#set-primary-email-visibility-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 index af172ed27..f1bb06f04 100644 --- a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 @@ -15,8 +15,8 @@ .NOTES [Follow a user](https://docs.github.com/rest/users/followers#follow-a-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Alias('Follow-GitHubUser')] [CmdletBinding()] diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 index eb2be94b5..c4329e9cf 100644 --- a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 +++ b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 @@ -19,6 +19,7 @@ .NOTES [List followers of the authenticated user](https://docs.github.com/rest/users/followers#list-followers-of-the-authenticated-user) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Alias('Get-GitHubUserMyFollowers')] [CmdletBinding()] diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 index ba26966f4..4e0983bfd 100644 --- a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 @@ -19,8 +19,8 @@ .NOTES [List the people the authenticated user follows](https://docs.github.com/rest/users/followers#list-the-people-the-authenticated-user-follows) [List the people a user follows](https://docs.github.com/rest/users/followers#list-the-people-a-user-follows) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 index da2bd615d..2cc6ad31f 100644 --- a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 @@ -14,6 +14,7 @@ .NOTES [Unfollow a user](https://docs.github.com/rest/users/followers#unfollow-a-user) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Alias('Unfollow-GitHubUser')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 index 062ada39a..1490de496 100644 --- a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 @@ -21,8 +21,8 @@ .NOTES [Check if a person is followed by the authenticated user](https://docs.github.com/rest/users/followers#check-if-a-person-is-followed-by-the-authenticated-user) [Check if a user follows another user](https://docs.github.com/rest/users/followers#check-if-a-user-follows-another-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([bool])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [Alias('Test-GitHubUserFollows')] diff --git a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 index a24cb9b5b..6fc6413fb 100644 --- a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 @@ -21,8 +21,8 @@ .NOTES [Create a GPG key for the authenticated user](https://docs.github.com/rest/users/gpg-keys#create-a-gpg-key-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 index 415e77140..ab08fa5d8 100644 --- a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 @@ -23,8 +23,8 @@ .NOTES [List GPG keys for the authenticated user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 index 1f6e7d517..423d92499 100644 --- a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 @@ -15,8 +15,8 @@ .NOTES [Delete a GPG key for the authenticated user](https://docs.github.com/rest/users/gpg-keys#delete-a-gpg-key-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Users/Get-GitHubUser.ps1 b/src/functions/public/Users/Get-GitHubUser.ps1 index e72406f47..89de4f409 100644 --- a/src/functions/public/Users/Get-GitHubUser.ps1 +++ b/src/functions/public/Users/Get-GitHubUser.ps1 @@ -26,6 +26,7 @@ .NOTES [Get the authenticated user](https://docs.github.com/rest/users/users) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSReviewUnusedParameter', diff --git a/src/functions/public/Users/Get-GitHubUserCard.ps1 b/src/functions/public/Users/Get-GitHubUserCard.ps1 index 79ae51fba..b921fd79f 100644 --- a/src/functions/public/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/public/Users/Get-GitHubUserCard.ps1 @@ -20,8 +20,8 @@ .NOTES [Get contextual information for a user](https://docs.github.com/rest/users/users#get-contextual-information-for-a-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 index dcd9b37f7..51336edb2 100644 --- a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 @@ -15,8 +15,8 @@ .NOTES [Create a public SSH key for the authenticated user](https://docs.github.com/rest/users/keys#create-a-public-ssh-key-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')] [CmdletBinding()] diff --git a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 index 04dd5f428..2f7bac5d5 100644 --- a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 @@ -26,8 +26,8 @@ .NOTES [List GPG keys for the authenticated user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 index 6870fcfea..61935b5ee 100644 --- a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 @@ -15,8 +15,8 @@ .NOTES [Delete a public SSH key for the authenticated user](https://docs.github.com/rest/users/keys#delete-a-public-ssh-key-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 index 13815ab36..12ca47c21 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 @@ -16,8 +16,8 @@ .NOTES [Create a SSH signing key for the authenticated user](https://docs.github.com/rest/users/ssh-signing-keys#create-a-ssh-signing-key-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')] [OutputType([pscustomobject])] [CmdletBinding()] diff --git a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 index cc1fd2559..03d26ccbc 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 @@ -25,8 +25,8 @@ [List SSH signing keys for the authenticated user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-the-authenticated-user) [Get an SSH signing key for the authenticated user](https://docs.github.com/rest/users/ssh-signing-keys#get-an-ssh-signing-key-for-the-authenticated-user) [List SSH signing keys for a user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-a-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding()] diff --git a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 index af4aab7bc..e2c78a16b 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 @@ -16,8 +16,8 @@ .NOTES [Delete an SSH signing key for the authenticated user](https://docs.github.com/rest/users/ssh-signing-keys#delete-an-ssh-signing-key-for-the-authenticated-user) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Users/Set-GitHubUser.ps1 b/src/functions/public/Users/Set-GitHubUser.ps1 index b7c23432e..e12e21700 100644 --- a/src/functions/public/Users/Set-GitHubUser.ps1 +++ b/src/functions/public/Users/Set-GitHubUser.ps1 @@ -26,6 +26,7 @@ .NOTES [Update the authenticated user](https://docs.github.com/rest/users/users#update-the-authenticated-user) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([void])] [Alias('Update-GitHubUser')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 index ebafaa786..14ae17f05 100644 --- a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 @@ -14,6 +14,7 @@ .NOTES [Add social accounts for the authenticated user](https://docs.github.com/rest/users/social-accounts#add-social-accounts-for-the-authenticated-user) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([void])] [Alias('Add-GitHubUserSocials')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')] diff --git a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 index 48bea6493..c142b84ce 100644 --- a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 @@ -15,6 +15,7 @@ .NOTES [Delete social accounts for the authenticated user](https://docs.github.com/rest/users/social-accounts#delete-social-accounts-for-the-authenticated-user) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([void])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [Alias('Remove-GitHubUserSocials')] From 888a82e52a55f933b10fc92df0f7a5bdf8ad0422 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 21:39:38 +0100 Subject: [PATCH 23/41] Add skip test comments for various GitHub functions in preparation for future tests --- src/functions/public/Organization/Get-GitHubOrganization.ps1 | 1 + .../Organization/Get-GitHubOrganizationAppInstallation.ps1 | 2 +- .../Organization/Members/Get-GitHubOrganizationMember.ps1 | 1 + .../Members/Get-GitHubOrganizationPendingInvitation.ps1 | 1 + .../Organization/Members/New-GitHubOrganizationInvitation.ps1 | 1 + .../public/Organization/Remove-GitHubOrganization.ps1 | 1 + src/functions/public/Organization/Set-GitHubOrganization.ps1 | 2 +- .../Organization/Set-GitHubOrganizationSecurityFeature.ps1 | 1 + .../public/Releases/Assets/Add-GitHubReleaseAsset.ps1 | 2 +- .../public/Releases/Assets/Get-GitHubReleaseAsset.ps1 | 2 +- .../public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 | 2 +- .../public/Releases/Assets/Set-GitHubReleaseAsset.ps1 | 1 + src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 | 2 +- src/functions/public/Releases/Releases/New-GitHubRelease.ps1 | 2 +- .../public/Releases/Releases/New-GitHubReleaseNote.ps1 | 2 +- .../public/Releases/Releases/Remove-GitHubRelease.ps1 | 2 +- src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 | 1 + .../Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 | 2 +- .../Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 | 2 +- .../Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 | 2 +- .../CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 | 2 +- .../Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 | 2 +- .../Repositories/Disable-GitHubRepositorySecurityFix.ps1 | 2 +- .../Disable-GitHubRepositoryVulnerabilityAlert.ps1 | 1 + .../Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 | 2 +- .../Repositories/Enable-GitHubRepositorySecurityFix.ps1 | 2 +- .../Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 | 1 + .../public/Repositories/Repositories/Get-GitHubRepository.ps1 | 1 + .../Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryCodeownersError.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryContributor.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryFork.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 | 2 +- .../Repositories/Get-GitHubRepositorySecurityFix.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTag.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 | 2 +- .../public/Repositories/Repositories/Move-GitHubRepository.ps1 | 2 +- .../public/Repositories/Repositories/New-GitHubRepository.ps1 | 3 +-- .../Repositories/Repositories/Remove-GitHubRepository.ps1 | 1 + .../Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 | 1 + .../Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 | 2 +- .../Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 | 1 + .../Repositories/Repositories/Update-GitHubRepository.ps1 | 1 + .../Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 | 1 + .../RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 | 1 + .../RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 | 2 +- .../Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 | 2 +- .../Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 | 1 + .../Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 | 2 +- 50 files changed, 50 insertions(+), 33 deletions(-) diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index 962f71944..76e148135 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -32,6 +32,7 @@ .NOTES [List organizations](https://docs.github.com/rest/orgs/orgs) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(DefaultParameterSetName = '__DefaultSet')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'All', Justification = 'Required for parameter set')] diff --git a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 index 6df2ab513..c0330a4cc 100644 --- a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 @@ -14,8 +14,8 @@ .NOTES [List app installations for an organization](https://docs.github.com/rest/orgs/orgs#list-app-installations-for-an-organization) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 index 05f0f1c51..9bf72a61f 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 @@ -10,6 +10,7 @@ .NOTES [List organization members](https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#list-organization-members) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 index a9c4f8ac6..c735b96ff 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 @@ -12,6 +12,7 @@ .NOTES [List pending organization invitations](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The organization name. The name is not case sensitive. diff --git a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 index 810fceef3..d211b55cf 100644 --- a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 @@ -15,6 +15,7 @@ .NOTES [Create an organization invitation](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The organization name. The name is not case sensitive. diff --git a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 index 55bc153ce..7b8822e47 100644 --- a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 @@ -17,6 +17,7 @@ .NOTES [Delete an organization](https://docs.github.com/rest/orgs/orgs#delete-an-organization) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Organization/Set-GitHubOrganization.ps1 b/src/functions/public/Organization/Set-GitHubOrganization.ps1 index 8849558bc..a270b7f7a 100644 --- a/src/functions/public/Organization/Set-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Set-GitHubOrganization.ps1 @@ -32,8 +32,8 @@ .NOTES [Update an organization](https://docs.github.com/rest/orgs/orgs#update-an-organization) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( diff --git a/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1 b/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1 index b87d0d206..0f3dac84a 100644 --- a/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1 +++ b/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1 @@ -21,6 +21,7 @@ .NOTES [Enable or disable a security feature for an organization](https://docs.github.com/rest/orgs/orgs#enable-or-disable-a-security-feature-for-an-organization) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long link in notes.')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 index 8e0e02e78..69a082f4d 100644 --- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 @@ -43,8 +43,8 @@ .NOTES [Upload a release asset](https://docs.github.com/rest/releases/assets#upload-a-release-asset) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 index d98588aa8..523f62709 100644 --- a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 @@ -19,8 +19,8 @@ .NOTES [Get a release asset](https://docs.github.com/rest/releases/assets#get-a-release-asset) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 index c0b93b9e8..445eb4a1c 100644 --- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 @@ -13,8 +13,8 @@ .NOTES [Delete a release asset](https://docs.github.com/rest/releases/assets#delete-a-release-asset) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 index 5c5e4a320..4d3848739 100644 --- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 @@ -15,6 +15,7 @@ .NOTES [Update a release asset](https://docs.github.com/rest/releases/assets#update-a-release-asset) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 index e6c77e679..18aad97c9 100644 --- a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 @@ -31,8 +31,8 @@ .NOTES [List releases](https://docs.github.com/rest/releases/releases#list-releases) [Get the latest release](https://docs.github.com/rest/releases/releases#get-the-latest-release) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(DefaultParameterSetName = 'All')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'Latest', Justification = 'Required for parameter set')] param( diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 index b24e8dd19..2d6f47237 100644 --- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 @@ -17,8 +17,8 @@ .NOTES [Create a release](https://docs.github.com/rest/releases/releases#create-a-release) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 index 7404cd08e..0e03302f0 100644 --- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 @@ -50,8 +50,8 @@ .NOTES [Generate release notes content for a release](https://docs.github.com/rest/releases/releases#list-releases) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Alias('Generate-GitHubReleaseNotes')] [Alias('New-GitHubReleaseNotes')] diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 index 4f3f739ed..657acd8eb 100644 --- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 @@ -13,8 +13,8 @@ .NOTES [Delete a release](https://docs.github.com/rest/releases/releases#delete-a-release) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 index 9b48fe068..9e0919029 100644 --- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 @@ -14,6 +14,7 @@ .NOTES [Update a release](https://docs.github.com/rest/releases/releases#update-a-release) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [CmdletBinding(SupportsShouldProcess)] diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 index 0763bccd0..8e118a3c4 100644 --- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 @@ -20,8 +20,8 @@ .NOTES [Get all autolinks of a repository](https://docs.github.com/rest/repos/autolinks#list-all-autolinks-of-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [Alias('Get-GitHubRepositoryAutolinks')] [CmdletBinding(DefaultParameterSetName = 'Default')] param( diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 index b8c40b9bc..56775f5f2 100644 --- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 @@ -14,8 +14,8 @@ .NOTES [Create an autolink reference for a repository](https://docs.github.com/rest/repos/autolinks#create-an-autolink-reference-for-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 index ff169a8b2..fe37297d4 100644 --- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 @@ -15,8 +15,8 @@ .NOTES [Delete an autolink reference from a repository](https://docs.github.com/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 index 3d9310041..6963276c9 100644 --- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 +++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 @@ -14,8 +14,8 @@ .NOTES [Get all custom property values for a repository](https://docs.github.com/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [Alias('Get-GitHubRepositoryCustomProperties')] [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index a071b3bc8..f343aeb2e 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -15,8 +15,8 @@ .NOTES [Disable private vulnerability reporting for a repository](https://docs.github.com/rest/repos/repos#disable-private-vulnerability-reporting-for-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 index 7cf6462f0..d24ce09e5 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 @@ -15,8 +15,8 @@ .NOTES [Disable automated security fixes](https://docs.github.com/rest/repos/repos#disable-automated-security-fixes) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [Alias('Disable-GitHubRepositorySecurityFixes')] param( diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 index 5064f3c88..48cb2e2d5 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -16,6 +16,7 @@ .NOTES [Disable vulnerability alerts](https://docs.github.com/rest/repos/repos#disable-vulnerability-alerts) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [Alias('Disable-GitHubRepositoryVulnerabilityAlerts')] param( diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index b5b8da905..1054d704d 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -15,8 +15,8 @@ .NOTES [Enable private vulnerability reporting for a repository](https://docs.github.com/rest/repos/repos#enable-private-vulnerability-reporting-for-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 index 9d19d7e56..1803fafa0 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 @@ -15,8 +15,8 @@ .NOTES [Enable automated security fixes](https://docs.github.com/rest/repos/repos#enable-automated-security-fixes) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [Alias('Enable-GitHubRepositorySecurityFixes')] param( diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 index eb5f09edc..0d82bd718 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -17,6 +17,7 @@ .NOTES [Enable vulnerability alerts](https://docs.github.com/rest/repos/repos#enable-vulnerability-alerts) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [Alias('Enable-GitHubRepositoryVulnerabilityAlerts')] param( diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 index a9244278d..05d156de3 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 @@ -48,6 +48,7 @@ filter Get-GitHubRepository { [List organization repositories](https://docs.github.com/rest/repos/repos#list-organization-repositories) [List repositories for a user](https://docs.github.com/rest/repos/repos#list-repositories-for-a-user) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(DefaultParameterSetName = 'MyRepos_Type')] param( #Limit results to repositories with the specified visibility. diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index 4c4bea32f..793aaf449 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -47,8 +47,8 @@ .NOTES [List repository activities](https://docs.github.com/rest/repos/repos#list-repository-activities) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 index 32c70da1d..6c341ee00 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 @@ -16,8 +16,8 @@ .NOTES [List CODEOWNERS errors](https://docs.github.com/rest/repos/repos#list-codeowners-errors) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] param( diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 index ce84b00ca..57566b925 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 @@ -18,8 +18,8 @@ .NOTES [List repository contributors](https://docs.github.com/rest/repos/repos#list-repository-contributors) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 index d2bf79142..cd5bff02e 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 @@ -13,8 +13,8 @@ .NOTES [List forks](https://docs.github.com/rest/repos/forks#list-forks) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 index 82a6c7fae..94cd52eac 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 @@ -14,8 +14,8 @@ .NOTES [List repository languages](https://docs.github.com/rest/repos/repos#list-repository-languages) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] [Alias('Get-GitHubRepositoryLanguages')] param( diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 index ae1b1c0fa..90c4b169c 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 @@ -15,8 +15,8 @@ .NOTES [Check if automated security fixes are enabled for a repository](https://docs.github.com/rest/repos/repos#check-if-automated-security-fixes-are-enabled-for-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [Alias('Get-GitHubRepoSecurityFixes')] [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 index bf10c8c02..3645515f8 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 @@ -13,8 +13,8 @@ .NOTES [List repository tags](https://docs.github.com/rest/repos/repos#list-repository-tags) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] [Alias('Get-GitHubRepositoryTags')] param( diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 index 4e13bcced..56c3df720 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 @@ -21,8 +21,8 @@ .NOTES [List repository teams](https://docs.github.com/rest/repos/repos#list-repository-teams) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] [Alias('Get-GitHubRepositoryTeams')] param( diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 index ee17bf3be..75c001cfe 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 @@ -10,8 +10,8 @@ .NOTES [Get all repository topics](https://docs.github.com/rest/repos/repos#get-all-repository-topics) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 index a50313744..63e50560d 100644 --- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 @@ -18,8 +18,8 @@ .NOTES [Transfer a repository](https://docs.github.com/rest/repos/repos#transfer-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 index 22321f992..89b42fc16 100644 --- a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 @@ -15,7 +15,6 @@ filter New-GitHubRepository { * `public_repo` scope or `repo` scope to create a public repository. Note: For GitHub AE, use `repo` scope to create an internal repository. * `repo` scope to create a private repository - .EXAMPLE $params = @{ Name = 'Hello-World' @@ -101,8 +100,8 @@ filter New-GitHubRepository { .NOTES [Create a repository for the authenticated user](https://docs.github.com/rest/repos/repos#create-a-repository-for-the-authenticated-user) [Create an organization repository](https://docs.github.com/rest/repos/repos#create-an-organization-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding( SupportsShouldProcess, diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 index c04cf4f96..54a61b0f4 100644 --- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 @@ -17,6 +17,7 @@ .NOTES [Delete a repository](https://docs.github.com/rest/repos/repos#delete-a-repository) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR #TODO: Set high impact [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 index ef4b0a14f..ebaa8d9da 100644 --- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 @@ -14,6 +14,7 @@ .NOTES [Replace all repository topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 index e16d39a1e..664952834 100644 --- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 +++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 @@ -38,8 +38,8 @@ .NOTES [Create a repository dispatch event](https://docs.github.com/rest/repos/repos#create-a-repository-dispatch-event) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 index 9a2af0ec3..49ac153c5 100644 --- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 @@ -17,6 +17,7 @@ .NOTES [Check if vulnerability alerts are enabled for a repository](https://docs.github.com/rest/repos/repos#list-repository-tags) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([bool])] [CmdletBinding()] [Alias('Test-GitHubRepositoryVulnerabilityAlerts')] diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 index e50193f98..99af0b21b 100644 --- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 @@ -23,6 +23,7 @@ .NOTES [Update a repository](https://docs.github.com/rest/repos/repos#update-a-repository) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 index 5964f3248..306739612 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 @@ -30,6 +30,7 @@ [List repository rule suites](https://docs.github.com/rest/repos/rule-suites#list-repository-rule-suites) [Get a repository rule suite](https://docs.github.com/rest/repos/rule-suites#get-a-repository-rule-suite) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] [CmdletBinding(DefaultParameterSetName = 'Default')] diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 index 548c94efb..ff1c4f3a3 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 @@ -15,6 +15,7 @@ .NOTES [Get a repository rule suite](https://docs.github.com/rest/repos/rule-suites#get-a-repository-rule-suite) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] [CmdletBinding()] diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 index 29c6cf3a0..2afb189cf 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 @@ -22,8 +22,8 @@ .NOTES [List repository rule suites](https://docs.github.com/rest/repos/rule-suites#list-repository-rule-suites) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] [CmdletBinding()] diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 index 29c5ef886..f5ce24ba3 100644 --- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 @@ -15,8 +15,8 @@ .NOTES [List tag protection states for a repository](https://docs.github.com/rest/repos/tags#list-tag-protection-states-for-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 index ab3a1fcef..5c144678c 100644 --- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 @@ -15,6 +15,7 @@ .NOTES [Create a tag protection state for a repository](https://docs.github.com/rest/repos/tags#create-a-tag-protection-state-for-a-repository) #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] param( diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 index 94bb00ec5..3b59df9c3 100644 --- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 @@ -14,8 +14,8 @@ .NOTES [Delete a tag protection state for a repository](https://docs.github.com/rest/repos/tags#delete-a-tag-protection-state-for-a-repository) - #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR [OutputType([pscustomobject])] [CmdletBinding(SupportsShouldProcess)] param( From 883483e581159cf483a9b09040de1e10e21a3577 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 22:12:14 +0100 Subject: [PATCH 24/41] Refactor GitHub configuration handling to strip protocol from HostName and add tests for configuration retrieval --- src/variables/private/Config.ps1 | 2 +- tests/GitHub.Tests.ps1 | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/variables/private/Config.ps1 b/src/variables/private/Config.ps1 index f3d00b1d6..687048693 100644 --- a/src/variables/private/Config.ps1 +++ b/src/variables/private/Config.ps1 @@ -9,7 +9,7 @@ } DefaultConfig = [GitHubConfig]@{ ID = 'PSModule.GitHub' - HostName = $env:GITHUB_SERVER_URL ?? 'github.com' + HostName = ($env:GITHUB_SERVER_URL ?? 'github.com') -replace '^https?://' AccessTokenGracePeriodInHours = 4 GitHubAppClientID = 'Iv1.f26b61bc99e69405' OAuthAppClientID = '7204ae9b0580f2cb8288' diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 57f442217..87be1cae2 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -17,13 +17,18 @@ Describe 'GitHub' { Write-Verbose ($config | Format-Table | Out-String) -Verbose $config | Should -Not -BeNullOrEmpty } + It 'Get-GitHubConfig - Can get the configuration by name' { + $config = Get-GitHubConfig -Name 'HostName' + Write-Verbose ($config | Format-Table | Out-String) -Verbose + $config | Should -Not -BeNullOrEmpty + } It 'Set-GitHubConfig - Can set the configuration' { - Set-GitHubConfig -Name 'MyName' -Value 'MyValue' - Get-GitHubConfig -Name 'MyName' | Should -Be 'MyValue' + Set-GitHubConfig -Name 'HostName' -Value 'msx.ghe.com' + Get-GitHubConfig -Name 'HostName' | Should -Be 'msx.ghe.com' } It 'Remove-GetGitHubConfig - Can remove the configuration' { - Remove-GitHubConfig -Name 'MyName' - { Get-GitHubConfig -Name 'MyName' } | Should -BeNullOrEmpty + Remove-GitHubConfig -Name 'HostName' + { Get-GitHubConfig -Name 'HostName' } | Should -BeNullOrEmpty } It 'Reset-GitHubConfig - Can reset the configuration' { Set-GitHubConfig -Name HostName -Value 'msx.ghe.com' From daf26398addd1490e002f0a87b245157e92100b1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 21 Dec 2024 22:38:32 +0100 Subject: [PATCH 25/41] Fix --- tests/GitHub.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 87be1cae2..95a9ba12c 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -28,7 +28,7 @@ Describe 'GitHub' { } It 'Remove-GetGitHubConfig - Can remove the configuration' { Remove-GitHubConfig -Name 'HostName' - { Get-GitHubConfig -Name 'HostName' } | Should -BeNullOrEmpty + Get-GitHubConfig -Name 'HostName' | Should -BeNullOrEmpty } It 'Reset-GitHubConfig - Can reset the configuration' { Set-GitHubConfig -Name HostName -Value 'msx.ghe.com' From b097eb6e6f8376c1ab9c47340c908b4682735e75 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 09:26:17 +0100 Subject: [PATCH 26/41] Enhance Get-GitHubRepositoryLicense function to support content type parameter and update tests for environment variable checks --- .../License/Get-GitHubRepositoryLicense.ps1 | 14 ++++++++++++-- tests/GitHub.Tests.ps1 | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index e4e60901f..e3c066468 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -15,7 +15,7 @@ Get the license for the Hello-World repository from the octocat account. .NOTES - https://docs.github.com/rest/licenses/licenses#get-the-license-for-a-repository + [Get the license for a repository](https://docs.github.com/rest/licenses/licenses#get-the-license-for-a-repository) #> [CmdletBinding()] @@ -28,6 +28,11 @@ [Parameter()] [string] $Repo, + # The type of data to return. Can be either 'raw' or 'html'. + [Parameter()] + [ValidateSet('raw', 'html')] + [string] $Type = 'raw', + # The context to run the command in. Used to get the details for the API call. # Can be either a string or a GitHubContext object. [Parameter()] @@ -49,6 +54,11 @@ $Repo = $Context.Repo } Write-Debug "Repo: [$Repo]" + + $contentType = switch ($Type) { + 'raw' { 'application/vnd.github.raw+json' } + 'html' { 'application/vnd.github.html+json' } + } } process { @@ -56,7 +66,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/license" - Accept = 'application/vnd.github+json' + ContentType = $contentType Method = 'GET' } diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 95a9ba12c..3895c5b1f 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -209,7 +209,7 @@ Describe 'GitHub' { { Add-GitHubSystemPath -Path $pwd.ToString() } | Should -Not -Throw - $env:Path | Should -Contain $pwd.ToString() + Get-Content $env:GITHUB_PATH -Raw | Should -Belike "*$($pwd.ToString())*" } It 'Disable-GitHubCommand should not throw' { { @@ -242,7 +242,7 @@ Describe 'GitHub' { { Set-GitHubEnvironmentVariable -Name 'MyName' -Value 'MyValue' } | Should -Not -Throw - $env:MyName | Should -Be 'MyValue' + Get-Content $env:GITHUB_ENV -Raw | Should -BeLike "*MyName=MyValue*" } It 'Set-GitHubStepSummary should not throw' { { From e7a0dd2d9f808f064c3dc0679f1d80a3b268d690 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 09:59:34 +0100 Subject: [PATCH 27/41] Enhance Get-GitHubLicense function to include Name parameter and improve argument completion; update tests for environment variable validation --- .../public/License/Get-GitHubLicense.ps1 | 30 ++++++++----------- tests/GitHub.Tests.ps1 | 2 +- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/functions/public/License/Get-GitHubLicense.ps1 b/src/functions/public/License/Get-GitHubLicense.ps1 index 230734a85..7f5953a61 100644 --- a/src/functions/public/License/Get-GitHubLicense.ps1 +++ b/src/functions/public/License/Get-GitHubLicense.ps1 @@ -43,28 +43,16 @@ filter Get-GitHubLicense { [Parameter(ParameterSetName = 'Repository')] [string] $Repo, + # The license keyword, license name, or license SPDX ID. For example, mit or mpl-2.0. + [Parameter(ParameterSetName = 'Name')] + [string] $Name, + # The context to run the command in. Used to get the details for the API call. # Can be either a string or a GitHubContext object. [Parameter()] [object] $Context = (Get-GitHubContext) ) - dynamicparam { - $DynamicParamDictionary = New-DynamicParamDictionary - - $dynParam = @{ - Name = 'Name' - ParameterSetName = 'Name' - Type = [string] - Mandatory = $true - ValidateSet = Get-GitHubLicenseList | Select-Object -ExpandProperty Name - DynamicParamDictionary = $DynamicParamDictionary - } - New-DynamicParam @dynParam - - return $DynamicParamDictionary - } - begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" @@ -83,7 +71,6 @@ filter Get-GitHubLicense { process { try { - $Name = $PSBoundParameters['Name'] switch ($PSCmdlet.ParameterSetName) { 'List' { Get-GitHubLicenseList -Context $Context @@ -104,3 +91,12 @@ filter Get-GitHubLicense { Write-Debug "[$stackPath] - End" } } + +Register-ArgumentCompleter -CommandName Get-GitHubLicense -ParameterName Name -ScriptBlock { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) + $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter + $names = Get-GitHubLicenseList | Select-Object -ExpandProperty Name | Where-Object { $_ -like "$wordToComplete*" } + $names | ForEach-Object { + [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + } +} diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 3895c5b1f..9894839eb 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -242,7 +242,7 @@ Describe 'GitHub' { { Set-GitHubEnvironmentVariable -Name 'MyName' -Value 'MyValue' } | Should -Not -Throw - Get-Content $env:GITHUB_ENV -Raw | Should -BeLike "*MyName=MyValue*" + Get-Content $env:GITHUB_ENV -Raw | Should -BeLike "*MyName*MyValue*" } It 'Set-GitHubStepSummary should not throw' { { From 1acef29212304a94809f126cee29b44c7a7d11a9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 10:27:32 +0100 Subject: [PATCH 28/41] Enhance Get-GitHubLicenseList function to clarify Context parameter description and change type to object for improved flexibility --- src/functions/private/License/Get-GitHubLicenseList.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index 42506ae1b..718f95b42 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -20,9 +20,10 @@ [OutputType([string[]])] [CmdletBinding()] param( - # The context to run the command in. + # The context to run the command in. Used to get the details for the API call. + # Can be either a string or a GitHubContext object. [Parameter()] - [string] $Context + [object] $Context = (Get-GitHubContext) ) begin { From f14c0cbc4c6a60c31351f0da297ddefcd77e14d6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 11:07:37 +0100 Subject: [PATCH 29/41] Enhance Process-PSModule workflow to enable Debug and Verbose options for improved logging --- .github/workflows/Process-PSModule.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 447c6bf6d..15b82da17 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -34,3 +34,6 @@ jobs: Process-PSModule: uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v3 secrets: inherit + with: + Debug: true + Verbose: true From 998783f7a971fafc38d9c639639f1b7000896924 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 11:37:57 +0100 Subject: [PATCH 30/41] Enhance Invoke-GitHubAPI function to improve error handling and logging with detailed response headers --- src/functions/public/API/Invoke-GitHubAPI.ps1 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index af1dd5cc1..d567471fd 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -227,6 +227,9 @@ $headers = [pscustomobject]$headers $sortedProperties = $headers.PSObject.Properties.Name | Sort-Object $headers = $headers | Select-Object $sortedProperties + Write-Debug 'Response headers:' + $headers | Out-String -Stream | ForEach-Object { Write-Debug $_ } + Write-Debug '---------------------------' $errordetails = $failure.ErrorDetails | ConvertFrom-Json -AsHashtable $errorResult = [ordered]@{ @@ -239,13 +242,13 @@ $APICall.Headers = $APICall.Headers | ConvertTo-Json $APICall.Method = $APICall.Method.ToString() - Write-Error '----------------------------------' - Write-Error 'Error details:' - $errorResult | Format-Table -AutoSize -HideTableHeaders | Out-String -Stream | ForEach-Object { Write-Error $_ } - Write-Error '----------------------------------' - Write-Debug 'Response headers:' - $headers | Out-String -Stream | ForEach-Object { Write-Debug $_ } - Write-Debug '---------------------------' + $errorResult = @" +---------------------------------- +Error details: +$($errorResult | Format-Table -AutoSize -HideTableHeaders | Out-String) +---------------------------------- +"@ + Write-Error $errorResult throw $failure.Exception.Message } } From 01e9b8f55fce143d1de0ecbc91983275d44ba40d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 17:23:00 +0100 Subject: [PATCH 31/41] Enhance GitHub workflows to include additional secrets for improved security and access management --- .github/workflows/Nightly-Run.yml | 15 ++++++++------- .github/workflows/Process-PSModule.yml | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/Nightly-Run.yml b/.github/workflows/Nightly-Run.yml index 4469a9064..c2260da4d 100644 --- a/.github/workflows/Nightly-Run.yml +++ b/.github/workflows/Nightly-Run.yml @@ -10,13 +10,14 @@ permissions: pull-requests: write statuses: write -env: - TEST_APP_CLIENT_ID: ${{ secrets.TEST_APP_CLIENT_ID }} - TEST_APP_PRIVATE_KEY: ${{ secrets.TEST_APP_PRIVATE_KEY }} - TEST_FG_PAT: ${{ secrets.TEST_FG_PAT }} - TEST_PAT: ${{ secrets.TEST_PAT }} - jobs: Process-PSModule: uses: PSModule/Process-PSModule/.github/workflows/CI.yml@v3 - secrets: inherit + secrets: + TEST_APP_ENT_CLIENT_ID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} + TEST_APP_ENT_PRIVATE_KEY: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} + TEST_APP_ORG_CLIENT_ID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} + TEST_APP_ORG_PRIVATE_KEY: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} + TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} + TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} + TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 15b82da17..cb62d2745 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -24,16 +24,17 @@ permissions: pages: write id-token: write -env: - TEST_APP_CLIENT_ID: ${{ secrets.TEST_APP_CLIENT_ID }} - TEST_APP_PRIVATE_KEY: ${{ secrets.TEST_APP_PRIVATE_KEY }} - TEST_FG_PAT: ${{ secrets.TEST_FG_PAT }} - TEST_PAT: ${{ secrets.TEST_PAT }} - jobs: Process-PSModule: uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v3 - secrets: inherit + secrets: + TEST_APP_ENT_CLIENT_ID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} + TEST_APP_ENT_PRIVATE_KEY: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} + TEST_APP_ORG_CLIENT_ID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} + TEST_APP_ORG_PRIVATE_KEY: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} + TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} + TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} + TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} with: Debug: true Verbose: true From 18b733b8bde998a92033f32374f8f66adea30d4c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 17:35:54 +0100 Subject: [PATCH 32/41] Add new env vars and tests --- tests/GitHub.Tests.ps1 | 173 ++++++++++++++++++++++++++++++++++------- 1 file changed, 144 insertions(+), 29 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 9894839eb..76da0ecb5 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -42,7 +42,6 @@ Describe 'GitHub' { { Connect-GitHubAccount } | Should -Not -Throw { Disconnect-GitHubAccount } | Should -Not -Throw } - It 'Can connect and disconnect - a second time' { Connect-GitHubAccount Write-Verbose (Get-GitHubContext | Out-String) -Verbose @@ -52,75 +51,66 @@ Describe 'GitHub' { Write-Verbose (Get-GitHubConfig | Out-String) -Verbose { Disconnect-GitHubAccount } | Should -Not -Throw } - It 'Can pass the context to the pipeline' { $context = Connect-GitHubAccount -PassThru Write-Verbose (Get-GitHubContext | Out-String) -Verbose $context | Should -Not -BeNullOrEmpty { $context | Disconnect-GitHubAccount } | Should -Not -Throw } - It 'Can connect multiple sessions, GITHUB_TOKEN + classic PAT token' { - { Connect-GitHubAccount -Token $env:TEST_PAT } | Should -Not -Throw - { Connect-GitHubAccount -Token $env:TEST_PAT } | Should -Not -Throw + { Connect-GitHubAccount -Token $env:TEST_USER_PAT } | Should -Not -Throw + { Connect-GitHubAccount -Token $env:TEST_USER_PAT } | Should -Not -Throw { Connect-GitHubAccount } | Should -Not -Throw # Logs on with GitHub Actions' token (Get-GitHubContext -ListAvailable).Count | Should -Be 2 Get-GitHubConfig -Name 'DefaultContext' | Should -Be 'github.com/github-actions/Organization/PSModule' Write-Verbose (Get-GitHubContext | Out-String) -Verbose } - It 'Can reconfigure an existing context to be fine-grained PAT token' { - { Connect-GitHubAccount -Token $env:TEST_FG_PAT } | Should -Not -Throw + { Connect-GitHubAccount -Token $env:TEST_USER_USER_FG_PAT } | Should -Not -Throw (Get-GitHubContext -ListAvailable).Count | Should -Be 2 Write-Verbose (Get-GitHubContext -ListAvailable | Out-String) -Verbose } - It 'Can be called with a GitHub App' { $params = @{ - ClientID = $env:TEST_APP_CLIENT_ID - PrivateKey = $env:TEST_APP_PRIVATE_KEY + ClientID = $env:TEST_APP_ORG_CLIENT_ID + PrivateKey = $env:TEST_APP_ORG_PRIVATE_KEY } { Connect-GitHubAccount @params } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 3 } - It 'Can be called with a GitHub App and autoload installations' { $params = @{ - ClientID = $env:TEST_APP_CLIENT_ID - PrivateKey = $env:TEST_APP_PRIVATE_KEY + ClientID = $env:TEST_APP_ORG_CLIENT_ID + PrivateKey = $env:TEST_APP_ORG_PRIVATE_KEY } { Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw $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-GitHubContextInfo -Name 'github.com/psmodule-test-app/*' -Verbose:$false + { Disconnect-GitHubAccount -Context 'github.com/psmodule-org-app/Organization/PSModule' -Silent } | Should -Not -Throw + $contexts = Get-GitHubContextInfo -Name 'github.com/psmodule-org-app/*' -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 3 - Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY -AutoloadInstallations + Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY -AutoloadInstallations $contexts = Get-GitHubContext -ListAvailable -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 7 } - It 'Can get the authenticated GitHubApp' { $app = Get-GitHubApp Write-Verbose ($app | Format-Table | Out-String) -Verbose $app | Should -Not -BeNullOrEmpty } - It 'Can connect to a GitHub App Installation' { $appContext = Connect-GitHubApp -Organization 'PSModule' -PassThru Write-Verbose ($appContext | Out-String) -Verbose $appContext | Should -Not -BeNullOrEmpty { $appContext | Disconnect-GitHub } | Should -Not -Throw } - It 'Can connect to all GitHub App Installations' { { Connect-GitHubApp } | Should -Not -Throw Write-Verbose 'Default context:' -Verbose @@ -128,16 +118,13 @@ Describe 'GitHub' { Write-Verbose 'All contexts:' -Verbose Write-Verbose (Get-GitHubContext -ListAvailable | Out-String) -Verbose } - It 'Can swap context to another' { { Set-GitHubDefaultContext -Context 'github.com/github-actions/Organization/PSModule' } | Should -Not -Throw Get-GitHubConfig -Name 'DefaultContext' | Should -Be 'github.com/github-actions/Organization/PSModule' } - It 'Get-GitHubViewer can be called' { Get-GitHubViewer | Should -Not -BeNullOrEmpty } - It 'Get-GitHubConfig gets the DefaultContext' { Write-Verbose (Get-GitHubConfig -Name 'DefaultContext') -Verbose { Get-GitHubConfig -Name 'DefaultContext' } | Should -Not -Throw @@ -264,9 +251,9 @@ Describe 'GitHub' { } } -Describe 'As a user - Fine-grained PAT token' { +Describe 'As a user - Fine-grained PAT token - user account access' { BeforeAll { - Connect-GitHubAccount -Token $env:TEST_FG_PAT + Connect-GitHubAccount -Token $env:TEST_USER_USER_FG_PAT } AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount @@ -385,9 +372,128 @@ Describe 'As a user - Fine-grained PAT token' { } } +Describe 'As a user - Fine-grained PAT token - organization account access' { + BeforeAll { + Connect-GitHubAccount -Token $env:TEST_USER_ORG_FG_PAT + } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount + } + Context 'API' { + It 'Can be called directly to get ratelimits' { + { + $rateLimit = Invoke-GitHubAPI -ApiEndpoint '/rate_limit' + Write-Verbose ($rateLimit | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + } + } + Context 'GraphQL' { + It 'Can be called directly to get viewer' { + { + $viewer = Invoke-GitHubGraphQLQuery -Query 'query { viewer { login } }' + Write-Verbose ($viewer | Format-Table | Out-String) -Verbose + } | Should -Not -Throw + } + } + Context 'Meta' { + It 'Get-GitHubRoot' { + $root = Get-GitHubRoot + Write-Verbose ($root | Format-Table | Out-String) -Verbose + $root | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubApiVersion' { + $apiVersion = Get-GitHubApiVersion + Write-Verbose ($apiVersion | Format-Table | Out-String) -Verbose + $apiVersion | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubMeta' { + $meta = Get-GitHubMeta + Write-Verbose ($meta | Format-Table | Out-String) -Verbose + $meta | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubOctocat' { + $octocat = Get-GitHubOctocat + Write-Verbose ($octocat | Format-Table | Out-String) -Verbose + $octocat | Should -Not -BeNullOrEmpty + } + It 'Get-GitHubZen' { + $zen = Get-GitHubZen + Write-Verbose ($zen | Format-Table | Out-String) -Verbose + $zen | Should -Not -BeNullOrEmpty + } + } + Context 'Rate-Limit' { + It 'Can be called with no parameters' { + { Get-GitHubRateLimit } | Should -Not -Throw + } + } + Context 'License' { + It 'Can be called with no parameters' { + { Get-GitHubLicense } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw + } + It 'Can be called with Repository parameter' { + { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + } + } + Context 'Emoji' { + It 'Can be called with no parameters' { + { Get-GitHubEmoji } | Should -Not -Throw + } + It 'Can be download the emojis' { + { Get-GitHubEmoji -Destination $env:TEMP } | Should -Not -Throw + } + } + Context 'Repository' { + Context 'Parameter Set: MyRepos_Type' { + It 'Can be called with no parameters' { + { Get-GitHubRepository - } | Should -Not -Throw + } + It 'Can be called with Type parameter' { + { Get-GitHubRepository -Type 'public' } | Should -Not -Throw + } + } + Context 'Parameter Set: MyRepos_Aff-Vis' { + It 'Can be called with Visibility and Affiliation parameters' { + { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw + } + } + It 'Can be called with Owner and Repo parameters' { + { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + } + It 'Can be called with Owner parameter' { + { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw + } + It 'Can be called with Username parameter' { + { Get-GitHubRepository -Username 'MariusStorhaug' } | Should -Not -Throw + } + } + Context 'GitIgnore' { + It 'Can be called with no parameters' { + { Get-GitHubGitignore } | Should -Not -Throw + } + It 'Can be called with Name parameter' { + { Get-GitHubGitignore -Name 'VisualStudio' } | Should -Not -Throw + } + } + Context 'Markdown' { + It 'Can be called with Text parameter' { + { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw + } + It 'Can be called with Text parameter and GitHub Format Mardown' { + { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw + } + It 'Raw - Can be called with Text parameter' { + { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw + } + } +} + Describe 'As a user - Classic PAT token' { BeforeAll { - Connect-GitHubAccount -Token $env:TEST_PAT + Connect-GitHubAccount -Token $env:TEST_USER_PAT } AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount @@ -588,9 +694,18 @@ Describe 'As GitHub Actions' { } } -Describe 'As a GitHub App' { +Describe 'As a GitHub App - Enterprise' { + BeforeAll { + Connect-GitHubAccount -ClientID $env:TEST_APP_ENT_CLIENT_ID -PrivateKey $env:TEST_APP_ENT_PRIVATE_KEY + } + AfterAll { + Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount + } +} + +Describe 'As a GitHub App - Organization' { BeforeAll { - Connect-GitHubAccount -ClientID $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY + Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY } AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount @@ -598,7 +713,7 @@ Describe 'As a GitHub App' { Context 'Apps' { Context 'GitHub Apps' { It 'Can get a JWT for the app' { - $jwt = Get-GitHubAppJSONWebToken -ClientId $env:TEST_APP_CLIENT_ID -PrivateKey $env:TEST_APP_PRIVATE_KEY + $jwt = Get-GitHubAppJSONWebToken -ClientId $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY Write-Verbose ($jwt | Format-Table | Out-String) -Verbose $jwt | Should -Not -BeNullOrEmpty } From 792040fb6df4b781072d55d9c9ec6b71a3b68be3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 17:51:21 +0100 Subject: [PATCH 33/41] Add APIKey secret to Nightly-Run and Process-PSModule workflows for enhanced security --- .github/workflows/Nightly-Run.yml | 1 + .github/workflows/Process-PSModule.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/Nightly-Run.yml b/.github/workflows/Nightly-Run.yml index c2260da4d..9b8e9f5d5 100644 --- a/.github/workflows/Nightly-Run.yml +++ b/.github/workflows/Nightly-Run.yml @@ -14,6 +14,7 @@ jobs: Process-PSModule: uses: PSModule/Process-PSModule/.github/workflows/CI.yml@v3 secrets: + APIKey: ${{ secrets.APIKey }} TEST_APP_ENT_CLIENT_ID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} TEST_APP_ENT_PRIVATE_KEY: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} TEST_APP_ORG_CLIENT_ID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index cb62d2745..3d703e6a5 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -28,6 +28,7 @@ jobs: Process-PSModule: uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v3 secrets: + APIKey: ${{ secrets.APIKey }} TEST_APP_ENT_CLIENT_ID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} TEST_APP_ENT_PRIVATE_KEY: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} TEST_APP_ORG_CLIENT_ID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} From 6c4674d8efaa69bb1d5136c343d9973f8e40ecd0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 18:24:44 +0100 Subject: [PATCH 34/41] Update GitHub tests to use enterprise app credentials and adjust expected context counts --- tests/GitHub.Tests.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 76da0ecb5..de1a52143 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -82,23 +82,27 @@ Describe 'GitHub' { } It 'Can be called with a GitHub App and autoload installations' { $params = @{ - ClientID = $env:TEST_APP_ORG_CLIENT_ID - PrivateKey = $env:TEST_APP_ORG_PRIVATE_KEY + ClientID = $env:TEST_APP_ENT_CLIENT_ID + PrivateKey = $env:TEST_APP_ENT_PRIVATE_KEY } + { Connect-GitHubAccount @params } | Should -Not -Throw + $contexts = Get-GitHubContextInfo -Verbose:$false + Write-Verbose ($contexts | Out-String) -Verbose + ($contexts).Count | Should -Be 4 { Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 7 + ($contexts).Count | Should -Be 6 } It 'Can disconnect a specific context' { { Disconnect-GitHubAccount -Context 'github.com/psmodule-org-app/Organization/PSModule' -Silent } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Name 'github.com/psmodule-org-app/*' -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 3 + ($contexts).Count | Should -Be 2 Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY -AutoloadInstallations $contexts = Get-GitHubContext -ListAvailable -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 7 + ($contexts).Count | Should -Be 6 } It 'Can get the authenticated GitHubApp' { $app = Get-GitHubApp From 50800c814f5d68d18803fdcd837adb1d3baf464c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 18:52:36 +0100 Subject: [PATCH 35/41] Update GitHub tests to reflect changes in context counts and adjust disconnect functionality for enterprise app --- tests/GitHub.Tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index de1a52143..1f13216d5 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -92,11 +92,11 @@ Describe 'GitHub' { { Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 6 + ($contexts).Count | Should -Be 7 } It 'Can disconnect a specific context' { - { Disconnect-GitHubAccount -Context 'github.com/psmodule-org-app/Organization/PSModule' -Silent } | Should -Not -Throw - $contexts = Get-GitHubContextInfo -Name 'github.com/psmodule-org-app/*' -Verbose:$false + { Disconnect-GitHubAccount -Context 'github.com/psmodule-enterprise-app/Organization/PSModule' -Silent } | Should -Not -Throw + $contexts = Get-GitHubContextInfo -Name 'github.com/psmodule-enterprise-app/*' -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 2 Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY -AutoloadInstallations From cfbc81f80bba04019c8d61ad527636d18ed5016b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 19:26:26 +0100 Subject: [PATCH 36/41] Update GitHub tests to reflect changes in context counts and validate autoload installations --- tests/GitHub.Tests.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 1f13216d5..237e764fa 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -79,6 +79,10 @@ Describe 'GitHub' { $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose ($contexts).Count | Should -Be 3 + { Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw + $contexts = Get-GitHubContextInfo -Verbose:$false + Write-Verbose ($contexts | Out-String) -Verbose + ($contexts).Count | Should -Be 5 } It 'Can be called with a GitHub App and autoload installations' { $params = @{ @@ -88,11 +92,11 @@ Describe 'GitHub' { { Connect-GitHubAccount @params } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 4 + ($contexts).Count | Should -Be 6 { Connect-GitHubAccount @params -AutoloadInstallations } | Should -Not -Throw $contexts = Get-GitHubContextInfo -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 7 + ($contexts).Count | Should -Be 9 } It 'Can disconnect a specific context' { { Disconnect-GitHubAccount -Context 'github.com/psmodule-enterprise-app/Organization/PSModule' -Silent } | Should -Not -Throw @@ -102,7 +106,7 @@ Describe 'GitHub' { Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY -AutoloadInstallations $contexts = Get-GitHubContext -ListAvailable -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 6 + ($contexts).Count | Should -Be 9 } It 'Can get the authenticated GitHubApp' { $app = Get-GitHubApp From 92f8a5941bc09de97eb2befe71dbda433e5bac82 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 20:00:21 +0100 Subject: [PATCH 37/41] Update GitHub tests to reflect changes in expected context counts and adjust assertions for command outputs --- tests/GitHub.Tests.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 237e764fa..adae72c8f 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -106,7 +106,7 @@ Describe 'GitHub' { Connect-GitHubAccount -ClientID $env:TEST_APP_ORG_CLIENT_ID -PrivateKey $env:TEST_APP_ORG_PRIVATE_KEY -AutoloadInstallations $contexts = Get-GitHubContext -ListAvailable -Verbose:$false Write-Verbose ($contexts | Out-String) -Verbose - ($contexts).Count | Should -Be 9 + ($contexts).Count | Should -Be 8 } It 'Can get the authenticated GitHubApp' { $app = Get-GitHubApp @@ -204,7 +204,7 @@ Describe 'GitHub' { { Add-GitHubSystemPath -Path $pwd.ToString() } | Should -Not -Throw - Get-Content $env:GITHUB_PATH -Raw | Should -Belike "*$($pwd.ToString())*" + Get-Content $env:GITHUB_PATH -Raw | Should -BeLike "*$($pwd.ToString())*" } It 'Disable-GitHubCommand should not throw' { { @@ -237,7 +237,7 @@ Describe 'GitHub' { { Set-GitHubEnvironmentVariable -Name 'MyName' -Value 'MyValue' } | Should -Not -Throw - Get-Content $env:GITHUB_ENV -Raw | Should -BeLike "*MyName*MyValue*" + Get-Content $env:GITHUB_ENV -Raw | Should -BeLike '*MyName*MyValue*' } It 'Set-GitHubStepSummary should not throw' { { @@ -337,7 +337,7 @@ Describe 'As a user - Fine-grained PAT token - user account access' { Context 'Repository' { Context 'Parameter Set: MyRepos_Type' { It 'Can be called with no parameters' { - { Get-GitHubRepository - } | Should -Not -Throw + { Get-GitHubRepository } | Should -Not -Throw } It 'Can be called with Type parameter' { @@ -457,7 +457,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { Context 'Repository' { Context 'Parameter Set: MyRepos_Type' { It 'Can be called with no parameters' { - { Get-GitHubRepository - } | Should -Not -Throw + { Get-GitHubRepository } | Should -Not -Throw } It 'Can be called with Type parameter' { { Get-GitHubRepository -Type 'public' } | Should -Not -Throw From c4f37505343a6cfb20d708c9a005e9f984b9410a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 20:57:54 +0100 Subject: [PATCH 38/41] Refactor GitHub API functions to enhance parameter handling and update tests for Markdown functionality --- .../Repositories/Get-GitHubMyRepositories.ps1 | 15 ++++++++++----- .../public/Markdown/Get-GitHubMarkdown.ps1 | 2 +- .../public/Markdown/Get-GitHubMarkdownRaw.ps1 | 6 +++++- tests/GitHub.Tests.ps1 | 6 +++--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index da8719bc8..acdfb5eb4 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -123,21 +123,26 @@ process { try { $body = @{ - type = $Type sort = $Sort direction = $Direction per_page = $PerPage } - - if ($PSBoundParameters.ContainsKey('Affiliation')) { - $body['affiliation'] = $Affiliation -join ',' - } if ($PSBoundParameters.ContainsKey('Since')) { $body['since'] = $Since.ToString('yyyy-MM-ddTHH:mm:ssZ') } if ($PSBoundParameters.ContainsKey('Before')) { $body['before'] = $Before.ToString('yyyy-MM-ddTHH:mm:ssZ') } + Write-Debug "ParamSet: [$($PSCmdlet.ParameterSetName)]" + switch ($PSCmdlet.ParameterSetName) { + 'Aff-Vis' { + $body['affiliation'] = $Affiliation -join ',' + $body['visibility'] = $Visibility + } + 'Type' { + $body['type'] = $Type + } + } $inputObject = @{ Context = $Context diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index f1be7cd37..5c8633833 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -24,7 +24,7 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [switch] $Text, + [string] $Text, # The rendering mode. [Parameter()] diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 index e6cd88509..e759137d0 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 @@ -16,6 +16,7 @@ .NOTES [Render a Markdown document in raw mode](https://docs.github.com/rest/reference/meta#github-api-root) + https://docs.github.com/rest/markdown/markdown#render-a-markdown-document-in-raw-mode #> [CmdletBinding()] param( @@ -38,12 +39,15 @@ process { try { + $body = @{ + text = $Text + } $inputObject = @{ Context = $Context APIEndpoint = '/markdown/raw' ContentType = 'text/plain' - Body = $Text Method = 'POST' + Body = $body } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index adae72c8f..29c3be9cf 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -488,13 +488,13 @@ Describe 'As a user - Fine-grained PAT token - organization account access' { } Context 'Markdown' { It 'Can be called with Text parameter' { - { Get-GitHubMarkdown -Text 'Hello, World!' } | Should -Not -Throw + { Get-GitHubMarkdown -Text 'Hello, **World**' } | Should -Not -Throw } It 'Can be called with Text parameter and GitHub Format Mardown' { - { Get-GitHubMarkdown -Text 'Hello, World!' -Mode gfm } | Should -Not -Throw + { Get-GitHubMarkdown -Text 'Hello, **World**' -Mode gfm } | Should -Not -Throw } It 'Raw - Can be called with Text parameter' { - { Get-GitHubMarkdownRaw -Text 'Hello, World!' } | Should -Not -Throw + { Get-GitHubMarkdownRaw -Text 'Hello, **World**' } | Should -Not -Throw } } } From 1ba69a53895207954a077d6c8a74df045135d9e9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 21:06:01 +0100 Subject: [PATCH 39/41] Fix --- src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 index e759137d0..cbdf5c1a6 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 @@ -15,8 +15,7 @@ Render the Markdown text 'Hello, world!' in raw mode. .NOTES - [Render a Markdown document in raw mode](https://docs.github.com/rest/reference/meta#github-api-root) - https://docs.github.com/rest/markdown/markdown#render-a-markdown-document-in-raw-mode + [Render a Markdown document in raw mode](https://docs.github.com/rest/markdown/markdown#render-a-markdown-document-in-raw-mode) #> [CmdletBinding()] param( From 15326e08601ff1076eb4e5fffe1e4b0c124dc0a3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 21:44:39 +0100 Subject: [PATCH 40/41] Add support for 'text/html' response handling in GitHub API function --- src/functions/public/API/Invoke-GitHubAPI.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index d567471fd..a13cdba3c 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -194,6 +194,9 @@ 'text/plain' { $results = $response.Content } + 'text/html' { + $results = $response.Content + } 'application/octocat-stream' { [byte[]]$byteArray = $response.Content $results = [System.Text.Encoding]::UTF8.GetString($byteArray) From 6447e01a9238c7ee126aab506bf7ec635387c436 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 23 Dec 2024 22:20:16 +0100 Subject: [PATCH 41/41] Fix --- src/functions/public/API/Invoke-GitHubAPI.ps1 | 4 ++-- .../Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index a13cdba3c..74a402946 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -95,12 +95,12 @@ process { $Token = $Context.Token - Write-Debug "Token : [$Token]" + Write-Debug "Token : [$Token]" if ([string]::IsNullOrEmpty($TokenType)) { $TokenType = $Context.TokenType } - Write-Debug "TokenType : [$($Context.TokenType)]" + Write-Debug "TokenType : [$($Context.TokenType)]" if ([string]::IsNullOrEmpty($ApiBaseUri)) { $ApiBaseUri = $Context.ApiBaseUri diff --git a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 index 5bf4316c1..734027fd6 100644 --- a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 @@ -58,8 +58,9 @@ url = $URL content_type = $ContentType secret = $Secret - insecure_ssl = $InsecureSSL ? 1 : 0 + insecure_ssl = $PSBoundParameters.ContainsKey($InsecureSSL) ? ($InsecureSSL ? 1 : 0) : $null } + $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ Context = $Context