Skip to content

Commit e5dfca3

Browse files
🧪 [Test]: Use throwaway temp secret values in self-tests + temporary masking probe
Self-tests no longer depend on real repository secrets; they pass known throwaway values through TestSecrets so masking can be verified conclusively. Adds a temporary MASKPROBE that will be removed after log verification.
1 parent 772d65f commit e5dfca3

4 files changed

Lines changed: 58 additions & 54 deletions

File tree

‎.github/workflows/Workflow-Test-Default.yml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ jobs:
2828
uses: ./.github/workflows/workflow.yml
2929
secrets:
3030
APIKey: ${{ secrets.APIKey }}
31-
# The calling workflow chooses which secrets to expose to the test jobs. Names are
32-
# caller-defined and read by the module's Pester tests via $env:<name>. CUSTOM_TEST_ENV_VAR
33-
# is a plain literal that proves arbitrary, caller-defined names flow through end to end.
31+
# Self-test only: THROWAWAY, non-sensitive placeholder values (not real secrets), so the
32+
# framework's own tests never depend on repository secrets and masking can be verified with
33+
# known values. A real caller would use `toJSON(secrets.<name>)` for each entry instead.
3434
# The folded '>-' block with flat indentation produces a SINGLE-LINE secret value; a literal
3535
# '|' multi-line value makes GitHub register every line as its own mask and over-masks logs.
3636
TestSecrets: >-
3737
{
38-
"TEST_APP_ENT_CLIENT_ID": ${{ toJSON(secrets.TEST_APP_ENT_CLIENT_ID) }},
39-
"TEST_APP_ENT_PRIVATE_KEY": ${{ toJSON(secrets.TEST_APP_ENT_PRIVATE_KEY) }},
40-
"TEST_APP_ORG_CLIENT_ID": ${{ toJSON(secrets.TEST_APP_ORG_CLIENT_ID) }},
41-
"TEST_APP_ORG_PRIVATE_KEY": ${{ toJSON(secrets.TEST_APP_ORG_PRIVATE_KEY) }},
42-
"TEST_USER_ORG_FG_PAT": ${{ toJSON(secrets.TEST_USER_ORG_FG_PAT) }},
43-
"TEST_USER_USER_FG_PAT": ${{ toJSON(secrets.TEST_USER_USER_FG_PAT) }},
44-
"TEST_USER_PAT": ${{ toJSON(secrets.TEST_USER_PAT) }},
38+
"TEST_APP_ENT_CLIENT_ID": "tmp-ent-client-id-01",
39+
"TEST_APP_ENT_PRIVATE_KEY": "tmp-ent-key-a1\ntmp-ent-key-a2",
40+
"TEST_APP_ORG_CLIENT_ID": "tmp-org-client-id-02",
41+
"TEST_APP_ORG_PRIVATE_KEY": "tmp-org-key-b1\ntmp-org-key-b2",
42+
"TEST_USER_ORG_FG_PAT": "tmp-user-org-fgpat-03",
43+
"TEST_USER_USER_FG_PAT": "tmp-user-usr-fgpat-04",
44+
"TEST_USER_PAT": "tmp-user-pat-05",
4545
"CUSTOM_TEST_ENV_VAR": "caller-provided-value"
4646
}
4747
with:

