From b95f120695b8d8072cb1b42aa1224b32af3db079 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 15:03:21 +0200 Subject: [PATCH 01/25] Add initial test scripts for GitHub API interactions - Created TEMPLATE.ps1 for structuring Pester tests. - Added Teams.Tests.ps1 to test GitHub Teams API functionalities, including team creation, retrieval, updating, and deletion. - Implemented Users.Tests.ps1 for testing user-related API calls, such as fetching user details and updating user information. - Developed Variables.Tests.ps1 to validate GitHub variable management, including setting, updating, and removing variables for users, organizations, and repositories. --- .github/PSModule.yml | 15 +++++ src/classes/public/App/GitHubApp.ps1 | 18 ++++++ .../public/App/GitHubAppInstallation.ps1 | 63 +++++++++++++++++++ src/classes/public/Owner/GitHubOwner.ps1 | 4 +- ...tHubAppInstallationForAuthenticatedApp.ps1 | 3 +- ...bEnterpriseOrganizationAppInstallation.ps1 | 4 +- .../Get-GitHubOrganizationAppInstallation.ps1 | 6 +- .../Get-GitHubAppInstallation.ps1 | 7 ++- {tests => tests copy}/Artifacts.Tests.ps1 | 0 {tests => tests copy}/Environments.Tests.ps1 | 0 {tests => tests copy}/Organizations.Tests.ps1 | 0 {tests => tests copy}/README.md | 0 {tests => tests copy}/Releases.Tests.ps1 | 0 {tests => tests copy}/Repositories.Tests.ps1 | 0 {tests => tests copy}/Secrets.Tests.ps1 | 0 {tests => tests copy}/TEMPLATE.ps1 | 0 {tests => tests copy}/Teams.Tests.ps1 | 0 {tests => tests copy}/Users.Tests.ps1 | 0 {tests => tests copy}/Variables.Tests.ps1 | 0 19 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 src/classes/public/App/GitHubApp.ps1 create mode 100644 src/classes/public/App/GitHubAppInstallation.ps1 rename {tests => tests copy}/Artifacts.Tests.ps1 (100%) rename {tests => tests copy}/Environments.Tests.ps1 (100%) rename {tests => tests copy}/Organizations.Tests.ps1 (100%) rename {tests => tests copy}/README.md (100%) rename {tests => tests copy}/Releases.Tests.ps1 (100%) rename {tests => tests copy}/Repositories.Tests.ps1 (100%) rename {tests => tests copy}/Secrets.Tests.ps1 (100%) rename {tests => tests copy}/TEMPLATE.ps1 (100%) rename {tests => tests copy}/Teams.Tests.ps1 (100%) rename {tests => tests copy}/Users.Tests.ps1 (100%) rename {tests => tests copy}/Variables.Tests.ps1 (100%) diff --git a/.github/PSModule.yml b/.github/PSModule.yml index 6d578178e..3440fd2ac 100644 --- a/.github/PSModule.yml +++ b/.github/PSModule.yml @@ -1,3 +1,18 @@ +Build: + Docs: + Skip: true Test: + SourceCode: + Skip: true + PSModule: + Skip: true + Module: + Windows: + Skip: true + MacOS: + Skip: true CodeCoverage: + Skip: true PercentTarget: 50 + TestResults: + Skip: true diff --git a/src/classes/public/App/GitHubApp.ps1 b/src/classes/public/App/GitHubApp.ps1 new file mode 100644 index 000000000..26049cf6e --- /dev/null +++ b/src/classes/public/App/GitHubApp.ps1 @@ -0,0 +1,18 @@ +class GitHubApp { + # The Client ID of the app + [string] $ClientID + + # The App ID of the app + [System.Nullable[UInt64]] $AppID + + # The Slug of the app + [string] $Slug + + GitHubApp() {} + + GitHubApp([object]$Object) { + $this.ClientID = $Object.client_id + $this.AppID = $Object.app_id + $this.Slug = $Object.app_slug ?? $Object.slug + } +} diff --git a/src/classes/public/App/GitHubAppInstallation.ps1 b/src/classes/public/App/GitHubAppInstallation.ps1 new file mode 100644 index 000000000..0bcc10ff5 --- /dev/null +++ b/src/classes/public/App/GitHubAppInstallation.ps1 @@ -0,0 +1,63 @@ +class GitHubAppInstallation { + # The installation ID on the target. + [System.Nullable[UInt64]] $ID + + # The app that is installed. + [GitHubApp] $App + + # The target of the installation. + [GitHubOwner]$Target + + # The type of target. + [string] $Type + + # The type of repository selection. + [string] $RepositorySelection + + # The permissions that the app has on the target. + [pscustomobject] $Permissions + + # The events that the app is subscribing to. + [string[]] $Events + + # The file paths that the app has access to. + [string[]] $FilePaths + + # The creation date of the installation. + # Example: 2008-01-14T04:33:35Z + [System.Nullable[datetime]] $CreatedAt + + # The last update date of the installation. + # Example: 2008-01-14T04:33:35Z + [System.Nullable[datetime]] $UpdatedAt + + # The date the installation was suspended. + # Example: 2008-01-14T04:33:35Z + [System.Nullable[datetime]] $SuspendedAt + + # The account that suspended the installation. + [GitHubUser] $SuspendedBy + + GitHubAppInstallation() {} + + GitHubAppInstallation([PSCustomObject]$Object) { + $this.ID = $Object.id + $this.App = [GitHubApp]::new( + [PSCustomObject]@{ + client_id = $Object.client_id + app_id = $Object.app_id + app_slug = $Object.app_slug + } + ) + $this.Target = [GitHubOwner]::new($Object.account) + $this.Type = $Object.target_type + $this.RepositorySelection = $Object.repository_selection + $this.Permissions = $Object.permissions + $this.Events = $Object.events + $this.FilePaths = $Object.single_file_paths + $this.CreatedAt = $Object.created_at + $this.UpdatedAt = $Object.updated_at + $this.SuspendedAt = $Object.suspended_at + $this.SuspendedBy = [GitHubUser]::new($Object.suspended_by) + } +} diff --git a/src/classes/public/Owner/GitHubOwner.ps1 b/src/classes/public/Owner/GitHubOwner.ps1 index 4c56bbc2a..96345cb84 100644 --- a/src/classes/public/Owner/GitHubOwner.ps1 +++ b/src/classes/public/Owner/GitHubOwner.ps1 @@ -75,13 +75,13 @@ $this.NodeID = $Object.node_id # From GitHubOwner - $this.Name = $Object.login + $this.Name = $Object.slug ?? $Object.login $this.DisplayName = $Object.name $this.AvatarUrl = $Object.avatar_url $this.Url = $Object.html_url $this.Type = $Object.type $this.Company = $Object.company - $this.Blog = $Object.blog + $this.Blog = $Object.website_url ?? $Object.blog $this.Location = $Object.location $this.Email = $Object.email $this.TwitterUsername = $Object.twitter_username diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 43f409f6c..be6623f5c 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -17,6 +17,7 @@ .NOTES [List installations for the authenticated app](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app) #> + [OutputType([GitHubAppInstallation])] [CmdletBinding()] param( # The context to run the command in. Used to get the details for the API call. @@ -38,7 +39,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubAppInstallation]::new($_.Response) } } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index baf4d38d6..bdad499f8 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -16,7 +16,7 @@ .NOTES [List GitHub Apps installed on an enterprise-owned organization]() #> - [OutputType([pscustomobject])] + [OutputType([GitHubAppInstallation])] [CmdletBinding()] param( # The enterprise slug or ID. @@ -58,7 +58,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubAppInstallation]::new($_.Response) } } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index 692ed4ed5..90c442354 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -15,7 +15,7 @@ .NOTES [List app installations for an organization](https://docs.github.com/rest/orgs/orgs#list-app-installations-for-an-organization) #> - [OutputType([pscustomobject])] + [OutputType([GitHubAppInstallation])] [CmdletBinding()] param( # The organization name. The name is not case sensitive. @@ -50,7 +50,9 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.installations + $_.Response.installations | ForEach-Object { + [GitHubAppInstallation]::new($_) + } } } diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 index bac0de97b..05f2c80c1 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 @@ -11,13 +11,14 @@ .LINK https://psmodule.io/GitHub/Functions/Apps/GitHub%20App%20Installations/Get-GitHubAppInstallation #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [OutputType([GitHubAppInstallation[]])] + [CmdletBinding(DefaultParameterSetName = 'List installations for the authenticated app')] param( # The enterprise slug or ID. [Parameter( Mandatory, ValueFromPipelineByPropertyName, - ParameterSetName = 'Enterprise' + ParameterSetName = 'List installations on the Enterprise' )] [string] $Enterprise, @@ -25,7 +26,7 @@ [Parameter( Mandatory, ValueFromPipelineByPropertyName, - ParameterSetName = 'Enterprise' + ParameterSetName = 'List installations on the Enterprise' )] [Parameter( Mandatory, diff --git a/tests/Artifacts.Tests.ps1 b/tests copy/Artifacts.Tests.ps1 similarity index 100% rename from tests/Artifacts.Tests.ps1 rename to tests copy/Artifacts.Tests.ps1 diff --git a/tests/Environments.Tests.ps1 b/tests copy/Environments.Tests.ps1 similarity index 100% rename from tests/Environments.Tests.ps1 rename to tests copy/Environments.Tests.ps1 diff --git a/tests/Organizations.Tests.ps1 b/tests copy/Organizations.Tests.ps1 similarity index 100% rename from tests/Organizations.Tests.ps1 rename to tests copy/Organizations.Tests.ps1 diff --git a/tests/README.md b/tests copy/README.md similarity index 100% rename from tests/README.md rename to tests copy/README.md diff --git a/tests/Releases.Tests.ps1 b/tests copy/Releases.Tests.ps1 similarity index 100% rename from tests/Releases.Tests.ps1 rename to tests copy/Releases.Tests.ps1 diff --git a/tests/Repositories.Tests.ps1 b/tests copy/Repositories.Tests.ps1 similarity index 100% rename from tests/Repositories.Tests.ps1 rename to tests copy/Repositories.Tests.ps1 diff --git a/tests/Secrets.Tests.ps1 b/tests copy/Secrets.Tests.ps1 similarity index 100% rename from tests/Secrets.Tests.ps1 rename to tests copy/Secrets.Tests.ps1 diff --git a/tests/TEMPLATE.ps1 b/tests copy/TEMPLATE.ps1 similarity index 100% rename from tests/TEMPLATE.ps1 rename to tests copy/TEMPLATE.ps1 diff --git a/tests/Teams.Tests.ps1 b/tests copy/Teams.Tests.ps1 similarity index 100% rename from tests/Teams.Tests.ps1 rename to tests copy/Teams.Tests.ps1 diff --git a/tests/Users.Tests.ps1 b/tests copy/Users.Tests.ps1 similarity index 100% rename from tests/Users.Tests.ps1 rename to tests copy/Users.Tests.ps1 diff --git a/tests/Variables.Tests.ps1 b/tests copy/Variables.Tests.ps1 similarity index 100% rename from tests/Variables.Tests.ps1 rename to tests copy/Variables.Tests.ps1 From 5d4e6c2c12cc5385826f364ae79add273be2e7be Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 15:12:16 +0200 Subject: [PATCH 02/25] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Correct=20paramet?= =?UTF-8?q?er=20set=20names=20in=20`Get-GitHubAppInstallation`=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubAppInstallation.ps1 | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 index 05f2c80c1..c99d8f6c4 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 @@ -18,7 +18,7 @@ [Parameter( Mandatory, ValueFromPipelineByPropertyName, - ParameterSetName = 'List installations on the Enterprise' + ParameterSetName = 'List installations on an Enterprise' )] [string] $Enterprise, @@ -26,18 +26,16 @@ [Parameter( Mandatory, ValueFromPipelineByPropertyName, - ParameterSetName = 'List installations on the Enterprise' + ParameterSetName = 'List installations on an Enterprise' )] [Parameter( Mandatory, ValueFromPipelineByPropertyName, - ParameterSetName = 'Organization' + ParameterSetName = 'List installations on an Organization' )] [string] $Organization, # The number of results per page (max 100). - [Parameter(ParameterSetName = 'Enterprise')] - [Parameter(ParameterSetName = 'Organization')] [System.Nullable[int]] $PerPage, # The context to run the command in. Used to get the details for the API call. @@ -53,26 +51,26 @@ } process { + $params = @{ + PerPage = $PerPage + Context = $Context + } switch ($PSCmdlet.ParameterSetName) { - 'Enterprise' { - $params = @{ + 'List installations on an Enterprise' { + $params += @{ Enterprise = $Enterprise Organization = $Organization - PerPage = $PerPage - Context = $Context } Get-GitHubEnterpriseOrganizationAppInstallation @params } - 'Organization' { - $params = @{ + 'List installations on an Organization' { + $params += @{ Organization = $Organization - PerPage = $PerPage - Context = $Context } Get-GitHubOrganizationAppInstallation @params } - default { - Get-GitHubAppInstallationForAuthenticatedApp -Context $Context + 'List installations for the authenticated app' { + Get-GitHubAppInstallationForAuthenticatedApp @params } } } From 6db222e56184daee83d4a55a2b17ea7d3c094237 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 15:37:45 +0200 Subject: [PATCH 03/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20`PerPage`?= =?UTF-8?q?=20parameter=20to=20`Get-GitHubAppInstallation`=20and=20`Get-Gi?= =?UTF-8?q?tHubAppInstallationForAuthenticatedApp`=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubAppInstallationForAuthenticatedApp.ps1 | 5 +++++ .../GitHub App Installations/Get-GitHubAppInstallation.ps1 | 1 + 2 files changed, 6 insertions(+) diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index be6623f5c..3cc5f5a2a 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -20,6 +20,10 @@ [OutputType([GitHubAppInstallation])] [CmdletBinding()] param( + # The number of results per page (max 100). + [Parameter()] + [System.Nullable[int]] $PerPage, + # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] [object] $Context @@ -35,6 +39,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/app/installations' + PerPage = $PerPage Method = 'GET' } diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 index c99d8f6c4..856252aa0 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 @@ -36,6 +36,7 @@ [string] $Organization, # The number of results per page (max 100). + [Parameter()] [System.Nullable[int]] $PerPage, # The context to run the command in. Used to get the details for the API call. From ca1871b78b12ba76176c7968d531cec5930897e0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 15:57:54 +0200 Subject: [PATCH 04/25] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Update=20referenc?= =?UTF-8?q?es=20from=20`target=5Ftype`=20to=20`Type`=20and=20`account`=20t?= =?UTF-8?q?o=20`Target`=20in=20GitHub=20App=20installation=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/Apps/EnterpriseApps.ps1 | 2 +- .../public/Auth/Connect-GitHubApp.ps1 | 20 +++++++++---------- .../Auth/Connect-GitHubApp_completer.ps1 | 12 +++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 index f06cbfaa7..fc45e5692 100644 --- a/examples/Apps/EnterpriseApps.ps1 +++ b/examples/Apps/EnterpriseApps.ps1 @@ -24,7 +24,7 @@ filter Install-GithubApp { $orgs = $installableOrgs | Where-Object { $_.login -like $organization } foreach ($org in $orgs) { foreach ($appIDitem in $AppID) { - Install-GitHubAppOnEnterpriseOrganization -Enterprise $Enterprise -Organization $org.login -ClientID $appIDitem -RepositorySelection all | ForEach-Object { + Install-GitHubApp -Enterprise $Enterprise -Organization $org.login -ClientID $appIDitem -RepositorySelection all | ForEach-Object { [PSCustomObject]@{ Organization = $org.login AppID = $appIDitem diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index bac6f7ace..9961fb11d 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -95,21 +95,21 @@ $userItem = $_ Write-Verbose "User filter: [$userItem]." $selectedInstallations += $installations | Where-Object { - $_.target_type -eq 'User' -and $_.account.login -like $userItem + $_.Type -eq 'User' -and $_.Target.Name -like $userItem } } $Organization | ForEach-Object { $organizationItem = $_ Write-Verbose "Organization filter: [$organizationItem]." $selectedInstallations += $installations | Where-Object { - $_.target_type -eq 'Organization' -and $_.account.login -like $organizationItem + $_.Type -eq 'Organization' -and $_.Target.Name -like $organizationItem } } $Enterprise | ForEach-Object { $enterpriseItem = $_ Write-Verbose "Enterprise filter: [$enterpriseItem]." $selectedInstallations += $installations | Where-Object { - $_.target_type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem + $_.Type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem } } } @@ -122,7 +122,7 @@ Write-Verbose "Found [$($selectedInstallations.Count)] installations for the target." $selectedInstallations | ForEach-Object { $installation = $_ - Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" + Write-Verbose "Processing installation [$($installation.Target.Name)] [$($installation.id)]" $token = New-GitHubAppInstallationAccessToken -Context $Context -InstallationID $installation.id $contextParams = @{ @@ -138,19 +138,19 @@ InstallationID = [string]$installation.id Permissions = [pscustomobject]$installation.permissions Events = [string[]]$installation.events - InstallationType = [string]$installation.target_type + InstallationType = [string]$installation.Type Token = [securestring]$token.Token TokenExpirationDate = [datetime]$token.ExpiresAt } - switch ($installation.target_type) { + switch ($installation.Type) { 'User' { - $contextParams['InstallationName'] = [string]$installation.account.login - $contextParams['Owner'] = [string]$installation.account.login + $contextParams['InstallationName'] = [string]$installation.Target.Name + $contextParams['Owner'] = [string]$installation.Target.Name } 'Organization' { - $contextParams['InstallationName'] = [string]$installation.account.login - $contextParams['Owner'] = [string]$installation.account.login + $contextParams['InstallationName'] = [string]$installation.Target.Name + $contextParams['Owner'] = [string]$installation.Target.Name } 'Enterprise' { $contextParams['InstallationName'] = [string]$installation.account.slug diff --git a/src/functions/public/Auth/Connect-GitHubApp_completer.ps1 b/src/functions/public/Auth/Connect-GitHubApp_completer.ps1 index 94c2b93dc..2dcf1938f 100644 --- a/src/functions/public/Auth/Connect-GitHubApp_completer.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp_completer.ps1 @@ -2,26 +2,26 @@ param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter - Get-GitHubAppInstallation -Verbose:$false | Where-Object { $_.target_type -eq 'User' -and $_.account.login -like "$wordToComplete*" } | + Get-GitHubAppInstallation -Verbose:$false | Where-Object { $_.Type -eq 'User' -and $_.Target.Name -like "$wordToComplete*" } | ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_.account.login, $_.account.login, 'ParameterValue', $_.account.login) + [System.Management.Automation.CompletionResult]::new($_.Target.Name, $_.Target.Name, 'ParameterValue', $_.Target.Name) } } Register-ArgumentCompleter -CommandName Connect-GitHubApp -ParameterName Organization -ScriptBlock { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter - Get-GitHubAppInstallation -Verbose:$false | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -like "$wordToComplete*" } | + Get-GitHubAppInstallation -Verbose:$false | Where-Object { $_.Type -eq 'Organization' -and $_.Target.Name -like "$wordToComplete*" } | ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_.account.login, $_.account.login, 'ParameterValue', $_.account.login) + [System.Management.Automation.CompletionResult]::new($_.Target.Name, $_.Target.Name, 'ParameterValue', $_.Target.Name) } } Register-ArgumentCompleter -CommandName Connect-GitHubApp -ParameterName Enterprise -ScriptBlock { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter - Get-GitHubAppInstallation -Verbose:$false | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -like "$wordToComplete*" } | + Get-GitHubAppInstallation -Verbose:$false | Where-Object { $_.Type -eq 'Enterprise' -and $_.Target.Name -like "$wordToComplete*" } | ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_.account.slug, $_.account.slug, 'ParameterValue', $_.account.slug) + [System.Management.Automation.CompletionResult]::new($_.Target.Name, $_.Target.Name, 'ParameterValue', $_.Target.Name) } } From faf2a4214d25a0709b1b07cc2970da1c817178a3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 16:20:01 +0200 Subject: [PATCH 05/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enhance=20loggi?= =?UTF-8?q?ng=20in=20authentication=20tests=20by=20adding=20debug=20and=20?= =?UTF-8?q?verbose=20options=20to=20connection=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/GitHub.Tests.ps1 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 666f5eb6d..954ec35d1 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -64,7 +64,9 @@ Describe 'Auth' { # Tests for APP goes here if ($AuthType -eq 'APP') { It 'Connect-GitHubAccount - Connects using the provided credentials + AutoloadInstallations' { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent -AutoloadInstallations + LogGroup 'Connect-Github' { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent -AutoloadInstallations -Debug -Verbose + } LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } @@ -72,7 +74,9 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Connects as a GitHub App to ' { - $contexts = Connect-GitHubApp -PassThru -Silent + LogGroup 'Connect-GithubApp' { + $contexts = Connect-GitHubApp -PassThru -Silent -Debug -Verbose + } LogGroup 'Contexts' { Write-Host ($contexts | Format-List | Out-String) } @@ -80,7 +84,9 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Connects as a GitHub App to ' { - $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent + LogGroup 'Connect-GithubApp' { + $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent -Debug -Verbose + } LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } From f757b4327953e04ff827827868a10b5703c40a15 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 16:41:34 +0200 Subject: [PATCH 06/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20resp?= =?UTF-8?q?onse=20handling=20in=20Get-GitHubAppInstallationForAuthenticate?= =?UTF-8?q?dApp=20and=20streamline=20test=20cases=20for=20GitHub=20App=20c?= =?UTF-8?q?onnections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tHubAppInstallationForAuthenticatedApp.ps1 | 4 +- tests/GitHub.Tests.ps1 | 49 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 3cc5f5a2a..33d667d93 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -44,7 +44,9 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - [GitHubAppInstallation]::new($_.Response) + $_.Response | ForEach-Object { + [GitHubAppInstallation]::new($_) + } } } diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 954ec35d1..28a8d359b 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -61,37 +61,34 @@ Describe 'Auth' { $context | Should -Not -BeNullOrEmpty } - # Tests for APP goes here - if ($AuthType -eq 'APP') { - It 'Connect-GitHubAccount - Connects using the provided credentials + AutoloadInstallations' { - LogGroup 'Connect-Github' { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent -AutoloadInstallations -Debug -Verbose - } - LogGroup 'Context' { - Write-Host ($context | Format-List | Out-String) - } - $context | Should -Not -BeNullOrEmpty + It 'Connect-GitHubAccount - Connects using the provided credentials + AutoloadInstallations' -Skip:($AuthType -ne 'APP') { + LogGroup 'Connect-Github' { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent -AutoloadInstallations -Debug -Verbose } + LogGroup 'Context' { + Write-Host ($context | Format-List | Out-String) + } + $context | Should -Not -BeNullOrEmpty + } - It 'Connect-GitHubApp - Connects as a GitHub App to ' { - LogGroup 'Connect-GithubApp' { - $contexts = Connect-GitHubApp -PassThru -Silent -Debug -Verbose - } - LogGroup 'Contexts' { - Write-Host ($contexts | Format-List | Out-String) - } - $contexts | Should -Not -BeNullOrEmpty + It 'Connect-GitHubApp - Connects as a GitHub App to ' -Skip:($AuthType -ne 'APP') { + LogGroup 'Connect-GithubApp' { + $contexts = Connect-GitHubApp -PassThru -Silent -Debug -Verbose } + LogGroup 'Contexts' { + Write-Host ($contexts | Format-List | Out-String) + } + $contexts | Should -Not -BeNullOrEmpty + } - It 'Connect-GitHubApp - Connects as a GitHub App to ' { - LogGroup 'Connect-GithubApp' { - $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent -Debug -Verbose - } - LogGroup 'Context' { - Write-Host ($context | Format-List | Out-String) - } - $context | Should -Not -BeNullOrEmpty + It 'Connect-GitHubApp - Connects as a GitHub App to ' -Skip:($AuthType -ne 'APP') { + LogGroup 'Connect-GithubApp' { + $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent -Debug -Verbose } + LogGroup 'Context' { + Write-Host ($context | Format-List | Out-String) + } + $context | Should -Not -BeNullOrEmpty } # Tests for runners goes here From 2405ea2fb0c7c4549d0a96215ac888603d76b31d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 17:38:15 +0200 Subject: [PATCH 07/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Fix=20formattin?= =?UTF-8?q?g=20in=20GitHubAppInstallation=20and=20update=20output=20displa?= =?UTF-8?q?y=20in=20tests=20to=20use=20Format-List?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/App/GitHubAppInstallation.ps1 | 2 +- tests/GitHub.Tests.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/classes/public/App/GitHubAppInstallation.ps1 b/src/classes/public/App/GitHubAppInstallation.ps1 index 0bcc10ff5..c34c67320 100644 --- a/src/classes/public/App/GitHubAppInstallation.ps1 +++ b/src/classes/public/App/GitHubAppInstallation.ps1 @@ -6,7 +6,7 @@ [GitHubApp] $App # The target of the installation. - [GitHubOwner]$Target + [GitHubOwner] $Target # The type of target. [string] $Type diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 28a8d359b..6aa011662 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -410,7 +410,7 @@ Describe 'Apps' { It 'Get-GitHubAppInstallation - Can get app installations' { $installations = Get-GitHubAppInstallation LogGroup 'Installations' { - Write-Host ($installations | Format-Table | Out-String) + Write-Host ($installations | Format-List | Out-String) } $installations | Should -Not -BeNullOrEmpty } @@ -419,7 +419,7 @@ Describe 'Apps' { $installations | ForEach-Object { $token = New-GitHubAppInstallationAccessToken -InstallationID $_.id LogGroup 'Token' { - Write-Host ($token | Format-Table | Out-String) + Write-Host ($token | Format-List | Out-String) } $token | Should -Not -BeNullOrEmpty } From c579845faeced8df0c1547e6eb8780d113d5b4c1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 17:40:50 +0200 Subject: [PATCH 08/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Improve=20loggi?= =?UTF-8?q?ng=20for=20app=20installation=20access=20tokens=20by=20grouping?= =?UTF-8?q?=20token=20outputs=20in=20a=20single=20log=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 6aa011662..a70cadb77 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -416,9 +416,9 @@ Describe 'Apps' { } It 'New-GitHubAppInstallationAccessToken - Can get app installation access tokens' { $installations = Get-GitHubAppInstallation - $installations | ForEach-Object { - $token = New-GitHubAppInstallationAccessToken -InstallationID $_.id - LogGroup 'Token' { + LogGroup 'Tokens' { + $installations | ForEach-Object { + $token = New-GitHubAppInstallationAccessToken -InstallationID $_.id Write-Host ($token | Format-List | Out-String) } $token | Should -Not -BeNullOrEmpty From 15eb2f4a6b60510b17f1d8c5419f263ed7c0519c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 18:46:35 +0200 Subject: [PATCH 09/25] =?UTF-8?q?=F0=9F=A9=B9=20[Enhancement]:=20Extend=20?= =?UTF-8?q?GitHubApp=20class=20with=20additional=20properties=20and=20upda?= =?UTF-8?q?te=20related=20functions=20to=20return=20GitHubApp=20objects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/App/GitHubApp.ps1 | 50 ++++++++++++++++++- .../Apps/GitHub Apps/Get-GitHubAppByName.ps1 | 4 +- .../Get-GitHubAuthenticatedApp.ps1 | 4 +- tests/GitHub.Tests.ps1 | 43 +++++++++++++++- 4 files changed, 95 insertions(+), 6 deletions(-) diff --git a/src/classes/public/App/GitHubApp.ps1 b/src/classes/public/App/GitHubApp.ps1 index 26049cf6e..bb38ad21f 100644 --- a/src/classes/public/App/GitHubApp.ps1 +++ b/src/classes/public/App/GitHubApp.ps1 @@ -1,4 +1,7 @@ -class GitHubApp { +class GitHubApp : GitHubNode { + # The unique ID of the app + [System.Nullable[UInt64]] $ID + # The Client ID of the app [string] $ClientID @@ -8,11 +11,56 @@ class GitHubApp { # The Slug of the app [string] $Slug + # The node_id of the app + [string] $NodeID + + # The owner of the app. + [GitHubOwner] $Owner + + # The name of the app + [string] $Name + + # The description of the app + [string] $Description + + # The external URL of the app + [string] $ExternalUrl + + # The HTML URL of the app + [string] $Url + + # The creation date of the app + [System.Nullable[datetime]] $CreatedAt + + # The last update date of the app + [System.Nullable[datetime]] $UpdatedAt + + # The permissions that the app is requesting. + [pscustomobject] $Permissions + + # The events that the app is subscribing to on its target. + [string[]] $Events + + # The number of installations + [System.Nullable[int]] $Installations + GitHubApp() {} GitHubApp([object]$Object) { + $this.ID = $Object.id $this.ClientID = $Object.client_id $this.AppID = $Object.app_id $this.Slug = $Object.app_slug ?? $Object.slug + $this.NodeID = $Object.node_id + $this.Owner = [GitHubOwner]::new($Object.owner) + $this.Name = $Object.name + $this.Description = $Object.description + $this.ExternalUrl = $Object.external_url + $this.Url = $Object.html_url + $this.CreatedAt = $Object.created_at + $this.UpdatedAt = $Object.updated_at + $this.Permissions = $Object.permissions + $this.Events = $Object.events + $this.InstallationsCount = $Object.installations_count } } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 index 260e22f78..4cab84652 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 @@ -14,7 +14,7 @@ .NOTES [Get an app](https://docs.github.com/rest/apps/apps#get-an-app) #> - [OutputType([pscustomobject])] + [OutputType([GitHubApp])] [CmdletBinding()] param( # The AppSlug is just the URL-friendly name of a GitHub App. @@ -43,7 +43,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubApp]::new($_.Response) } } end { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index f7f0c4cba..bfa58d061 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -20,7 +20,7 @@ .NOTES [Get the authenticated app](https://docs.github.com/rest/apps/apps#get-an-app) #> - [OutputType([pscustomobject])] + [OutputType([GitHubApp])] [CmdletBinding()] param( # The context to run the command in. Used to get the details for the API call. @@ -42,7 +42,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubApp]::new($_.Response) } } end { diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index a70cadb77..89ea1f3e9 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -397,7 +397,30 @@ Describe 'Apps' { Write-Host ($app | Format-Table | Out-String) } $app | Should -Not -BeNullOrEmpty - } + $app | Should -BeOfType 'GitHubApp' + $app.ID | Should -Not -BeNullOrEmpty + $app.ClientID | Should -Not -BeNullOrEmpty + $app.AppID | Should -Not -BeNullOrEmpty + $app.Slug | Should -Not -BeNullOrEmpty + $app.NodeID | Should -Not -BeNullOrEmpty + $app.Owner | Should -BeOfType 'GitHubOwner' + $app.Name | Should -Not -BeNullOrEmpty + $app.Description | Should -Not -BeNullOrEmpty + $app.ExternalUrl | Should -Not -BeNullOrEmpty + $app.Url | Should -Not -BeNullOrEmpty + $app.CreatedAt | Should -Not -BeNullOrEmpty + $app.UpdatedAt | Should -Not -BeNullOrEmpty + $app.Permissions | Should -Not -BeNullOrEmpty + $app.Events | Should -BeOfType 'Object[]' + $app.Installations | Should -Not -BeNullOrEmpty + } + # It 'Get-GitHubApp - Get an app by slug' { + # $app = Get-GitHubApp -Name 'github-actions' + # LogGroup 'App by slug' { + # Write-Host ($app | Format-Table | Out-String) + # } + # $app | Should -Not -BeNullOrEmpty + # } It 'Get-GitHubAppJSONWebToken - Can get a JWT for the app' { $jwt = Get-GitHubAppJSONWebToken @connectParams @@ -413,6 +436,24 @@ Describe 'Apps' { Write-Host ($installations | Format-List | Out-String) } $installations | Should -Not -BeNullOrEmpty + $githubApp = Get-GitHubApp + foreach ($installation in $installations) { + $installation | Should -BeOfType 'GitHubAppInstallation' + $installation.ID | Should -Not -BeNullOrEmpty + $installation.App | Should -BeOfType 'GitHubApp' + $installation.App.ClientID | Should -Be $githubApp.ClientID + $installation.App.AppID | Should -Not -BeNullOrEmpty + $installation.App.AppSlug | Should -Not -BeNullOrEmpty + $installation.Target | Should -BeOfType 'GitHubOwner' + $installation.Type | Should -Not -BeNullOrEmpty + $installation.RepositorySelection | Should -Not -BeNullOrEmpty + $installation.Permissions | Should -Not -BeNullOrEmpty + $installation.Events | Should -BeOfType 'Object[]' + $installation.CreatedAt | Should -Not -BeNullOrEmpty + $installation.UpdatedAt | Should -Not -BeNullOrEmpty + $installation.SuspendedAt | Should -BeNullOrEmpty + $installation.SuspendedBy | Should -BeOfType 'GitHubUser' + } } It 'New-GitHubAppInstallationAccessToken - Can get app installation access tokens' { $installations = Get-GitHubAppInstallation From 7d542262dde9a5275de603b31a3be86bd0a6487c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 18:48:58 +0200 Subject: [PATCH 10/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Fix=20property?= =?UTF-8?q?=20casing=20for=20GitHub=20App=20attributes=20in=20Set-GitHubCo?= =?UTF-8?q?ntext=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/Context/Set-GitHubContext.ps1 | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index d96d925b5..1a7cf2eb9 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -78,7 +78,7 @@ if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) { try { $app = Get-GitHubApp -Name $contextObj['Username'] -Context $contextObj - $contextObj['DisplayName'] = [string]$app.name + $contextObj['DisplayName'] = [string]$app.Name } catch { Write-Debug "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." } @@ -122,15 +122,15 @@ } 'App' { $app = Get-GitHubApp -Context $contextObj - $contextObj['Name'] = "$($contextObj['HostName'])/$($app.slug)" - $contextObj['DisplayName'] = [string]$app.name - $contextObj['Username'] = [string]$app.slug - $contextObj['NodeID'] = [string]$app.node_id - $contextObj['DatabaseID'] = [string]$app.id - $contextObj['Permissions'] = [PSCustomObject]$app.permissions - $contextObj['Events'] = [string[]]$app.events - $contextObj['OwnerName'] = [string]$app.owner.login - $contextObj['OwnerType'] = [string]$app.owner.type + $contextObj['Name'] = "$($contextObj['HostName'])/$($app.Slug)" + $contextObj['DisplayName'] = [string]$app.Name + $contextObj['Username'] = [string]$app.Slug + $contextObj['NodeID'] = [string]$app.NodeID + $contextObj['DatabaseID'] = [string]$app.ID + $contextObj['Permissions'] = [PSCustomObject]$app.Permissions + $contextObj['Events'] = [string[]]$app.Events + $contextObj['OwnerName'] = [string]$app.Owner.Name + $contextObj['OwnerType'] = [string]$app.Owner.Type $contextObj['Type'] = 'App' } default { From 68f76bcfaff255b1c5f6727f1beee6e173d9a5f1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 19:29:15 +0200 Subject: [PATCH 11/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20Instal?= =?UTF-8?q?lationsCount=20property=20to=20Installations=20for=20consistenc?= =?UTF-8?q?y=20in=20GitHubApp=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/App/GitHubApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/public/App/GitHubApp.ps1 b/src/classes/public/App/GitHubApp.ps1 index bb38ad21f..87748aef1 100644 --- a/src/classes/public/App/GitHubApp.ps1 +++ b/src/classes/public/App/GitHubApp.ps1 @@ -61,6 +61,6 @@ class GitHubApp : GitHubNode { $this.UpdatedAt = $Object.updated_at $this.Permissions = $Object.permissions $this.Events = $Object.events - $this.InstallationsCount = $Object.installations_count + $this.Installations = $Object.installations_count } } From 95e2260a19473bb782ba5b13083e633aa5049b65 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 19:31:01 +0200 Subject: [PATCH 12/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20parame?= =?UTF-8?q?ter=20set=20names=20for=20consistency=20in=20Get-GitHubApp=20fu?= =?UTF-8?q?nction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 index f675e0163..6e678b585 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 @@ -24,16 +24,16 @@ https://psmodule.io/GitHub/Functions/Apps/GitHub%20App/Get-GitHubApp #> [OutputType([pscustomobject])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding(DefaultParameterSetName = 'Get the authenticated app')] param( # The AppSlug is just the URL-friendly name of a GitHub App. # You can find this on the settings page for your GitHub App (e.g., ). # Example: 'github-actions' [Parameter( Mandatory, - ParameterSetName = 'BySlug' + ParameterSetName = 'Get an app by slug' )] - [Alias('AppSlug')] + [Alias('AppSlug', 'Slug')] [string] $Name, # The context to run the command in. Used to get the details for the API call. @@ -50,7 +50,7 @@ process { switch ($PSCmdlet.ParameterSetName) { - 'BySlug' { + 'Get an app by slug' { Get-GitHubAppByName -AppSlug $Name -Context $Context } default { From 2b1077b9f51150a50ec460037e6e6a7a2b963ab9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 19:34:06 +0200 Subject: [PATCH 13/25] =?UTF-8?q?=F0=9F=A9=B9=20[Enhancement]:=20Refactor?= =?UTF-8?q?=20GitHub=20configuration=20and=20event=20data=20tests=20to=20u?= =?UTF-8?q?se=20LogGroup=20for=20better=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/GitHub.Tests.ps1 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 89ea1f3e9..63f6becb2 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -138,8 +138,10 @@ Describe 'Auth' { Describe 'GitHub' { Context 'Config' { It 'Get-GitHubConfig - Gets the module configuration' { - $config = Get-GitHubConfig - Write-Host ($config | Format-Table | Out-String) + LogGroup 'Config' { + $config = Get-GitHubConfig + Write-Host ($config | Format-List | Out-String) + } $config | Should -Not -BeNullOrEmpty } It 'Get-GitHubConfig - Gets a configuration item by name' { @@ -166,14 +168,18 @@ Describe 'GitHub' { } Context 'Actions' { It 'Get-GitHubEventData - Gets data about the event that triggered the workflow' { - $workflow = Get-GitHubEventData - Write-Host ($workflow | Format-List | Out-String) - $workflow | Should -Not -BeNullOrEmpty + LogGroup 'Event Data' { + $eventData = Get-GitHubEventData + Write-Host ($eventData | Format-List | Out-String) + } + $eventData | Should -Not -BeNullOrEmpty } It 'Get-GitHubRunnerData - Gets data about the runner that is running the workflow' { - $workflow = Get-GitHubRunnerData - Write-Host ($workflow | Format-List | Out-String) - $workflow | Should -Not -BeNullOrEmpty + LogGroup 'Runner Data' { + $runnerData = Get-GitHubRunnerData + Write-Host ($runnerData | Format-List | Out-String) + } + $runnerData | Should -Not -BeNullOrEmpty } } Context 'Status' -ForEach @('Public', 'Europe', 'Australia') { From 48e964a364a0630065931180f3d557982ad3ab75 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 19:52:00 +0200 Subject: [PATCH 14/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20AppID?= =?UTF-8?q?=20null=20check=20from=20GitHubApp=20tests=20and=20update=20log?= =?UTF-8?q?ging=20format=20for=20installations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/GitHub.Tests.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 63f6becb2..ec44cdba2 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -406,7 +406,6 @@ Describe 'Apps' { $app | Should -BeOfType 'GitHubApp' $app.ID | Should -Not -BeNullOrEmpty $app.ClientID | Should -Not -BeNullOrEmpty - $app.AppID | Should -Not -BeNullOrEmpty $app.Slug | Should -Not -BeNullOrEmpty $app.NodeID | Should -Not -BeNullOrEmpty $app.Owner | Should -BeOfType 'GitHubOwner' @@ -439,7 +438,7 @@ Describe 'Apps' { It 'Get-GitHubAppInstallation - Can get app installations' { $installations = Get-GitHubAppInstallation LogGroup 'Installations' { - Write-Host ($installations | Format-List | Out-String) + Write-Host ($installations | Format-Table | Out-String) } $installations | Should -Not -BeNullOrEmpty $githubApp = Get-GitHubApp From 12398fff45316c680b57d3b4757201a5dc284f85 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 20:33:39 +0200 Subject: [PATCH 15/25] =?UTF-8?q?=F0=9F=A9=B9=20[Enhancement]:=20Update=20?= =?UTF-8?q?event=20handling=20in=20GitHubApp=20class=20and=20improve=20out?= =?UTF-8?q?put=20formatting=20in=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/App/GitHubApp.ps1 | 2 +- tests/GitHub.Tests.ps1 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/classes/public/App/GitHubApp.ps1 b/src/classes/public/App/GitHubApp.ps1 index 87748aef1..eed305708 100644 --- a/src/classes/public/App/GitHubApp.ps1 +++ b/src/classes/public/App/GitHubApp.ps1 @@ -60,7 +60,7 @@ class GitHubApp : GitHubNode { $this.CreatedAt = $Object.created_at $this.UpdatedAt = $Object.updated_at $this.Permissions = $Object.permissions - $this.Events = $Object.events + $this.Events = @($Object.events) $this.Installations = $Object.installations_count } } diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index ec44cdba2..b392c085e 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -400,7 +400,7 @@ Describe 'Apps' { It 'Get-GitHubApp - Can get app details' { $app = Get-GitHubApp LogGroup 'App' { - Write-Host ($app | Format-Table | Out-String) + Write-Host ($app | Format-List | Out-String) } $app | Should -Not -BeNullOrEmpty $app | Should -BeOfType 'GitHubApp' @@ -438,7 +438,7 @@ Describe 'Apps' { It 'Get-GitHubAppInstallation - Can get app installations' { $installations = Get-GitHubAppInstallation LogGroup 'Installations' { - Write-Host ($installations | Format-Table | Out-String) + Write-Host ($installations | Format-List | Out-String) } $installations | Should -Not -BeNullOrEmpty $githubApp = Get-GitHubApp @@ -448,7 +448,7 @@ Describe 'Apps' { $installation.App | Should -BeOfType 'GitHubApp' $installation.App.ClientID | Should -Be $githubApp.ClientID $installation.App.AppID | Should -Not -BeNullOrEmpty - $installation.App.AppSlug | Should -Not -BeNullOrEmpty + $installation.App.Slug | Should -Not -BeNullOrEmpty $installation.Target | Should -BeOfType 'GitHubOwner' $installation.Type | Should -Not -BeNullOrEmpty $installation.RepositorySelection | Should -Not -BeNullOrEmpty From 83ecd8cce454bb8d22d8a21baeb71be85bd19e69 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 20:50:55 +0200 Subject: [PATCH 16/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20event?= =?UTF-8?q?=20assignment=20in=20GitHubApp=20constructor=20for=20consistent?= =?UTF-8?q?=20array=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/App/GitHubApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/public/App/GitHubApp.ps1 b/src/classes/public/App/GitHubApp.ps1 index eed305708..31b258055 100644 --- a/src/classes/public/App/GitHubApp.ps1 +++ b/src/classes/public/App/GitHubApp.ps1 @@ -60,7 +60,7 @@ class GitHubApp : GitHubNode { $this.CreatedAt = $Object.created_at $this.UpdatedAt = $Object.updated_at $this.Permissions = $Object.permissions - $this.Events = @($Object.events) + $this.Events = ,($Object.events) $this.Installations = $Object.installations_count } } From d38be5c724e4ca1f6fd6f5a159bee64e628dfee3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 21:00:03 +0200 Subject: [PATCH 17/25] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Adjust=20event=20?= =?UTF-8?q?assignment=20in=20GitHubApp=20and=20GitHubAppInstallation=20con?= =?UTF-8?q?structors=20for=20consistent=20array=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/App/GitHubApp.ps1 | 2 +- src/classes/public/App/GitHubAppInstallation.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classes/public/App/GitHubApp.ps1 b/src/classes/public/App/GitHubApp.ps1 index 31b258055..f570eabce 100644 --- a/src/classes/public/App/GitHubApp.ps1 +++ b/src/classes/public/App/GitHubApp.ps1 @@ -60,7 +60,7 @@ class GitHubApp : GitHubNode { $this.CreatedAt = $Object.created_at $this.UpdatedAt = $Object.updated_at $this.Permissions = $Object.permissions - $this.Events = ,($Object.events) + $this.Events = , ($Object.events) $this.Installations = $Object.installations_count } } diff --git a/src/classes/public/App/GitHubAppInstallation.ps1 b/src/classes/public/App/GitHubAppInstallation.ps1 index c34c67320..6684d77f4 100644 --- a/src/classes/public/App/GitHubAppInstallation.ps1 +++ b/src/classes/public/App/GitHubAppInstallation.ps1 @@ -53,7 +53,7 @@ $this.Type = $Object.target_type $this.RepositorySelection = $Object.repository_selection $this.Permissions = $Object.permissions - $this.Events = $Object.events + $this.Events = , ($Object.events) $this.FilePaths = $Object.single_file_paths $this.CreatedAt = $Object.created_at $this.UpdatedAt = $Object.updated_at From 1347edbd7a7c974fcdf9bc97c18fd0ed16c148bd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 21:24:30 +0200 Subject: [PATCH 18/25] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20type?= =?UTF-8?q?=20assertions=20for=20Permissions=20and=20Events=20in=20Apps=20?= =?UTF-8?q?tests=20to=20ensure=20correct=20data=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/GitHub.Tests.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index b392c085e..c037f25b3 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -415,8 +415,8 @@ Describe 'Apps' { $app.Url | Should -Not -BeNullOrEmpty $app.CreatedAt | Should -Not -BeNullOrEmpty $app.UpdatedAt | Should -Not -BeNullOrEmpty - $app.Permissions | Should -Not -BeNullOrEmpty - $app.Events | Should -BeOfType 'Object[]' + $app.Permissions | Should -BeOfType 'PSCustomObject' + $app.Events | Should -BeOfType 'string' $app.Installations | Should -Not -BeNullOrEmpty } # It 'Get-GitHubApp - Get an app by slug' { @@ -452,8 +452,8 @@ Describe 'Apps' { $installation.Target | Should -BeOfType 'GitHubOwner' $installation.Type | Should -Not -BeNullOrEmpty $installation.RepositorySelection | Should -Not -BeNullOrEmpty - $installation.Permissions | Should -Not -BeNullOrEmpty - $installation.Events | Should -BeOfType 'Object[]' + $installation.Permissions | Should -BeOfType 'PSCustomObject' + $installation.Events | Should -BeOfType 'string' $installation.CreatedAt | Should -Not -BeNullOrEmpty $installation.UpdatedAt | Should -Not -BeNullOrEmpty $installation.SuspendedAt | Should -BeNullOrEmpty From c62f342ff3ea4b7bcc676dca89f5b4910ea5be6d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 21:50:53 +0200 Subject: [PATCH 19/25] Add initial test scripts for GitHub API interactions - Created TEMPLATE.ps1 for structuring Pester tests with authentication cases. - Added Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion. - Introduced Users.Tests.ps1 to validate user-related API calls such as user retrieval and updates. - Implemented Variables.Tests.ps1 to manage GitHub repository and organization variables, including creation, updating, and deletion of variables. --- {tests copy => tests}/Artifacts.Tests.ps1 | 0 {tests copy => tests}/Environments.Tests.ps1 | 0 {tests copy => tests}/Organizations.Tests.ps1 | 0 {tests copy => tests}/README.md | 0 {tests copy => tests}/Releases.Tests.ps1 | 0 {tests copy => tests}/Repositories.Tests.ps1 | 0 {tests copy => tests}/Secrets.Tests.ps1 | 0 {tests copy => tests}/TEMPLATE.ps1 | 0 {tests copy => tests}/Teams.Tests.ps1 | 0 {tests copy => tests}/Users.Tests.ps1 | 0 {tests copy => tests}/Variables.Tests.ps1 | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename {tests copy => tests}/Artifacts.Tests.ps1 (100%) rename {tests copy => tests}/Environments.Tests.ps1 (100%) rename {tests copy => tests}/Organizations.Tests.ps1 (100%) rename {tests copy => tests}/README.md (100%) rename {tests copy => tests}/Releases.Tests.ps1 (100%) rename {tests copy => tests}/Repositories.Tests.ps1 (100%) rename {tests copy => tests}/Secrets.Tests.ps1 (100%) rename {tests copy => tests}/TEMPLATE.ps1 (100%) rename {tests copy => tests}/Teams.Tests.ps1 (100%) rename {tests copy => tests}/Users.Tests.ps1 (100%) rename {tests copy => tests}/Variables.Tests.ps1 (100%) diff --git a/tests copy/Artifacts.Tests.ps1 b/tests/Artifacts.Tests.ps1 similarity index 100% rename from tests copy/Artifacts.Tests.ps1 rename to tests/Artifacts.Tests.ps1 diff --git a/tests copy/Environments.Tests.ps1 b/tests/Environments.Tests.ps1 similarity index 100% rename from tests copy/Environments.Tests.ps1 rename to tests/Environments.Tests.ps1 diff --git a/tests copy/Organizations.Tests.ps1 b/tests/Organizations.Tests.ps1 similarity index 100% rename from tests copy/Organizations.Tests.ps1 rename to tests/Organizations.Tests.ps1 diff --git a/tests copy/README.md b/tests/README.md similarity index 100% rename from tests copy/README.md rename to tests/README.md diff --git a/tests copy/Releases.Tests.ps1 b/tests/Releases.Tests.ps1 similarity index 100% rename from tests copy/Releases.Tests.ps1 rename to tests/Releases.Tests.ps1 diff --git a/tests copy/Repositories.Tests.ps1 b/tests/Repositories.Tests.ps1 similarity index 100% rename from tests copy/Repositories.Tests.ps1 rename to tests/Repositories.Tests.ps1 diff --git a/tests copy/Secrets.Tests.ps1 b/tests/Secrets.Tests.ps1 similarity index 100% rename from tests copy/Secrets.Tests.ps1 rename to tests/Secrets.Tests.ps1 diff --git a/tests copy/TEMPLATE.ps1 b/tests/TEMPLATE.ps1 similarity index 100% rename from tests copy/TEMPLATE.ps1 rename to tests/TEMPLATE.ps1 diff --git a/tests copy/Teams.Tests.ps1 b/tests/Teams.Tests.ps1 similarity index 100% rename from tests copy/Teams.Tests.ps1 rename to tests/Teams.Tests.ps1 diff --git a/tests copy/Users.Tests.ps1 b/tests/Users.Tests.ps1 similarity index 100% rename from tests copy/Users.Tests.ps1 rename to tests/Users.Tests.ps1 diff --git a/tests copy/Variables.Tests.ps1 b/tests/Variables.Tests.ps1 similarity index 100% rename from tests copy/Variables.Tests.ps1 rename to tests/Variables.Tests.ps1 From 18ea81697a8d59089b2f4d2fa5cd175473b556b6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Jun 2025 21:54:15 +0200 Subject: [PATCH 20/25] =?UTF-8?q?=F0=9F=A9=B9=20[Cleanup]:=20Remove=20unne?= =?UTF-8?q?cessary=20skip=20configurations=20from=20PSModule.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PSModule.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/PSModule.yml b/.github/PSModule.yml index 3440fd2ac..6d578178e 100644 --- a/.github/PSModule.yml +++ b/.github/PSModule.yml @@ -1,18 +1,3 @@ -Build: - Docs: - Skip: true Test: - SourceCode: - Skip: true - PSModule: - Skip: true - Module: - Windows: - Skip: true - MacOS: - Skip: true CodeCoverage: - Skip: true PercentTarget: 50 - TestResults: - Skip: true From 32e24b908ad201f8b3b067a69b3a4e2e2740169f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 11 Jun 2025 21:32:26 +0200 Subject: [PATCH 21/25] asd --- {tests => test2}/Artifacts.Tests.ps1 | 0 {tests => test2}/Environments.Tests.ps1 | 0 {tests => test2}/GitHub.Tests.ps1 | 0 {tests => test2}/Organizations.Tests.ps1 | 0 {tests => test2}/README.md | 0 {tests => test2}/Releases.Tests.ps1 | 0 {tests => test2}/Repositories.Tests.ps1 | 0 {tests => test2}/Secrets.Tests.ps1 | 0 {tests => test2}/TEMPLATE.ps1 | 0 {tests => test2}/Teams.Tests.ps1 | 0 {tests => test2}/Users.Tests.ps1 | 0 tests/Variables.Tests.ps1 | 10 ++++++++-- 12 files changed, 8 insertions(+), 2 deletions(-) rename {tests => test2}/Artifacts.Tests.ps1 (100%) rename {tests => test2}/Environments.Tests.ps1 (100%) rename {tests => test2}/GitHub.Tests.ps1 (100%) rename {tests => test2}/Organizations.Tests.ps1 (100%) rename {tests => test2}/README.md (100%) rename {tests => test2}/Releases.Tests.ps1 (100%) rename {tests => test2}/Repositories.Tests.ps1 (100%) rename {tests => test2}/Secrets.Tests.ps1 (100%) rename {tests => test2}/TEMPLATE.ps1 (100%) rename {tests => test2}/Teams.Tests.ps1 (100%) rename {tests => test2}/Users.Tests.ps1 (100%) diff --git a/tests/Artifacts.Tests.ps1 b/test2/Artifacts.Tests.ps1 similarity index 100% rename from tests/Artifacts.Tests.ps1 rename to test2/Artifacts.Tests.ps1 diff --git a/tests/Environments.Tests.ps1 b/test2/Environments.Tests.ps1 similarity index 100% rename from tests/Environments.Tests.ps1 rename to test2/Environments.Tests.ps1 diff --git a/tests/GitHub.Tests.ps1 b/test2/GitHub.Tests.ps1 similarity index 100% rename from tests/GitHub.Tests.ps1 rename to test2/GitHub.Tests.ps1 diff --git a/tests/Organizations.Tests.ps1 b/test2/Organizations.Tests.ps1 similarity index 100% rename from tests/Organizations.Tests.ps1 rename to test2/Organizations.Tests.ps1 diff --git a/tests/README.md b/test2/README.md similarity index 100% rename from tests/README.md rename to test2/README.md diff --git a/tests/Releases.Tests.ps1 b/test2/Releases.Tests.ps1 similarity index 100% rename from tests/Releases.Tests.ps1 rename to test2/Releases.Tests.ps1 diff --git a/tests/Repositories.Tests.ps1 b/test2/Repositories.Tests.ps1 similarity index 100% rename from tests/Repositories.Tests.ps1 rename to test2/Repositories.Tests.ps1 diff --git a/tests/Secrets.Tests.ps1 b/test2/Secrets.Tests.ps1 similarity index 100% rename from tests/Secrets.Tests.ps1 rename to test2/Secrets.Tests.ps1 diff --git a/tests/TEMPLATE.ps1 b/test2/TEMPLATE.ps1 similarity index 100% rename from tests/TEMPLATE.ps1 rename to test2/TEMPLATE.ps1 diff --git a/tests/Teams.Tests.ps1 b/test2/Teams.Tests.ps1 similarity index 100% rename from tests/Teams.Tests.ps1 rename to test2/Teams.Tests.ps1 diff --git a/tests/Users.Tests.ps1 b/test2/Users.Tests.ps1 similarity index 100% rename from tests/Users.Tests.ps1 rename to test2/Users.Tests.ps1 diff --git a/tests/Variables.Tests.ps1 b/tests/Variables.Tests.ps1 index d6a3da75a..5970b6c5a 100644 --- a/tests/Variables.Tests.ps1 +++ b/tests/Variables.Tests.ps1 @@ -30,13 +30,19 @@ Describe 'Variables' { Context 'As using on ' -ForEach $authCases { BeforeAll { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent + $context = Connect-GitHubAccount @connectParams -PassThru -Silent -Debug -Verbose + LogGroup "Current Contexts" { + Write-Host (Get-GitHubContext -ListAvailable | Format-List | Out-String) + } LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } if ($AuthType -eq 'APP') { + LogGroup "Current Contexts" { + Write-Host (Get-GitHubContext -ListAvailable | Format-List | Out-String) + } LogGroup 'Context - Installation' { - $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent + $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent -Debug -Verbose Write-Host ($context | Format-List | Out-String) } } From 0c50725f09188a5a91a255c0d8f0895ed02a1c36 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 11 Jun 2025 21:58:15 +0200 Subject: [PATCH 22/25] qwe --- tests/Variables.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Variables.Tests.ps1 b/tests/Variables.Tests.ps1 index 5970b6c5a..d210ddee9 100644 --- a/tests/Variables.Tests.ps1 +++ b/tests/Variables.Tests.ps1 @@ -30,8 +30,8 @@ Describe 'Variables' { Context 'As using on ' -ForEach $authCases { BeforeAll { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent -Debug -Verbose LogGroup "Current Contexts" { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent -Debug -Verbose Write-Host (Get-GitHubContext -ListAvailable | Format-List | Out-String) } LogGroup 'Context' { From b8b7770393607a6aa21a4ad3d40ad05e52836f44 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 12 Jun 2025 09:19:37 +0200 Subject: [PATCH 23/25] asd --- src/functions/public/Auth/Connect-GitHubApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 9961fb11d..dd11923d2 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -109,7 +109,7 @@ $enterpriseItem = $_ Write-Verbose "Enterprise filter: [$enterpriseItem]." $selectedInstallations += $installations | Where-Object { - $_.Type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem + $_.Type -eq 'Enterprise' -and $_.Target.Name -like $enterpriseItem } } } From bc80b485848415e16ea360e997121e3696c6f07d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 12 Jun 2025 11:28:16 +0200 Subject: [PATCH 24/25] wqer --- .../GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 | 4 ++++ .../Get-GitHubAppInstallationForAuthenticatedApp.ps1 | 3 +++ .../Get-GitHubAppAccessibleRepository.ps1 | 9 ++++++++- {test2 => tests}/Artifacts.Tests.ps1 | 0 {test2 => tests}/Environments.Tests.ps1 | 0 {test2 => tests}/GitHub.Tests.ps1 | 0 {test2 => tests}/Organizations.Tests.ps1 | 0 {test2 => tests}/README.md | 0 {test2 => tests}/Releases.Tests.ps1 | 0 {test2 => tests}/Repositories.Tests.ps1 | 0 {test2 => tests}/Secrets.Tests.ps1 | 0 {test2 => tests}/TEMPLATE.ps1 | 0 {test2 => tests}/Teams.Tests.ps1 | 0 {test2 => tests}/Users.Tests.ps1 | 0 14 files changed, 15 insertions(+), 1 deletion(-) rename {test2 => tests}/Artifacts.Tests.ps1 (100%) rename {test2 => tests}/Environments.Tests.ps1 (100%) rename {test2 => tests}/GitHub.Tests.ps1 (100%) rename {test2 => tests}/Organizations.Tests.ps1 (100%) rename {test2 => tests}/README.md (100%) rename {test2 => tests}/Releases.Tests.ps1 (100%) rename {test2 => tests}/Repositories.Tests.ps1 (100%) rename {test2 => tests}/Secrets.Tests.ps1 (100%) rename {test2 => tests}/TEMPLATE.ps1 (100%) rename {test2 => tests}/Teams.Tests.ps1 (100%) rename {test2 => tests}/Users.Tests.ps1 (100%) diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 index a53e7eca8..c179a6a3f 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 @@ -13,9 +13,13 @@ .EXAMPLE Get-GitHubAppInstallableOrganization -Enterprise 'msx' + .OUTPUTS + GitHubOrganization[] + .LINK https://psmodule.io/GitHub/Functions/Apps/GitHub%20App/Get-GitHubAppInstallableOrganization #> + [OutputType([GitHubOrganization[]])] [CmdletBinding()] param( # The enterprise slug or ID. diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 33d667d93..c7e3c6d1b 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -14,6 +14,9 @@ List installations for the authenticated app. + .OUTPUTS + GitHubAppInstallation[] + .NOTES [List installations for the authenticated app](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app) #> diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 index 4cee89486..133976f18 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 @@ -19,9 +19,16 @@ Get the repositories that can be made accessible to a GitHub App installed on the organization 'PSModule' in the enterprise 'msx'. + .OUTPUTS + GitHubRepository[] + .LINK https://psmodule.io/GitHub/Functions/Apps/GitHub%20App%20Installations/Get-GitHubAppAccessibleRepository + + .NOTES + #> + [OutputType([GitHubRepository[]])] [CmdletBinding(SupportsShouldProcess)] param( # The enterprise slug or ID. @@ -65,7 +72,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubRepository]::($_.Response) } } diff --git a/test2/Artifacts.Tests.ps1 b/tests/Artifacts.Tests.ps1 similarity index 100% rename from test2/Artifacts.Tests.ps1 rename to tests/Artifacts.Tests.ps1 diff --git a/test2/Environments.Tests.ps1 b/tests/Environments.Tests.ps1 similarity index 100% rename from test2/Environments.Tests.ps1 rename to tests/Environments.Tests.ps1 diff --git a/test2/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 similarity index 100% rename from test2/GitHub.Tests.ps1 rename to tests/GitHub.Tests.ps1 diff --git a/test2/Organizations.Tests.ps1 b/tests/Organizations.Tests.ps1 similarity index 100% rename from test2/Organizations.Tests.ps1 rename to tests/Organizations.Tests.ps1 diff --git a/test2/README.md b/tests/README.md similarity index 100% rename from test2/README.md rename to tests/README.md diff --git a/test2/Releases.Tests.ps1 b/tests/Releases.Tests.ps1 similarity index 100% rename from test2/Releases.Tests.ps1 rename to tests/Releases.Tests.ps1 diff --git a/test2/Repositories.Tests.ps1 b/tests/Repositories.Tests.ps1 similarity index 100% rename from test2/Repositories.Tests.ps1 rename to tests/Repositories.Tests.ps1 diff --git a/test2/Secrets.Tests.ps1 b/tests/Secrets.Tests.ps1 similarity index 100% rename from test2/Secrets.Tests.ps1 rename to tests/Secrets.Tests.ps1 diff --git a/test2/TEMPLATE.ps1 b/tests/TEMPLATE.ps1 similarity index 100% rename from test2/TEMPLATE.ps1 rename to tests/TEMPLATE.ps1 diff --git a/test2/Teams.Tests.ps1 b/tests/Teams.Tests.ps1 similarity index 100% rename from test2/Teams.Tests.ps1 rename to tests/Teams.Tests.ps1 diff --git a/test2/Users.Tests.ps1 b/tests/Users.Tests.ps1 similarity index 100% rename from test2/Users.Tests.ps1 rename to tests/Users.Tests.ps1 From 1067c4fb97650dd3a6542fa87de71545d6f20e84 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 12 Jun 2025 13:12:33 +0200 Subject: [PATCH 25/25] Fix debug --- examples/Apps/EnterpriseApps.ps1 | 4 ++-- tests/GitHub.Tests.ps1 | 6 +++--- tests/Variables.Tests.ps1 | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 index fc45e5692..2526b7b2d 100644 --- a/examples/Apps/EnterpriseApps.ps1 +++ b/examples/Apps/EnterpriseApps.ps1 @@ -20,7 +20,7 @@ filter Install-GithubApp { ) process { - $installableOrgs = Get-GitHubOrganization -Enterprise $Enterprise -Debug -Verbose + $installableOrgs = Get-GitHubOrganization -Enterprise $Enterprise $orgs = $installableOrgs | Where-Object { $_.login -like $organization } foreach ($org in $orgs) { foreach ($appIDitem in $AppID) { @@ -35,6 +35,6 @@ filter Install-GithubApp { } } -$appIDs | Install-GitHubApp -Organization $organization -Debug -Verbose +$appIDs | Install-GitHubApp -Organization $organization $installation = Get-GitHubAppInstallation diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index c037f25b3..82964fea3 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -63,7 +63,7 @@ Describe 'Auth' { It 'Connect-GitHubAccount - Connects using the provided credentials + AutoloadInstallations' -Skip:($AuthType -ne 'APP') { LogGroup 'Connect-Github' { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent -AutoloadInstallations -Debug -Verbose + $context = Connect-GitHubAccount @connectParams -PassThru -Silent -AutoloadInstallations } LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) @@ -73,7 +73,7 @@ Describe 'Auth' { It 'Connect-GitHubApp - Connects as a GitHub App to ' -Skip:($AuthType -ne 'APP') { LogGroup 'Connect-GithubApp' { - $contexts = Connect-GitHubApp -PassThru -Silent -Debug -Verbose + $contexts = Connect-GitHubApp -PassThru -Silent } LogGroup 'Contexts' { Write-Host ($contexts | Format-List | Out-String) @@ -83,7 +83,7 @@ Describe 'Auth' { It 'Connect-GitHubApp - Connects as a GitHub App to ' -Skip:($AuthType -ne 'APP') { LogGroup 'Connect-GithubApp' { - $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent -Debug -Verbose + $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent } LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) diff --git a/tests/Variables.Tests.ps1 b/tests/Variables.Tests.ps1 index d210ddee9..41107a50a 100644 --- a/tests/Variables.Tests.ps1 +++ b/tests/Variables.Tests.ps1 @@ -30,19 +30,19 @@ Describe 'Variables' { Context 'As using on ' -ForEach $authCases { BeforeAll { - LogGroup "Current Contexts" { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent -Debug -Verbose + LogGroup 'Current Contexts' { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent Write-Host (Get-GitHubContext -ListAvailable | Format-List | Out-String) } LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } if ($AuthType -eq 'APP') { - LogGroup "Current Contexts" { + LogGroup 'Current Contexts' { Write-Host (Get-GitHubContext -ListAvailable | Format-List | Out-String) } LogGroup 'Context - Installation' { - $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent -Debug -Verbose + $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent Write-Host ($context | Format-List | Out-String) } }