Merge remote-tracking branch 'origin/main' into feat/oficina-id-native-a
1 file changed,
+13
−1
connect/native_test.go+13 −1
CI passed — run details
diff --git a/connect/native_test.go b/connect/native_test.go| index a6bd4a6..6b3f3b1 100644 |
| --- a/connect/native_test.go |
| +++ b/connect/native_test.go |
| @@ -271,7 +271,7 @@ func TestNativeExchangeRefusesTheWrongAssertion(t *testing.T) { |
| "another verifier": {"assertion": good, "verifier": newVerifier(t)}, |
| "a browser nonce": {"assertion": f.signed(t, "pr_linked", webNonce, bridgeOrigin), "verifier": verifier}, |
| "another audience": {"assertion": f.nativeAssertionFor(t, "pr_linked", verifier, "https://red.docs.oficina.works"), "verifier": verifier}, |
| - "a corrupted token": {"assertion": good[:len(good)-2] + "AA", "verifier": verifier}, |
| + "a corrupted token": {"assertion": corrupt(good), "verifier": verifier}, |
| "a stranger's token": {"assertion": strings.Repeat("x", 200), "verifier": verifier}, |
| } { |
| t.Run(name, func(t *testing.T) { wantState(t, f.exchange(t, nativeRequestFor(t, body)), 401, "failed") }) |
| @@ -284,6 +284,18 @@ func TestNativeExchangeRefusesTheWrongAssertion(t *testing.T) { |
| wantState(t, f.exchange(t, nativeRequestFor(t, ok)), 401, "failed") |
| } |
| +// corrupt changes one character inside the token's signature, always to a |
| +// different one: a middle character carries six full bits, so the decoded |
| +// signature differs whatever the original was. |
| +func corrupt(token string) string { |
| + i := len(token) - 10 |
| + c := byte('A') |
| + if token[i] == 'A' { |
| + c = 'B' |
| + } |
| + return token[:i] + string(c) + token[i+1:] |
| +} |
| + |
| func (f *bridgeFixture) nativeAssertionFor(t *testing.T, subject, verifier, audience string) string { |
| t.Helper() |
| challenge, _ := handoff.NativeChallenge(verifier) |