Uh oh!
There was an error while loading. Please reload this page.
🌟 [Major]: Fixed test secret inputs replaced by TestData - #365
Conversation
…via TestSecrets Replaces the seven hard-coded TEST_* secrets with a single optional TestSecrets JSON input. The calling workflow decides which org/repo secrets to expose by building a JSON object with toJSON(secrets.<name>); each entry is expanded into an environment variable (multi-line safe and masked) in the BeforeAll/Test/AfterAll ModuleLocal jobs, so tests read them via $env:<name>. No secret names are hard-coded in the shared workflow and secrets: inherit is not required. Closes#52.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
There was a problem hiding this comment.
Pull request overview
This PR updates the reusable Process-PSModule GitHub Actions workflow to let calling workflows pass an optional TestSecrets JSON object, which is expanded into environment variables for the *-ModuleLocal test jobs—removing the previous fixed list of TEST_* secrets and avoiding secrets: inherit.
Changes:
- Replaces the fixed seven
TEST_*secret pass-throughs with a single optionalTestSecretssecret in the top-level reusable workflow and its nested ModuleLocal workflows. - Adds a PowerShell step in
BeforeAll-ModuleLocal,Test-ModuleLocal, andAfterAll-ModuleLocalto expandTestSecretsJSON into$GITHUB_ENVand mask values. - Updates self-test workflows and Pester environment tests, and rewrites the README Secrets documentation to describe
TestSecrets.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/srcWithManifestTestRepo/tests/Environments/Environment.Tests.ps1 | Adds assertion that a caller-defined env var flows through from TestSecrets. |
| tests/srcTestRepo/tests/Environment.Tests.ps1 | Same validation as above for the default self-test repo. |
| README.md | Updates Secrets documentation to describe APIKey + optional TestSecrets JSON. |
| .github/workflows/workflow.yml | Declares TestSecrets and passes only that secret to ModuleLocal jobs. |
| .github/workflows/Workflow-Test-WithManifest.yml | Builds TestSecrets JSON (including a literal proving arbitrary names). |
| .github/workflows/Workflow-Test-Default.yml | Builds TestSecrets JSON (including a literal proving arbitrary names). |
| .github/workflows/Test-ModuleLocal.yml | Adds the JSON→env expansion/masking step for tests. |
| .github/workflows/BeforeAll-ModuleLocal.yml | Adds the JSON→env expansion/masking step for setup scripts. |
| .github/workflows/AfterAll-ModuleLocal.yml | Adds the JSON→env expansion/masking step for teardown scripts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…r-masking
A multi-line secret makes GitHub register every line (including standalone { and } braces) as its own mask, which over-masks unrelated log output (563 masked lines vs 25 on main). Use a folded (>-) block so the source stays readable but the secret value is a single line, registering one mask. Per-value protection is unchanged (the expose step still ::add-mask::es each value).Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Self-tests now pass two dedicated, non-sensitive repository secrets (PSMODULE_TEST_SINGLELINE_SECRET, PSMODULE_TEST_MULTILINE_SECRET) through TestSecrets and assert the exact value and length (and multi-line integrity) in Environment.Tests.ps1. This exercises the real GitHub-secret path (masked, passed through, exposed as $env:<name>) instead of literal placeholders.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Adds a TestVariables workflow input (symmetric to TestSecrets) that exposes caller-selected NON-SECRET values as environment variables in the module test jobs, without masking. The expose step is refactored into a shared helper that masks secrets but not variables. Self-tests prove it via a dedicated PSMODULE_TEST_VARIABLE repo variable (asserted value + length). README documents both.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
61751d0 to
66ab9a8Compare66ab9a8 to
c3c335aCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
c3c335a to
38f5a98CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
38f5a98 to
4dc521fCompareUh oh!
There was an error while loading. Please reload this page.
- Reconcile with #365 (TestData secret inputs) — kept both the Plan/version wiring and the new TestData inputs in workflow.yml/Test-ModuleLocal.yml; README secrets section adopts the TestData model. - Repin to released tags: Test-PSModule v3.0.13, Install-PSModuleHelpers v1.0.8, Document-PSModule v1.0.17 (replacing the temporary branch pins).
Module test jobs now use a
TestDataobject for optional test secrets and non-secret variables. This replaces the previous fixedTEST_*workflow secret inputs: callers that used those inputs must pass the same names insideTestData, while callers that need different names can expose them without changing the shared workflow.Breaking Changes
Removed: fixed
TEST_*workflow secret inputsThe reusable workflow no longer declares or accepts these individual test-secret inputs:
TEST_APP_ENT_CLIENT_IDTEST_APP_ENT_PRIVATE_KEYTEST_APP_ORG_CLIENT_IDTEST_APP_ORG_PRIVATE_KEYTEST_USER_ORG_FG_PATTEST_USER_USER_FG_PATTEST_USER_PATCallers using any of these inputs must move them into the
secretsmap insideTestData. The names can stay the same, so existing Pester tests can continue reading the same environment variables.New: Caller-selected
TestDataTestDatais an optional single-line JSON object withsecretsandvariablesmaps. Entries from both maps become environment variables inBeforeAll-ModuleLocal,Test-ModuleLocal, andAfterAll-ModuleLocal.Values under
secretsare masked before being exposed to the test jobs. Values undervariablesare exposed without masking for normal, non-sensitive configuration. Modules that do not need secrets or variables can omitTestDataentirely.Because the workflow does not use
secrets: inherit, only the values explicitly listed inTestDataare exposed to module tests.New: Safe
TestDatavalidation and formattingTestDatamust parse as a JSON object containing only optionalsecretsandvariablesmaps. Values in those maps must be scalar values. Keys must be safe environment-variable names matching^[A-Za-z_][A-Za-z0-9_]*$, must not be duplicated acrosssecretsandvariables, and must not override reserved variables such asPATH,CI,GITHUB_*,RUNNER_*orACTIONS_*.Pass
TestDataas a single-line value after YAML folding. The folded>-form is safe when the JSON is compact, or when every JSON content line stays at the same indentation level inside the block.Avoid normal pretty-printed JSON with nested indentation inside
>-. YAML preserves more-indented lines instead of folding them, so that shape can still produce a multi-line secret value. KeepingTestDatasingle-line after folding avoids GitHub treating line fragments as separate mask values.Use the direct quoted form for single-line secrets:
Using the JSON-encoded approach, github-advanced security will warn that all secrets available to the runner gets exposed.
Use
toJSON(vars.NAME)for variables so normal configuration values are JSON-encoded safely:For multi-line secrets, or secrets containing quotes or backslashes, base64-encode the secret and decode it in the test.
Technical Details
workflow.ymldeclares and forwards a single optionalTestDatasecret instead of the seven fixedTEST_*secrets..github/scripts/Expose-TestData.ps1contains the sharedTestDataparsing, validation, masking, and UTF-8GITHUB_ENVexport logic used by the ModuleLocal workflows.BeforeAll-ModuleLocal.yml,Test-ModuleLocal.yml, andAfterAll-ModuleLocal.ymlcall the shared helper instead of duplicating the security-sensitive exposure logic.Test-Module.ymlno longer declares or exports the obsolete fixedTEST_*secrets.pull_requestruns where repository secrets and variables are unavailable, while still running for trusted PRs, schedules, and manual dispatches.TestData, and the environment Pester tests assert the exact exposed secret and variable values.README.mddocuments the breaking migration path, theTestDatacontract, safe YAML folding, safe key names, environment-scoped value usage, the difference between masked secrets and unmasked variables, and base64 guidance for complex secret values.secrets: inheritin ModuleLocal workflows #322's duplicated fixed-secret pass-through without adopting broadsecrets: inherit.