|
13 | 13 | [CmdletBinding()] |
14 | 14 | param() |
15 | 15 |
|
16 | | -Describe 'TestData is pushed into the module tests' { |
17 | | - # TEST_SECRET (from the "secrets" map, masked) and TEST_VARIABLE (from the "variables" map, not |
18 | | - # masked) are public non-secret fixtures that exist only to prove the calling workflow can push |
19 | | - # secrets and variables into the module test jobs. The calling workflow passes them through a |
20 | | - # single TestData object and Import-TestData (from Install-PSModuleHelpers) exposes them as |
21 | | - # environment variables; these tests confirm they arrive with the expected values. |
| 16 | +Describe 'TestData exposes all secrets and variables' { |
| 17 | + # EXPERIMENT: the calling workflow now passes every secret and every variable through the single |
| 18 | + # TestData object via toJSON(secrets)/toJSON(vars). Import-TestData (from Install-PSModuleHelpers) |
| 19 | + # exposes each entry as an environment variable. These tests iterate every environment variable |
| 20 | + # visible to the job and print it, so the job log shows exactly what reached the module tests. |
| 21 | + # GitHub Actions redacts any registered secret value to *** in the log; plain variables print |
| 22 | + # verbatim. Inspect the job log to see which names arrived and how they are rendered. |
22 | 23 |
|
23 | | - It 'Exposes the secret from the "secrets" map' { |
24 | | - $actual = [System.Environment]::GetEnvironmentVariable('TEST_SECRET') |
25 | | - $actual | Should -Not -BeNullOrEmpty |
26 | | - $actual | Should -BeExactly 'mariustestmodule-secret-fixture-value' |
| 24 | + It 'Iterates every environment variable and prints what the job can see' { |
| 25 | + $all = Get-ChildItem env: | Sort-Object Name |
| 26 | + Write-Host "===== BEGIN environment dump ($($all.Count) variables) =====" |
| 27 | + foreach ($entry in $all) { |
| 28 | + Write-Host ("{0} = {1}" -f $entry.Name, $entry.Value) |
| 29 | + } |
| 30 | + Write-Host '===== END environment dump =====' |
| 31 | + $all.Count | Should -BeGreaterThan 0 |
27 | 32 | } |
28 | 33 |
|
29 | | - It 'Exposes the variable from the "variables" map' { |
30 | | - $actual = [System.Environment]::GetEnvironmentVariable('TEST_VARIABLE') |
31 | | - $actual | Should -Not -BeNullOrEmpty |
32 | | - $actual | Should -BeExactly 'mariustestmodule-variable-fixture-value' |
33 | | - } |
34 | | - |
35 | | - It 'Masks the secret in the log even when a test prints it in plain text' { |
36 | | - # Deliberately try to leak both values to the log with Write-Host. Because Import-TestData |
37 | | - # registered the secret via ::add-mask::, GitHub Actions redacts it to *** in the log, while |
38 | | - # the variable (not masked) is printed verbatim. Inspect the job log to see the difference. |
39 | | - Write-Host "Secret in plain text: $env:TEST_SECRET" |
40 | | - Write-Host "Variable in plain text: $env:TEST_VARIABLE" |
| 34 | + It 'Reports the fixture secret and variable arrived' { |
| 35 | + # These two fixtures are part of the full dump (a repo secret and a repo variable). If the |
| 36 | + # full enumeration worked, both are present; the secret prints as *** because it is masked. |
| 37 | + Write-Host "TEST_SECRET = $env:TEST_SECRET" |
| 38 | + Write-Host "TEST_VARIABLE = $env:TEST_VARIABLE" |
41 | 39 | } |
42 | 40 | } |
0 commit comments