Menu

1 / 2

Auth regression tests for CI: what to assert and why

DEV Community·Blue Hills·6 months ago
#OGHcgFaO
#pattern#cicd#devsecops#githubactions#token
Reading 0:00
15s threshold

Most teams I have worked with have one auth test in their suite. It looks like this:

test ( ' valid token verifies ' , () => { const token = signSync ({ sub : ' user-1 ' , aud : ' api://backend ' }, secret ); const result = verify ( token , options ); expect ( result . valid ). toBe ( true ); });

Enter fullscreen mode

Exit fullscreen mode

That test is fine. It is also a smoke test, not a regression suite. It catches the case where verification is completely broken. It does not catch the case where verification accepts tokens that should be rejected — which is most of the auth bugs that ship to prod.

A real auth regression suite asserts that invalid tokens fail with the right code . Each test pairs a token with the failure mode it should produce. If the policy quietly accepts a token that should fail, the suite fails the PR.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.