Skip to content

Add CI that tests the step-up authentication flow - #7

Merged
HarshCasper merged 4 commits into
mainfrom
ci/assert-step-up-flow
Oct 13, 2026
Merged

HarshCasper merged 4 commits into
mainfrom
ci/assert-step-up-flow

Conversation

@HarshCasper

@HarshCasper HarshCasper commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

The repo had no CI and no test.

New test.sh (make test) walks the step-up flow through the deployed API:

  • creates a Cognito user and signs in with USER_PASSWORD_AUTH
  • GET /info returns 401 without a token, 403 with a malformed token, and 200 with the access token
  • with a STEP_UP_REQUIRED rule for /transfer in step-up-auth-setting, POST /transfer returns 401 and the authorizer records a STEP_UP_REQUIRED session in step-up-auth-session
  • /initiate-auth returns MAYBE_SOFTWARE_TOKEN_STEP_UP for a user without MFA
  • after associating a software token, /respond-to-challenge rejects a malformed code and accepts a generated TOTP code
  • the session is STEP_UP_COMPLETED and POST /transfer returns 200
  • the rule and the user are removed on exit

Sample fixes:

  • Lambdas move from the deprecated nodejs18.x to nodejs22.x.
  • The request authorizer now has AuthorizerResultTtlInSeconds: 0, set on the L1 resource because resultsCacheTtl expects a Duration from a different @aws-cdk/core copy and the stack failed to compile. The decision depends on the step-up session, which changes between requests with the same token, and the returned policy only covers the called method. With the default 5 minute cache, the step-up result could not take effect and calls to other methods reused the wrong policy.
  • The challenge responder now awaits the session update before returning, so the Lambda cannot finish before the session is marked completed.
  • The build scripts ran as #!/bin/sh but use [ "$1" == ... ], which dash rejects. On Linux the compressed module step was silently skipped and make build failed. They now use #!/bin/bash.
  • make install also installs the CDK CLI and yarn, which make deploy needs. New make test target, and the README documents it.

New workflow: Node 22, make install, make build, make start, make deploy, make test, and LocalStack logs on failure.

https://claude.ai/code/session_01DZfDmzUBPqNAu3yFKyfCNM

Add test.sh and a workflow that deploys the stacks and walks the step-up
flow through the API: token checks, a STEP_UP_REQUIRED rule, a TOTP
challenge and the completed session. Move the Lambdas to Node.js 22,
disable authorizer caching and await the session update.

Claude-Session: https://claude.ai/code/session_01DZfDmzUBPqNAu3yFKyfCNM
The build scripts use `[ "$1" == ... ]`, which dash rejects. On Ubuntu,
where /bin/sh is dash, the compressed module step was skipped and the
Lambda build failed. macOS runs /bin/sh as bash, so it worked there.

Claude-Session: https://claude.ai/code/session_01DZfDmzUBPqNAu3yFKyfCNM
resultsCacheTtl expects a Duration from a different @aws-cdk/core copy
than the one the app imports, so the stack failed to compile.

Claude-Session: https://claude.ai/code/session_01DZfDmzUBPqNAu3yFKyfCNM
@HarshCasper
HarshCasper merged commit 27568aa into main Oct 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant