🧪 test(bdd): admin metadata endpoint security property — no secret leak
Activates a new @critical @admin-introspection scenario in features/jwt/jwt_secret_retention.feature that exercises the GET /api/v1/admin/jwt/secrets endpoint added in PR #51. The scenario asserts the SECURITY-CRITICAL property: the metadata endpoint exposes structure (count + per-secret is_primary, age, fingerprint) WITHOUT leaking secret values. If a future change accidentally adds the secret value to the response, this test fails loud: SECURITY: response leaked the secret value "test-secret-do-not-leak..." Specifically, the BDD asserts: - After adding a secondary secret with a known value, GET returns 200 - The response contains 2 secrets in count - The response does NOT contain the secret value anywhere - Every entry has a non-empty SHA-256 fingerprint 4 new step definitions added to pkg/bdd/steps/jwt_retention_steps.go: - iAddASecondaryJWTSecretNamed (parameterised by secret value) - iRequestTheJWTSecretsMetadataEndpoint - theMetadataShouldContainNSecrets - theMetadataShouldNotContainTheSecretValue (the security check) - everySecretInTheMetadataShouldHaveASHA256Fingerprint Tests: - Scenario passes via @admin-introspection tag filter. - Full BDD suite (auth/config/greet/health/info/jwt) green. The pre-existing @todo scenarios (Multiple secrets with different ages, Cleanup frequency configuration, etc.) remain @todo — they require arbitrary timestamp setup or manual cleanup triggers that aren't exposed via API, by design. Documented as future test-infrastructure work.
This commit is contained in:
@@ -173,6 +173,12 @@ func InitializeAllSteps(ctx *godog.ScenarioContext, client *testserver.Client, s
|
||||
ctx.Step(`^I should receive configuration validation error$`, sc.jwtRetentionSteps.iShouldReceiveConfigurationValidationError)
|
||||
ctx.Step(`^the error should mention "([^"]*)"$`, sc.jwtRetentionSteps.theErrorShouldMention)
|
||||
ctx.Step(`^I have enabled Prometheus metrics$`, sc.jwtRetentionSteps.iHaveEnabledPrometheusMetrics)
|
||||
// Admin metadata introspection steps (PR #51 + admin-introspection scenario)
|
||||
ctx.Step(`^I add a secondary JWT secret "([^"]*)"$`, sc.jwtRetentionSteps.iAddASecondaryJWTSecretNamed)
|
||||
ctx.Step(`^I request the JWT secrets metadata endpoint$`, sc.jwtRetentionSteps.iRequestTheJWTSecretsMetadataEndpoint)
|
||||
ctx.Step(`^the metadata should contain (\d+) secrets$`, sc.jwtRetentionSteps.theMetadataShouldContainNSecrets)
|
||||
ctx.Step(`^the metadata should NOT contain the secret value "([^"]*)"$`, sc.jwtRetentionSteps.theMetadataShouldNotContainTheSecretValue)
|
||||
ctx.Step(`^every secret in the metadata should have a SHA-256 fingerprint$`, sc.jwtRetentionSteps.everySecretInTheMetadataShouldHaveASHA256Fingerprint)
|
||||
ctx.Step(`^I should see "([^"]*)" metric increment$`, sc.jwtRetentionSteps.iShouldSeeMetricIncrement)
|
||||
ctx.Step(`^I should see "([^"]*)" metric decrease$`, sc.jwtRetentionSteps.iShouldSeeMetricDecrease)
|
||||
ctx.Step(`^I should see "([^"]*)" histogram update$`, sc.jwtRetentionSteps.iShouldSeeHistogramUpdate)
|
||||
|
||||
Reference in New Issue
Block a user