‎.github/workflows/Workflow-Test-WithManifest.yml‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ jobs:
2828
uses: ./.github/workflows/workflow.yml
2929
secrets:
3030
APIKey: ${{ secrets.APIKey }}
31-
# The calling workflow chooses which secrets to expose to the test jobs. Names are
32-
# caller-defined and read by the module's Pester tests via $env:<name>. CUSTOM_TEST_ENV_VAR
33-
# is a plain literal that proves arbitrary, caller-defined names flow through end to end.
31+
# Self-test only: THROWAWAY, non-sensitive placeholder values (not real secrets), so the
32+
# framework's own tests never depend on repository secrets and masking can be verified with
33+
# known values. A real caller would use `toJSON(secrets.<name>)` for each entry instead.
3434
# The folded '>-' block with flat indentation produces a SINGLE-LINE secret value; a literal
3535
# '|' multi-line value makes GitHub register every line as its own mask and over-masks logs.
3636
TestSecrets: >-
3737
{
38-
"TEST_APP_ENT_CLIENT_ID": ${{ toJSON(secrets.TEST_APP_ENT_CLIENT_ID) }},
39-
"TEST_APP_ENT_PRIVATE_KEY": ${{ toJSON(secrets.TEST_APP_ENT_PRIVATE_KEY) }},
40-
"TEST_APP_ORG_CLIENT_ID": ${{ toJSON(secrets.TEST_APP_ORG_CLIENT_ID) }},
41-
"TEST_APP_ORG_PRIVATE_KEY": ${{ toJSON(secrets.TEST_APP_ORG_PRIVATE_KEY) }},
42-
"TEST_USER_ORG_FG_PAT": ${{ toJSON(secrets.TEST_USER_ORG_FG_PAT) }},
43-
"TEST_USER_USER_FG_PAT": ${{ toJSON(secrets.TEST_USER_USER_FG_PAT) }},
44-
"TEST_USER_PAT": ${{ toJSON(secrets.TEST_USER_PAT) }},
38+
"TEST_APP_ENT_CLIENT_ID": "tmp-ent-client-id-01",
39+
"TEST_APP_ENT_PRIVATE_KEY": "tmp-ent-key-a1\ntmp-ent-key-a2",
40+
"TEST_APP_ORG_CLIENT_ID": "tmp-org-client-id-02",
41+
"TEST_APP_ORG_PRIVATE_KEY": "tmp-org-key-b1\ntmp-org-key-b2",
42+
"TEST_USER_ORG_FG_PAT": "tmp-user-org-fgpat-03",
43+
"TEST_USER_USER_FG_PAT": "tmp-user-usr-fgpat-04",
44+
"TEST_USER_PAT": "tmp-user-pat-05",
4545
"CUSTOM_TEST_ENV_VAR": "caller-provided-value"
4646
}
4747
with:
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
Describe 'Environment Variables are available' {
2-
It 'Should be available [<_>]' -ForEach @(
3-
'TEST_APP_ENT_CLIENT_ID',
4-
'TEST_APP_ENT_PRIVATE_KEY',
5-
'TEST_APP_ORG_CLIENT_ID',
6-
'TEST_APP_ORG_PRIVATE_KEY',
7-
'TEST_USER_ORG_FG_PAT',
8-
'TEST_USER_USER_FG_PAT',
9-
'TEST_USER_PAT'
1+
# TEMP masking probe (removed after verification): deliberately emits throwaway secret values so
2+
# the run logs can be inspected to confirm they render as *** (masked).
3+
Write-Verbose ("MASKPROBE TEST_USER_PAT=[{0}] CUSTOM_TEST_ENV_VAR=[{1}]" -f $env:TEST_USER_PAT, $env:CUSTOM_TEST_ENV_VAR) -Verbose
4+
5+
Describe 'Environment Variables are available' {
6+
It 'Exposes [<Name>] with the caller-provided value' -ForEach @(
7+
@{ Name = 'TEST_APP_ENT_CLIENT_ID'; Expected = 'tmp-ent-client-id-01' }
8+
@{ Name = 'TEST_APP_ORG_CLIENT_ID'; Expected = 'tmp-org-client-id-02' }
9+
@{ Name = 'TEST_USER_ORG_FG_PAT'; Expected = 'tmp-user-org-fgpat-03' }
10+
@{ Name = 'TEST_USER_USER_FG_PAT'; Expected = 'tmp-user-usr-fgpat-04' }
11+
@{ Name = 'TEST_USER_PAT'; Expected = 'tmp-user-pat-05' }
12+
@{ Name = 'CUSTOM_TEST_ENV_VAR'; Expected = 'caller-provided-value' }
1013
) {
11-
$name = $_
12-
Write-Verbose "Environment variable: [$name]" -Verbose
13-
Get-ChildItem env: | Where-Object { $_.Name -eq $name } | Should -Not -BeNullOrEmpty
14+
Write-Verbose "Environment variable: [$Name]" -Verbose
15+
[System.Environment]::GetEnvironmentVariable($Name) | Should -Be $Expected
1416
}
1517

16-
It 'Exposes caller-defined secret names with their values' {
17-
# CUSTOM_TEST_ENV_VAR is provided by the calling workflow through the TestSecrets JSON object.
18-
# It proves arbitrary, caller-defined names are plumbed through as environment variables that
19-
# the tests read via $env:<name>, without relying on secrets: inherit.
20-
$env:CUSTOM_TEST_ENV_VAR | Should -Be 'caller-provided-value'
18+
It 'Preserves multi-line values in [<Name>]' -ForEach @(
19+
@{ Name = 'TEST_APP_ENT_PRIVATE_KEY'; Expected = "tmp-ent-key-a1`ntmp-ent-key-a2" }
20+
@{ Name = 'TEST_APP_ORG_PRIVATE_KEY'; Expected = "tmp-org-key-b1`ntmp-org-key-b2" }
21+
) {
22+
[System.Environment]::GetEnvironmentVariable($Name) | Should -Be $Expected
2123
}
2224
}
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
Describe 'Environment Variables are available' {
2-
It 'Should be available [<_>]' -ForEach @(
3-
'TEST_APP_ENT_CLIENT_ID',
4-
'TEST_APP_ENT_PRIVATE_KEY',
5-
'TEST_APP_ORG_CLIENT_ID',
6-
'TEST_APP_ORG_PRIVATE_KEY',
7-
'TEST_USER_ORG_FG_PAT',
8-
'TEST_USER_USER_FG_PAT',
9-
'TEST_USER_PAT'
1+
# TEMP masking probe (removed after verification): deliberately emits throwaway secret values so
2+
# the run logs can be inspected to confirm they render as *** (masked).
3+
Write-Verbose ("MASKPROBE TEST_USER_PAT=[{0}] CUSTOM_TEST_ENV_VAR=[{1}]" -f $env:TEST_USER_PAT, $env:CUSTOM_TEST_ENV_VAR) -Verbose
4+
5+
Describe 'Environment Variables are available' {
6+
It 'Exposes [<Name>] with the caller-provided value' -ForEach @(
7+
@{ Name = 'TEST_APP_ENT_CLIENT_ID'; Expected = 'tmp-ent-client-id-01' }
8+
@{ Name = 'TEST_APP_ORG_CLIENT_ID'; Expected = 'tmp-org-client-id-02' }
9+
@{ Name = 'TEST_USER_ORG_FG_PAT'; Expected = 'tmp-user-org-fgpat-03' }
10+
@{ Name = 'TEST_USER_USER_FG_PAT'; Expected = 'tmp-user-usr-fgpat-04' }
11+
@{ Name = 'TEST_USER_PAT'; Expected = 'tmp-user-pat-05' }
12+
@{ Name = 'CUSTOM_TEST_ENV_VAR'; Expected = 'caller-provided-value' }
1013
) {
11-
$name = $_
12-
Write-Verbose "Environment variable: [$name]" -Verbose
13-
Get-ChildItem env: | Where-Object { $_.Name -eq $name } | Should -Not -BeNullOrEmpty
14+
Write-Verbose "Environment variable: [$Name]" -Verbose
15+
[System.Environment]::GetEnvironmentVariable($Name) | Should -Be $Expected
1416
}
1517

16-
It 'Exposes caller-defined secret names with their values' {
17-
# CUSTOM_TEST_ENV_VAR is provided by the calling workflow through the TestSecrets JSON object.
18-
# It proves arbitrary, caller-defined names are plumbed through as environment variables that
19-
# the tests read via $env:<name>, without relying on secrets: inherit.
20-
$env:CUSTOM_TEST_ENV_VAR | Should -Be 'caller-provided-value'
18+
It 'Preserves multi-line values in [<Name>]' -ForEach @(
19+
@{ Name = 'TEST_APP_ENT_PRIVATE_KEY'; Expected = "tmp-ent-key-a1`ntmp-ent-key-a2" }
20+
@{ Name = 'TEST_APP_ORG_PRIVATE_KEY'; Expected = "tmp-org-key-b1`ntmp-org-key-b2" }
21+
) {
22+
[System.Environment]::GetEnvironmentVariable($Name) | Should -Be $Expected
2123
}
2224
}

0 commit comments

Comments
 (0)