From 7a5c139d3968112d319fcf88a68b614d57d8cefb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 17:52:33 +0000 Subject: [PATCH 01/20] Initial plan From 85fd3afda1fc33684a434ccd9db759d0e5fb84d9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 17:59:55 +0000 Subject: [PATCH 02/20] Modify types and format to display Unknown for PAT tokens Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- src/formats/GitHubContext.Format.ps1xml | 2 +- src/types/GitHubContext.Types.ps1xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/formats/GitHubContext.Format.ps1xml b/src/formats/GitHubContext.Format.ps1xml index 45756fbb5..ea52e2049 100644 --- a/src/formats/GitHubContext.Format.ps1xml +++ b/src/formats/GitHubContext.Format.ps1xml @@ -55,7 +55,7 @@ if ($null -eq $_.TokenExpiresIn) { - return + return 'Unknown' } if ($_.TokenExpiresIn -le 0) { diff --git a/src/types/GitHubContext.Types.ps1xml b/src/types/GitHubContext.Types.ps1xml index d30c41a11..381c40693 100644 --- a/src/types/GitHubContext.Types.ps1xml +++ b/src/types/GitHubContext.Types.ps1xml @@ -6,14 +6,14 @@ TokenExpiresIn - if ($null -eq $this.TokenExpiresAt) { return [TimeSpan]::Zero } + if ($null -eq $this.TokenExpiresAt) { return $null } $this.TokenExpiresAt - [DateTime]::Now RefreshTokenExpiresIn - if ($null -eq $this.RefreshTokenExpiresAt) { return [TimeSpan]::Zero } + if ($null -eq $this.RefreshTokenExpiresAt) { return $null } $this.RefreshTokenExpiresAt - [DateTime]::Now @@ -25,7 +25,7 @@ TokenExpiresIn - if ($null -eq $this.TokenExpiresAt) { return [TimeSpan]::Zero } + if ($null -eq $this.TokenExpiresAt) { return $null } $this.TokenExpiresAt - [DateTime]::Now @@ -37,7 +37,7 @@ TokenExpiresIn - if ($null -eq $this.TokenExpiresAt) { return [TimeSpan]::Zero } + if ($null -eq $this.TokenExpiresAt) { return $null } $this.TokenExpiresAt - [DateTime]::Now From 55834ee8ee059923dab9d0f5e4facd1ffda8579f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 18:19:11 +0000 Subject: [PATCH 03/20] Add tests for TokenExpiresIn behavior for PAT and IAT tokens Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 9a7c69a17..e690bf21f 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -45,6 +45,18 @@ Describe 'Auth' { $context | Should -Not -BeNullOrEmpty } + It 'Connect-GitHubAccount - TokenExpiresIn should be null for PAT tokens' -Skip:($AuthType -ne 'PAT') { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent + $context.TokenExpiresAt | Should -BeNullOrEmpty + $context.TokenExpiresIn | Should -BeNullOrEmpty + } + + It 'Connect-GitHubAccount - TokenExpiresIn should be set for IAT tokens' -Skip:($AuthType -ne 'IAT') { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent + $context.TokenExpiresAt | Should -BeOfType [DateTime] + $context.TokenExpiresIn | Should -BeOfType [TimeSpan] + } + It 'Connect-GitHubAccount - Connects using the provided credentials - Double' { $context = Connect-GitHubAccount @connectParams -PassThru -Silent $context = Connect-GitHubAccount @connectParams -PassThru -Silent From 41e27c8f82f9f64e146ce69a8341a7bafa95a21f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 19:53:17 +0000 Subject: [PATCH 04/20] Fix test to handle GITHUB_TOKEN without expiration Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- 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 e690bf21f..12e6923df 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -51,10 +51,10 @@ Describe 'Auth' { $context.TokenExpiresIn | Should -BeNullOrEmpty } - It 'Connect-GitHubAccount - TokenExpiresIn should be set for IAT tokens' -Skip:($AuthType -ne 'IAT') { + It 'Connect-GitHubAccount - TokenExpiresIn should be null for GITHUB_TOKEN (IAT)' -Skip:($TokenType -ne 'GITHUB_TOKEN') { $context = Connect-GitHubAccount @connectParams -PassThru -Silent - $context.TokenExpiresAt | Should -BeOfType [DateTime] - $context.TokenExpiresIn | Should -BeOfType [TimeSpan] + $context.TokenExpiresAt | Should -BeNullOrEmpty + $context.TokenExpiresIn | Should -BeNullOrEmpty } It 'Connect-GitHubAccount - Connects using the provided credentials - Double' { From 5aabf79c5bd0e63dee39770df21056544efacc43 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 20:32:22 +0000 Subject: [PATCH 05/20] Add comprehensive test coverage for all token types Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 12e6923df..9d33fa19f 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -45,6 +45,12 @@ Describe 'Auth' { $context | Should -Not -BeNullOrEmpty } + # Token expiration tests: + # - PAT tokens (classic and fine-grained): No expiration metadata + # - GITHUB_TOKEN (IAT): No expiration metadata + # - GitHub App Installation tokens (IAT from Connect-GitHubApp): Has expiration metadata + # - GitHub App tokens (JWT): Has expiration metadata + It 'Connect-GitHubAccount - TokenExpiresIn should be null for PAT tokens' -Skip:($AuthType -ne 'PAT') { $context = Connect-GitHubAccount @connectParams -PassThru -Silent $context.TokenExpiresAt | Should -BeNullOrEmpty @@ -129,6 +135,15 @@ Describe 'Auth' { $context | Should -Not -BeNullOrEmpty } + It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { + $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent + # GitHub App Installation tokens (IAT) created by Connect-GitHubApp should have expiration metadata + $context.AuthType | Should -Be 'IAT' + $context.TokenExpiresAt | Should -BeOfType [DateTime] + $context.TokenExpiresIn | Should -BeOfType [TimeSpan] + $context.TokenExpiresIn.TotalMinutes | Should -BeGreaterThan 0 + } + # Tests for runners goes here if ($Type -eq 'GitHub Actions') {} From ece59614a048faf6a1282a8adcea633934b001ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 20:33:50 +0000 Subject: [PATCH 06/20] Clarify comment about GITHUB_TOKEN being IAT in GitHub Actions Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- 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 9d33fa19f..bb051ecf2 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -47,7 +47,7 @@ Describe 'Auth' { # Token expiration tests: # - PAT tokens (classic and fine-grained): No expiration metadata - # - GITHUB_TOKEN (IAT): No expiration metadata + # - GITHUB_TOKEN (IAT in GitHub Actions): No expiration metadata # - GitHub App Installation tokens (IAT from Connect-GitHubApp): Has expiration metadata # - GitHub App tokens (JWT): Has expiration metadata From 219edecda805215393f3bae36702153a0bab70e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 21:03:58 +0000 Subject: [PATCH 07/20] Remove unnecessary comments from tests Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index bb051ecf2..bdc6a6686 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -45,12 +45,6 @@ Describe 'Auth' { $context | Should -Not -BeNullOrEmpty } - # Token expiration tests: - # - PAT tokens (classic and fine-grained): No expiration metadata - # - GITHUB_TOKEN (IAT in GitHub Actions): No expiration metadata - # - GitHub App Installation tokens (IAT from Connect-GitHubApp): Has expiration metadata - # - GitHub App tokens (JWT): Has expiration metadata - It 'Connect-GitHubAccount - TokenExpiresIn should be null for PAT tokens' -Skip:($AuthType -ne 'PAT') { $context = Connect-GitHubAccount @connectParams -PassThru -Silent $context.TokenExpiresAt | Should -BeNullOrEmpty @@ -137,7 +131,6 @@ Describe 'Auth' { It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent - # GitHub App Installation tokens (IAT) created by Connect-GitHubApp should have expiration metadata $context.AuthType | Should -Be 'IAT' $context.TokenExpiresAt | Should -BeOfType [DateTime] $context.TokenExpiresIn | Should -BeOfType [TimeSpan] From e22f84a6b7eba1406f0ffa0ebfca8d85c151941a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 18:49:19 +0000 Subject: [PATCH 08/20] Fix test by resetting to App context before Connect-GitHubApp call Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index bdc6a6686..a6bf4c348 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -130,7 +130,9 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { - $context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent + # Switch back to App context since previous test may have set default to IAT + $appContext = Connect-GitHubAccount @connectParams -PassThru -Silent + $context = Connect-GitHubApp @connectAppParams -PassThru -Silent $context.AuthType | Should -Be 'IAT' $context.TokenExpiresAt | Should -BeOfType [DateTime] $context.TokenExpiresIn | Should -BeOfType [TimeSpan] From 075b804b50887fd7e66ecd426903e51da6f7f7ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 18:50:56 +0000 Subject: [PATCH 09/20] Remove unused variable from test Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index a6bf4c348..ca3260567 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -130,8 +130,8 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { - # Switch back to App context since previous test may have set default to IAT - $appContext = Connect-GitHubAccount @connectParams -PassThru -Silent + # Reset default context to App (previous test may have set it to IAT) + $null = Connect-GitHubAccount @connectParams -PassThru -Silent $context = Connect-GitHubApp @connectAppParams -PassThru -Silent $context.AuthType | Should -Be 'IAT' $context.TokenExpiresAt | Should -BeOfType [DateTime] From 8d144411979afa1beee2823f9a7f94f78b22a42b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 18:55:18 +0000 Subject: [PATCH 10/20] Remove comment from test Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index ca3260567..33549fa73 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -130,7 +130,6 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { - # Reset default context to App (previous test may have set it to IAT) $null = Connect-GitHubAccount @connectParams -PassThru -Silent $context = Connect-GitHubApp @connectAppParams -PassThru -Silent $context.AuthType | Should -Be 'IAT' From 80b38471a0178f0c91ec514f67efcdcfe47b5001 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 19:01:41 +0000 Subject: [PATCH 11/20] Simplify context reset by removing unnecessary PassThru Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- 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 33549fa73..e70635a42 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -130,7 +130,7 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { - $null = Connect-GitHubAccount @connectParams -PassThru -Silent + Connect-GitHubAccount @connectParams -Silent $context = Connect-GitHubApp @connectAppParams -PassThru -Silent $context.AuthType | Should -Be 'IAT' $context.TokenExpiresAt | Should -BeOfType [DateTime] From f9fcda4751aeb2da108a4fd5dccfa796041a3b1f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 19:25:11 +0000 Subject: [PATCH 12/20] Remove redundant Connect-GitHubAccount calls and use Get-GitHubContext Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index e70635a42..f27504e41 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -46,13 +46,13 @@ Describe 'Auth' { } It 'Connect-GitHubAccount - TokenExpiresIn should be null for PAT tokens' -Skip:($AuthType -ne 'PAT') { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent + $context = Get-GitHubContext $context.TokenExpiresAt | Should -BeNullOrEmpty $context.TokenExpiresIn | Should -BeNullOrEmpty } It 'Connect-GitHubAccount - TokenExpiresIn should be null for GITHUB_TOKEN (IAT)' -Skip:($TokenType -ne 'GITHUB_TOKEN') { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent + $context = Get-GitHubContext $context.TokenExpiresAt | Should -BeNullOrEmpty $context.TokenExpiresIn | Should -BeNullOrEmpty } @@ -130,12 +130,11 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { - Connect-GitHubAccount @connectParams -Silent - $context = Connect-GitHubApp @connectAppParams -PassThru -Silent - $context.AuthType | Should -Be 'IAT' - $context.TokenExpiresAt | Should -BeOfType [DateTime] - $context.TokenExpiresIn | Should -BeOfType [TimeSpan] - $context.TokenExpiresIn.TotalMinutes | Should -BeGreaterThan 0 + $appContext = Connect-GitHubApp @connectAppParams -PassThru -Silent + $appContext.AuthType | Should -Be 'IAT' + $appContext.TokenExpiresAt | Should -BeOfType [DateTime] + $appContext.TokenExpiresIn | Should -BeOfType [TimeSpan] + $appContext.TokenExpiresIn.TotalMinutes | Should -BeGreaterThan 0 } # Tests for runners goes here From acb07c87da7b2ffba963f0921fda1d31eac17d8e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 2 Jan 2026 19:02:05 +0000 Subject: [PATCH 13/20] Fix test by passing App context explicitly to Connect-GitHubApp Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- tests/GitHub.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index f27504e41..43d914b15 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -130,7 +130,8 @@ Describe 'Auth' { } It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { - $appContext = Connect-GitHubApp @connectAppParams -PassThru -Silent + $appContextToUse = Get-GitHubContext -ListAvailable | Where-Object { $_.AuthType -eq 'App' } | Select-Object -First 1 + $appContext = Connect-GitHubApp @connectAppParams -PassThru -Silent -Context $appContextToUse $appContext.AuthType | Should -Be 'IAT' $appContext.TokenExpiresAt | Should -BeOfType [DateTime] $appContext.TokenExpiresIn | Should -BeOfType [TimeSpan] From 860d4f56b3944ccce33443c5c512b24c96172ae4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 3 Jan 2026 19:29:12 +0100 Subject: [PATCH 14/20] Refactor Connect-GitHubAccount and Connect-GitHubApp tests to validate TokenExpiresAt and TokenExpiresIn based on token type --- tests/GitHub.Tests.ps1 | 69 +++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 43d914b15..7a50b5da5 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -45,16 +45,16 @@ Describe 'Auth' { $context | Should -Not -BeNullOrEmpty } - It 'Connect-GitHubAccount - TokenExpiresIn should be null for PAT tokens' -Skip:($AuthType -ne 'PAT') { - $context = Get-GitHubContext - $context.TokenExpiresAt | Should -BeNullOrEmpty - $context.TokenExpiresIn | Should -BeNullOrEmpty - } - - It 'Connect-GitHubAccount - TokenExpiresIn should be null for GITHUB_TOKEN (IAT)' -Skip:($TokenType -ne 'GITHUB_TOKEN') { - $context = Get-GitHubContext - $context.TokenExpiresAt | Should -BeNullOrEmpty - $context.TokenExpiresIn | Should -BeNullOrEmpty + It 'Connect-GitHubAccount - TokenExpiresAt and TokenExpiresIn should have correct values based on token type' { + if ($TokenType -in @('PAT', 'USER_FG_PAT', 'ORG_FG_PAT', 'GITHUB_TOKEN')) { + $context.TokenExpiresAt | Should -BeNullOrEmpty + $context.TokenExpiresIn | Should -BeNullOrEmpty + } else { + $context.TokenExpiresAt | Should -BeOfType [DateTime] + $context.TokenExpiresAt | Should -BeGreaterThan ([DateTime]::Now) + $context.TokenExpiresIn | Should -BeOfType [TimeSpan] + $context.TokenExpiresIn.TotalSeconds | Should -BeGreaterThan 0 + } } It 'Connect-GitHubAccount - Connects using the provided credentials - Double' { @@ -92,8 +92,6 @@ Describe 'Auth' { } $context | Should -Not -BeNullOrEmpty $context | Should -BeOfType [GitHubContext] - $context.TokenExpiresAt | Should -BeOfType [DateTime] - $context.TokenExpiresIn | Should -BeOfType [TimeSpan] } It 'Connect-GitHubApp - Connects as a GitHub App to ' -Skip:($AuthType -ne 'APP') { @@ -121,21 +119,16 @@ Describe 'Auth' { LogGroup 'Connect-GithubApp' { $context } - $context.TokenExpiresAt | Should -BeOfType [DateTime] - $context.TokenExpiresIn | Should -BeOfType [TimeSpan] LogGroup 'Context' { Write-Host ($context | Format-List | Out-String) } $context | Should -Not -BeNullOrEmpty } - It 'Connect-GitHubApp - Installation tokens (IAT) should have expiration set' -Skip:($AuthType -ne 'APP') { + It 'Connect-GitHubApp - Installation tokens (IAT) should have correct auth type' -Skip:($AuthType -ne 'APP') { $appContextToUse = Get-GitHubContext -ListAvailable | Where-Object { $_.AuthType -eq 'App' } | Select-Object -First 1 $appContext = Connect-GitHubApp @connectAppParams -PassThru -Silent -Context $appContextToUse $appContext.AuthType | Should -Be 'IAT' - $appContext.TokenExpiresAt | Should -BeOfType [DateTime] - $appContext.TokenExpiresIn | Should -BeOfType [TimeSpan] - $appContext.TokenExpiresIn.TotalMinutes | Should -BeGreaterThan 0 } # Tests for runners goes here @@ -254,18 +247,18 @@ Describe 'GitHub' { $config.PerPage | Should -Be 100 } It 'Set-GitHubConfig - Sets a configuration item' { - Set-GitHubConfig -Name 'HostName' -Value 'msx.ghe.com' - Get-GitHubConfig -Name 'HostName' | Should -Be 'msx.ghe.com' + Set-GitHubConfig -name 'HostName' -Value 'msx.ghe.com' + Get-GitHubConfig -name 'HostName' | Should -Be 'msx.ghe.com' } It 'Remove-GitHubConfig - Removes a configuration item' { - Remove-GitHubConfig -Name 'HostName' - Get-GitHubConfig -Name 'HostName' | Should -BeNullOrEmpty + Remove-GitHubConfig -name 'HostName' + Get-GitHubConfig -name 'HostName' | Should -BeNullOrEmpty } It 'Reset-GitHubConfig - Resets the module configuration' { - Set-GitHubConfig -Name HostName -Value 'msx.ghe.com' - Get-GitHubConfig -Name HostName | Should -Be 'msx.ghe.com' + 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' + Get-GitHubConfig -name HostName | Should -Be 'github.com' } } Context 'Actions' { @@ -323,7 +316,7 @@ Describe 'GitHub' { } It 'Set-GitHubLogGroup - Should not throw' { { - Set-GitHubLogGroup -Name 'MyGroup' -ScriptBlock { + Set-GitHubLogGroup -name 'MyGroup' -ScriptBlock { Get-ChildItem env: | Select-Object Name, Value | Format-Table -AutoSize } } | Should -Not -Throw @@ -365,13 +358,13 @@ Describe 'GitHub' { } It 'Set-GitHubOutput + Simple string - Should not throw' { { - Set-GitHubOutput -Name 'MyOutput' -Value 'MyValue' + Set-GitHubOutput -name 'MyOutput' -Value 'MyValue' } | Should -Not -Throw (Get-GitHubOutput).MyOutput | Should -Be 'MyValue' } It 'Set-GitHubOutput + Multiline string - Should not throw' { { - Set-GitHubOutput -Name 'MyOutput' -Value @' + Set-GitHubOutput -name 'MyOutput' -Value @' This is a multiline string '@ @@ -384,7 +377,7 @@ string It 'Set-GitHubOutput + SecureString - Should not throw' { { $secret = 'MyValue' | ConvertTo-SecureString -AsPlainText -Force - Set-GitHubOutput -Name 'MySecret' -Value $secret + Set-GitHubOutput -name 'MySecret' -Value $secret } | Should -Not -Throw (Get-GitHubOutput).MySecret | Should -Be 'MyValue' } @@ -402,19 +395,19 @@ string Value = 'Else' } } - Set-GitHubOutput -Name 'Jupiter' -Value $jupiter + Set-GitHubOutput -name 'Jupiter' -Value $jupiter } | Should -Not -Throw (Get-GitHubOutput).Config | Should -BeLike '' } It 'Set-GitHubOutput + Empty string - Should not throw' { { - Set-GitHubOutput -Name 'EmptyOutput' -Value '' + Set-GitHubOutput -name 'EmptyOutput' -Value '' } | Should -Not -Throw (Get-GitHubOutput).EmptyOutput | Should -Be '' } It 'Set-GitHubOutput + Null - Should not throw and store as null' { { - Set-GitHubOutput -Name 'NullOutput' -Value $null + Set-GitHubOutput -name 'NullOutput' -Value $null } | Should -Not -Throw $nullValue = (Get-GitHubOutput).NullOutput $nullValue | Should -Be $null @@ -426,7 +419,7 @@ string It 'Set-GitHubOutput + Empty String - Should store as empty string' { { - Set-GitHubOutput -Name 'EmptyStringOutput' -Value '' + Set-GitHubOutput -name 'EmptyStringOutput' -Value '' } | Should -Not -Throw (Get-GitHubOutput).EmptyStringOutput | Should -Be '' @@ -442,7 +435,7 @@ ghadelimiter_6f9f5610-74ad-4b25-8ef3-7f3e9e764fa2 '@ Add-Content -Path $env:GITHUB_OUTPUT -Value $existingContent { - Set-GitHubOutput -Name 'TestAfterExisting' -Value 'TestValue' + Set-GitHubOutput -name 'TestAfterExisting' -Value 'TestValue' } | Should -Not -Throw (Get-GitHubOutput).TestAfterExisting | Should -Be 'TestValue' $stderr = (Get-GitHubOutput).stderr @@ -455,14 +448,14 @@ ghadelimiter_6f9f5610-74ad-4b25-8ef3-7f3e9e764fa2 Write-Host (Get-GitHubOutput | Format-List | Out-String) } It 'Reset-GitHubOutput - Should clear the outputs from the output file' { - Set-GitHubOutput -Name 'TestOutput' -Value 'TestValue' + Set-GitHubOutput -name 'TestOutput' -Value 'TestValue' (Get-GitHubOutput).TestOutput | Should -Be 'TestValue' Reset-GitHubOutput Get-GitHubOutput | Should -BeNullOrEmpty } It 'Set-GitHubEnvironmentVariable - Should not throw' { { - Set-GitHubEnvironmentVariable -Name 'MyName' -Value 'MyValue' + Set-GitHubEnvironmentVariable -name 'MyName' -Value 'MyValue' } | Should -Not -Throw Get-Content $env:GITHUB_ENV -Raw | Should -BeLike '*MyName*MyValue*' } @@ -697,7 +690,7 @@ Describe 'API' { $licenseList | Should -Not -BeNullOrEmpty } It 'Get-GitHubLicense - Gets a spesific license' { - $mitLicense = Get-GitHubLicense -Name 'mit' + $mitLicense = Get-GitHubLicense -name 'mit' LogGroup 'MIT License' { Write-Host ($mitLicense | Format-Table | Out-String) } @@ -721,7 +714,7 @@ Describe 'API' { $gitIgnoreList | Should -Not -BeNullOrEmpty } It 'Get-GitHubGitignore - Gets a gitignore template' { - $vsGitIgnore = Get-GitHubGitignore -Name 'VisualStudio' + $vsGitIgnore = Get-GitHubGitignore -name 'VisualStudio' LogGroup 'Visual Studio GitIgnore' { Write-Host ($vsGitIgnore | Format-Table | Out-String) } From b76a5f150e11b4a97109610e78e95af6cc6fae4d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 3 Jan 2026 22:30:52 +0100 Subject: [PATCH 15/20] Enhance tests for TokenExpiresAt and TokenExpiresIn properties in Connect-GitHubApp and Connect-GitHubAccount --- tests/Apps.Tests.ps1 | 7 +++-- tests/GitHub.Tests.ps1 | 62 +++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/tests/Apps.Tests.ps1 b/tests/Apps.Tests.ps1 index 9e5697196..e9979095b 100644 --- a/tests/Apps.Tests.ps1 +++ b/tests/Apps.Tests.ps1 @@ -230,7 +230,7 @@ Describe 'Apps' { LogGroup 'Config' { Write-Host "$($config | Format-List | Out-String)" } - LogGroup "Installation" { + LogGroup 'Installation' { Write-Host "$($installation | Format-List | Out-String)" } LogGroup 'Permissions' { @@ -274,8 +274,11 @@ Describe 'Apps' { $installationContext.Events | Should -BeOfType 'string' } - It 'Connect-GitHubApp - TokenExpiresIn property should be calculated correctly' { + It 'Connect-GitHubApp - TokenExpiresAt and TokenExpiresIn properties should be calculated correctly' { + $installationContext.TokenExpiresAt | Should -BeOfType [DateTime] + $installationContext.TokenExpiresAt | Should -BeGreaterThan ([DateTime]::Now) $installationContext.TokenExpiresIn | Should -BeOfType [TimeSpan] + $installationContext.TokenExpiresIn.TotalSeconds | Should -BeGreaterThan 0 $installationContext.TokenExpiresIn.TotalMinutes | Should -BeGreaterThan 0 $installationContext.TokenExpiresIn.TotalMinutes | Should -BeLessOrEqual 60 } diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 7a50b5da5..7cb9d9991 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -45,15 +45,19 @@ Describe 'Auth' { $context | Should -Not -BeNullOrEmpty } - It 'Connect-GitHubAccount - TokenExpiresAt and TokenExpiresIn should have correct values based on token type' { - if ($TokenType -in @('PAT', 'USER_FG_PAT', 'ORG_FG_PAT', 'GITHUB_TOKEN')) { - $context.TokenExpiresAt | Should -BeNullOrEmpty - $context.TokenExpiresIn | Should -BeNullOrEmpty - } else { + It 'Connect-GitHubAccount - TokenExpiresAt and TokenExpiresIn validation' { + if ($AuthType -eq 'APP') { + $context.TokenExpiresAt | Should -Not -BeNullOrEmpty $context.TokenExpiresAt | Should -BeOfType [DateTime] - $context.TokenExpiresAt | Should -BeGreaterThan ([DateTime]::Now) + $context.TokenExpiresAt | Should -BeGreaterThan ([DateTime]::UtcNow) + + $context.TokenExpiresIn | Should -Not -BeNullOrEmpty $context.TokenExpiresIn | Should -BeOfType [TimeSpan] - $context.TokenExpiresIn.TotalSeconds | Should -BeGreaterThan 0 + $context.TokenExpiresIn.TotalMinutes | Should -BeGreaterThan 0 + $context.TokenExpiresIn.TotalMinutes | Should -BeLessOrEqual 10 + } else { + $context.TokenExpiresAt | Should -BeNullOrEmpty + $context.TokenExpiresIn | Should -BeNullOrEmpty } } @@ -131,10 +135,6 @@ Describe 'Auth' { $appContext.AuthType | Should -Be 'IAT' } - # Tests for runners goes here - if ($Type -eq 'GitHub Actions') {} - - # Tests for IAT UAT and PAT goes here It 'Connect-GitHubAccount - Connects to GitHub CLI on runners' { [string]::IsNullOrEmpty($(gh auth token)) | Should -Be $false } @@ -247,18 +247,18 @@ Describe 'GitHub' { $config.PerPage | Should -Be 100 } It 'Set-GitHubConfig - Sets a configuration item' { - Set-GitHubConfig -name 'HostName' -Value 'msx.ghe.com' - Get-GitHubConfig -name 'HostName' | Should -Be 'msx.ghe.com' + Set-GitHubConfig -Name 'HostName' -Value 'msx.ghe.com' + Get-GitHubConfig -Name 'HostName' | Should -Be 'msx.ghe.com' } It 'Remove-GitHubConfig - Removes a configuration item' { - Remove-GitHubConfig -name 'HostName' - Get-GitHubConfig -name 'HostName' | Should -BeNullOrEmpty + Remove-GitHubConfig -Name 'HostName' + Get-GitHubConfig -Name 'HostName' | Should -BeNullOrEmpty } It 'Reset-GitHubConfig - Resets the module configuration' { - Set-GitHubConfig -name HostName -Value 'msx.ghe.com' - Get-GitHubConfig -name HostName | Should -Be 'msx.ghe.com' + 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' + Get-GitHubConfig -Name HostName | Should -Be 'github.com' } } Context 'Actions' { @@ -316,7 +316,7 @@ Describe 'GitHub' { } It 'Set-GitHubLogGroup - Should not throw' { { - Set-GitHubLogGroup -name 'MyGroup' -ScriptBlock { + Set-GitHubLogGroup -Name 'MyGroup' -ScriptBlock { Get-ChildItem env: | Select-Object Name, Value | Format-Table -AutoSize } } | Should -Not -Throw @@ -358,13 +358,13 @@ Describe 'GitHub' { } It 'Set-GitHubOutput + Simple string - Should not throw' { { - Set-GitHubOutput -name 'MyOutput' -Value 'MyValue' + Set-GitHubOutput -Name 'MyOutput' -Value 'MyValue' } | Should -Not -Throw (Get-GitHubOutput).MyOutput | Should -Be 'MyValue' } It 'Set-GitHubOutput + Multiline string - Should not throw' { { - Set-GitHubOutput -name 'MyOutput' -Value @' + Set-GitHubOutput -Name 'MyOutput' -Value @' This is a multiline string '@ @@ -377,7 +377,7 @@ string It 'Set-GitHubOutput + SecureString - Should not throw' { { $secret = 'MyValue' | ConvertTo-SecureString -AsPlainText -Force - Set-GitHubOutput -name 'MySecret' -Value $secret + Set-GitHubOutput -Name 'MySecret' -Value $secret } | Should -Not -Throw (Get-GitHubOutput).MySecret | Should -Be 'MyValue' } @@ -395,19 +395,19 @@ string Value = 'Else' } } - Set-GitHubOutput -name 'Jupiter' -Value $jupiter + Set-GitHubOutput -Name 'Jupiter' -Value $jupiter } | Should -Not -Throw (Get-GitHubOutput).Config | Should -BeLike '' } It 'Set-GitHubOutput + Empty string - Should not throw' { { - Set-GitHubOutput -name 'EmptyOutput' -Value '' + Set-GitHubOutput -Name 'EmptyOutput' -Value '' } | Should -Not -Throw (Get-GitHubOutput).EmptyOutput | Should -Be '' } It 'Set-GitHubOutput + Null - Should not throw and store as null' { { - Set-GitHubOutput -name 'NullOutput' -Value $null + Set-GitHubOutput -Name 'NullOutput' -Value $null } | Should -Not -Throw $nullValue = (Get-GitHubOutput).NullOutput $nullValue | Should -Be $null @@ -419,7 +419,7 @@ string It 'Set-GitHubOutput + Empty String - Should store as empty string' { { - Set-GitHubOutput -name 'EmptyStringOutput' -Value '' + Set-GitHubOutput -Name 'EmptyStringOutput' -Value '' } | Should -Not -Throw (Get-GitHubOutput).EmptyStringOutput | Should -Be '' @@ -435,7 +435,7 @@ ghadelimiter_6f9f5610-74ad-4b25-8ef3-7f3e9e764fa2 '@ Add-Content -Path $env:GITHUB_OUTPUT -Value $existingContent { - Set-GitHubOutput -name 'TestAfterExisting' -Value 'TestValue' + Set-GitHubOutput -Name 'TestAfterExisting' -Value 'TestValue' } | Should -Not -Throw (Get-GitHubOutput).TestAfterExisting | Should -Be 'TestValue' $stderr = (Get-GitHubOutput).stderr @@ -448,14 +448,14 @@ ghadelimiter_6f9f5610-74ad-4b25-8ef3-7f3e9e764fa2 Write-Host (Get-GitHubOutput | Format-List | Out-String) } It 'Reset-GitHubOutput - Should clear the outputs from the output file' { - Set-GitHubOutput -name 'TestOutput' -Value 'TestValue' + Set-GitHubOutput -Name 'TestOutput' -Value 'TestValue' (Get-GitHubOutput).TestOutput | Should -Be 'TestValue' Reset-GitHubOutput Get-GitHubOutput | Should -BeNullOrEmpty } It 'Set-GitHubEnvironmentVariable - Should not throw' { { - Set-GitHubEnvironmentVariable -name 'MyName' -Value 'MyValue' + Set-GitHubEnvironmentVariable -Name 'MyName' -Value 'MyValue' } | Should -Not -Throw Get-Content $env:GITHUB_ENV -Raw | Should -BeLike '*MyName*MyValue*' } @@ -690,7 +690,7 @@ Describe 'API' { $licenseList | Should -Not -BeNullOrEmpty } It 'Get-GitHubLicense - Gets a spesific license' { - $mitLicense = Get-GitHubLicense -name 'mit' + $mitLicense = Get-GitHubLicense -Name 'mit' LogGroup 'MIT License' { Write-Host ($mitLicense | Format-Table | Out-String) } @@ -714,7 +714,7 @@ Describe 'API' { $gitIgnoreList | Should -Not -BeNullOrEmpty } It 'Get-GitHubGitignore - Gets a gitignore template' { - $vsGitIgnore = Get-GitHubGitignore -name 'VisualStudio' + $vsGitIgnore = Get-GitHubGitignore -Name 'VisualStudio' LogGroup 'Visual Studio GitIgnore' { Write-Host ($vsGitIgnore | Format-Table | Out-String) } From bddf285876c634c39a0291c24ad16f5309f5d845 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 4 Jan 2026 01:39:18 +0100 Subject: [PATCH 16/20] Add BeforeAll block to initialize GitHub account context in Auth tests --- tests/GitHub.Tests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 7cb9d9991..0f7b72dd3 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -23,6 +23,13 @@ Describe 'Auth' { $authCases = . "$PSScriptRoot/Data/AuthCases.ps1" Context 'As using on ' -ForEach $authCases { + BeforeAll { + $context = Connect-GitHubAccount @connectParams -PassThru -Silent + LogGroup 'Context' { + Write-Host ($context | Format-List | Out-String) + } + } + AfterAll { Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent Write-Host ('-' * 60) From 6a58e0eae577fb6ebda706f014dd5ebf0a866ee5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 4 Jan 2026 01:39:53 +0100 Subject: [PATCH 17/20] Remove redundant context assignment in Connect-GitHubAccount test --- tests/GitHub.Tests.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 0f7b72dd3..13894e651 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -36,7 +36,6 @@ Describe 'Auth' { } It 'Connect-GitHubAccount - Connects using the provided credentials' { - $context = Connect-GitHubAccount @connectParams -PassThru -Silent LogGroup 'Context - Standard' { Write-Host ($context | Out-String) } From afd3bb3a8f043ddc0750cd6a8c79f7be3956c4da Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 4 Jan 2026 21:46:31 +0100 Subject: [PATCH 18/20] Refactor TokenExpiresIn handling to return 'Unknown' when TokenExpiresAt is null and improve formatting for terminal support --- src/formats/GitHubContext.Format.ps1xml | 66 +++++++++++++++---------- src/types/GitHubContext.Types.ps1xml | 47 +----------------- 2 files changed, 42 insertions(+), 71 deletions(-) diff --git a/src/formats/GitHubContext.Format.ps1xml b/src/formats/GitHubContext.Format.ps1xml index ea52e2049..6c80c2e1b 100644 --- a/src/formats/GitHubContext.Format.ps1xml +++ b/src/formats/GitHubContext.Format.ps1xml @@ -49,39 +49,55 @@ TokenType - - TokenExpiresAt - - if ($null -eq $_.TokenExpiresIn) { - return 'Unknown' + if ($null -ne $_.TokenExpiresAt) { + return $_.TokenExpiresAt } - if ($_.TokenExpiresIn -le 0) { - $text = 'Expired' - } else { - $text = $_.TokenExpiresIn.ToString('hh\:mm\:ss') + $text = 'N/A' + if ($Host.UI.SupportsVirtualTerminal -and ($env:GITHUB_ACTIONS -ne 'true')) { + $gray = "`e[90m" + $reset = "`e[0m" + return "$gray$text$reset" } + return $text + + + + + if ($null -ne $_.TokenExpiresIn) { + if ($_.TokenExpiresIn -le 0) { + $text = 'Expired' + } else { + $text = $_.TokenExpiresIn.ToString('hh\:mm\:ss') + } - if ($Host.UI.SupportsVirtualTerminal -and - ($env:GITHUB_ACTIONS -ne 'true')) { - switch ($_.AuthType) { - 'UAT' { - $maxValue = [TimeSpan]::FromHours(8) - } - 'IAT' { - $maxValue = [TimeSpan]::FromHours(1) - } - 'APP' { - $maxValue = [TimeSpan]::FromMinutes(10) + if ($Host.UI.SupportsVirtualTerminal -and ($env:GITHUB_ACTIONS -ne 'true')) { + switch ($_.AuthType) { + 'UAT' { + $maxValue = [TimeSpan]::FromHours(8) + } + 'IAT' { + $maxValue = [TimeSpan]::FromHours(1) + } + 'APP' { + $maxValue = [TimeSpan]::FromMinutes(10) + } + } + $ratio = [Math]::Min(($_.TokenExpiresIn / $maxValue), 1) + return [GitHubFormatter]::FormatColorByRatio($ratio, $text) + } + return $text } + + $text = 'N/A' + if ($Host.UI.SupportsVirtualTerminal -and ($env:GITHUB_ACTIONS -ne 'true')) { + $gray = "`e[90m" + $reset = "`e[0m" + return "$gray$text$reset" } - $ratio = [Math]::Min(($_.TokenExpiresIn / $maxValue), 1) - [GitHubFormatter]::FormatColorByRatio($ratio, $text) - } else { - $text - } + return $text diff --git a/src/types/GitHubContext.Types.ps1xml b/src/types/GitHubContext.Types.ps1xml index 381c40693..846be693c 100644 --- a/src/types/GitHubContext.Types.ps1xml +++ b/src/types/GitHubContext.Types.ps1xml @@ -1,46 +1 @@ - - - - GitHubUserContext - - - TokenExpiresIn - - if ($null -eq $this.TokenExpiresAt) { return $null } - $this.TokenExpiresAt - [DateTime]::Now - - - - RefreshTokenExpiresIn - - if ($null -eq $this.RefreshTokenExpiresAt) { return $null } - $this.RefreshTokenExpiresAt - [DateTime]::Now - - - - - - GitHubAppInstallationContext - - - TokenExpiresIn - - if ($null -eq $this.TokenExpiresAt) { return $null } - $this.TokenExpiresAt - [DateTime]::Now - - - - - - GitHubAppContext - - - TokenExpiresIn - - if ($null -eq $this.TokenExpiresAt) { return $null } - $this.TokenExpiresAt - [DateTime]::Now - - - - - +ø From 26b9724fbba8664a629058171aeb5a5a6e9f7f71 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 4 Jan 2026 21:49:59 +0100 Subject: [PATCH 19/20] Refactor GitHubContext types to include TokenExpiresIn and RefreshTokenExpiresIn properties with proper handling for null TokenExpiresAt values --- src/types/GitHubContext.Types.ps1xml | 51 +++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/types/GitHubContext.Types.ps1xml b/src/types/GitHubContext.Types.ps1xml index 846be693c..92f51f159 100644 --- a/src/types/GitHubContext.Types.ps1xml +++ b/src/types/GitHubContext.Types.ps1xml @@ -1 +1,50 @@ -ø + + + + GitHubUserContext + + + TokenExpiresIn + + if ($null -ne $this.TokenExpiresAt) { + return $this.TokenExpiresAt - [DateTime]::Now + } + + + + RefreshTokenExpiresIn + + if ($null -ne $this.RefreshTokenExpiresAt) { + return $this.RefreshTokenExpiresAt - [DateTime]::Now + } + + + + + + GitHubAppInstallationContext + + + TokenExpiresIn + + if ($null -ne $this.TokenExpiresAt) { + return $this.TokenExpiresAt - [DateTime]::Now + } + + + + + + GitHubAppContext + + + TokenExpiresIn + + if ($null -ne $this.TokenExpiresAt) { + return $this.TokenExpiresAt - [DateTime]::Now + } + + + + + From d3fceefa9532e1b823f2715e389a9b4ead13547a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 5 Jan 2026 09:52:28 +0100 Subject: [PATCH 20/20] Update TokenExpiresAt comparison to use DateTime.Now for accurate time validation --- 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 13894e651..177d53235 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -55,7 +55,7 @@ Describe 'Auth' { if ($AuthType -eq 'APP') { $context.TokenExpiresAt | Should -Not -BeNullOrEmpty $context.TokenExpiresAt | Should -BeOfType [DateTime] - $context.TokenExpiresAt | Should -BeGreaterThan ([DateTime]::UtcNow) + $context.TokenExpiresAt | Should -BeGreaterThan ([DateTime]::Now) $context.TokenExpiresIn | Should -Not -BeNullOrEmpty $context.TokenExpiresIn | Should -BeOfType [TimeSpan]