Skip to content

feat: static passcode generator for tests - #2793

Open
pvanek wants to merge 1 commit into
teamhanko:mainfrom
pvanek:feature/static-passcode-generator
Open

feat: static passcode generator for tests#2793
pvanek wants to merge 1 commit into
teamhanko:mainfrom
pvanek:feature/static-passcode-generator

Conversation

@pvanek

@pvanek pvanek commented Jul 29, 2026

Copy link
Copy Markdown

Description

New type of passcode charset is created: "static". It always returns a predefined code - 123456 for now.
This code generator is not targeted to real usage, its main purpose is to serve static codes in tests using Hanko in e.g. Docker compose with custom applications.

I want to run our integration test suite based on Hanko's docker compose file + additional containers for with our stack. The problem is with user registration tests. The verification code (email|) obviously always different and sent in the email body to MailSlurper.

Implementation

new "enum" value static for passcode_charset which returns 123456 for now.

Todos

This PR is a proposal for now, I'm pretty sure the team will have strong opinions about it.

New type of passcode charset is created: "static". It always returns a
predefined code - `123456` for now.
This code generator is not targeted to real usage, its main purpose is
to serve static codes in tests using Hanko in e.g. Docker compose with
custom applications.
@lfleischmann
lfleischmann marked this pull request as ready for review August 13, 2026 15:49

@lfleischmann lfleischmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope you don't mind I undrafted this. We decided to go ahead with this, just added some minor suggestions

}

func (g *staticPasscodeGenerator) Generate() (string, error) {
// this is just a POC for now. I can imagine config option for it, or an env variable...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// this is just a POC for now. I can imagine config option for it, or an env variable...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PasscodeCharset PasscodeCharset `yaml:"passcode_charset" json:"passcode_charset" koanf:"passcode_charset" jsonschema:"default=numeric,enum=numeric,enum=alphanumeric,enum=static"`

Comment on lines 23 to 24
// `passcode_charset` specifies the characters that can be used in passcodes.
// E.g. `numeric` allows only numbers, `alphanumeric` allows both numbers and letters.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// `passcode_charset` specifies the characters that can be used in passcodes.
// E.g. `numeric` allows only numbers, `alphanumeric` allows both numbers and letters. `static` returns always the same passcode 123456, it SHOULD ONLY BE USED FOR DEVELOPMENT/DEBUG/TESTING PURPOSES.

Just felt like blowing that up a bit 🙈

"static"
],
"description": "`passcode_charset` specifies the characters that can be used in passcodes.\nE.g. `numeric` allows only numbers, `alphanumeric` allows both numbers and letters.",
"description": "`passcode_charset` specifies the characters that can be used in passcodes.\nE.g. `numeric` allows only numbers, `alphanumeric` allows both numbers and letters, `static` returns always the same passcode 123456.\nThe `static` should be used in local test runs only.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hanko.config.json schema is generated via schema generate config command - so comments and jsonschema tags are the source of truth. Hence we should not update this file manually because on the next generation your additions would be gone.

See this comment.

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.

2 participants