test(secrets): scope-routing + roundtrip integration matrix#742
Merged
Conversation
Per workflow#735 SPEC T20.
secrets/github_scope_integration_test.go (235 LoC, 6 subtests +
2 root tests):
- roundtripStub: httptest.Server that records every request +
decrypts every PUT body using a stub key pair generated per-
test. Mirrors the encryptSecret blake2b-nonce sealed-box
convention exactly.
- TestScope_Integration_Matrix exercises every scope path:
repo: /repos/acme/repo/actions/secrets/REPO_SECRET
env: /repos/acme/repo/environments/staging/secrets/ENV_SECRET
org-all: /orgs/acme/actions/secrets/ORG_SECRET + visibility=all
org-private: /orgs/acme/actions/secrets/PRIVATE_SECRET + visibility=private
org-selected:/orgs/acme/actions/secrets/SELECTED_SECRET + visibility=selected
Each subtest asserts:
1. PUT path matches the scope's URL prefix.
2. Encrypted body decrypts back to the original plaintext.
3. visibility field is present on org PUTs + absent on repo/env.
- TestScope_Integration_SelectedRepoIDsPropagate verifies that
the selected_repository_ids array is serialised correctly
into the org PUT payload when visibility=selected.
Closes the end-to-end test gap for the scoped-secret-set feature.
All existing wfctl + secrets tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an end-to-end integration test matrix for the GitHub Actions secrets provider, validating scope-based URL routing (repo/env/org) and verifying encrypted payloads can be decrypted back to the original plaintext (roundtrip) via an httptest stub.
Changes:
- Introduces a
roundtripStubhttptestserver that serves/public-key, records PUTs, and decryptsencrypted_valuefor assertions. - Adds a scope/visibility matrix test covering repo, environment, and org secrets (including org visibility modes).
- Adds a focused test ensuring
selected_repository_idsserializes correctly for org visibilityselected.
Comment on lines
+3
to
+18
| import ( | ||
| "context" | ||
| "encoding/base64" | ||
| "encoding/json" | ||
| "io" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "strings" | ||
| "sync" | ||
| "testing" | ||
|
|
||
| "crypto/rand" | ||
|
|
||
| "golang.org/x/crypto/blake2b" | ||
| "golang.org/x/crypto/nacl/box" | ||
| ) |
Comment on lines
+21
to
+22
| // every request + decrypts every PUT body using a deterministic key | ||
| // pair (generated per-test). Used by the T20 integration matrix. |
Comment on lines
+82
to
+110
| // decrypt inverts encryptSecret. The wire shape is: | ||
| // | ||
| // eph_pub_key (32 bytes) || box.Seal(plaintext, nonce, recipient, eph_priv) | ||
| // | ||
| // where nonce = blake2b-192(eph_pub || recipient_pub) per libsodium | ||
| // sealed-box. | ||
| func (s *roundtripStub) decrypt(encB64 string) (string, bool) { | ||
| cipher, err := base64.StdEncoding.DecodeString(encB64) | ||
| if err != nil || len(cipher) < 32 { | ||
| return "", false | ||
| } | ||
| var ephPub [32]byte | ||
| copy(ephPub[:], cipher[:32]) | ||
|
|
||
| h, err := blake2b.New(24, nil) | ||
| if err != nil { | ||
| return "", false | ||
| } | ||
| h.Write(ephPub[:]) | ||
| h.Write(s.pubKey[:]) | ||
| var nonce [24]byte | ||
| copy(nonce[:], h.Sum(nil)) | ||
|
|
||
| plain, ok := box.Open(nil, cipher[32:], &nonce, &ephPub, &s.privKey) | ||
| if !ok { | ||
| return "", false | ||
| } | ||
| return string(plain), true | ||
| } |
Comment on lines
+127
to
+134
| cases := []struct { | ||
| name string | ||
| buildProv func(t *testing.T, base string) *GitHubSecretsProvider | ||
| secret string | ||
| value string | ||
| wantPath string | ||
| extraPayload map[string]any | ||
| }{ |
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per workflow#735 SPEC T20. Httptest stub captures PUT paths + decrypts payloads end-to-end across repo/env/org × visibility levels. 6 subtests.