Skip to content

Flaky unit test: oidc-keys ciphertext check searches base64 text for kty #2172

Open

Description

@neuromechanist

backend/test/oidc-keys.test.ts has an assertion that fails by chance: the test "the private key is ciphertext, readable only under OIDC_SECRET > the stored private key is not a JSON Web Key and holds none of its members" asserts expect(row.private_jwk_encrypted).not.toContain("kty") (line 172).

The stored value is base64 ciphertext of random bytes, so the three characters kty appear in it with a small probability on every run (about one in 262,144 per position, a few thousand characters per value: roughly a one percent chance per run, and the test checks several members).

Observed: one failure in the unit-pure shard 1/6 of run 43625110529 on nemarOrg/nemar-cli (2026-11-14, pull request into dev from the portable compute epic), where the received ciphertext contained kty; the rerun of the job passed. Nothing in that pull request touches the key code.

Suggested fix: do not search the encoded text for member names. Assert what the test means instead: that JSON.parse of the stored value throws (already asserted on the line above) and that the decrypted bytes under the right secret parse to a key with kty, or search the decoded ciphertext bytes for the UTF-8 member names (a random 3-byte match there is about one in 16 million).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions