mirror of
https://gh-proxy.org/https://github.com/klinsmaya/new-api.git
synced 2026-11-08 01:17:09 +08:00
test(security): match the email code only as a whole number
The email binding audit test failed now and then because it searched the whole audit JSON for the six-digit code. Audit event and request IDs start with a long run of time digits, so a random code sometimes appeared inside one of them. Treat only a code that no other digit touches as a leak.
This commit is contained in:
@@ -645,7 +645,9 @@ func TestSecurityAccountEmailConfirmationAndAudit(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, string(encoded), "user.binding_bind")
|
||||
assert.NotContains(t, string(encoded), flow.FlowToken)
|
||||
assert.NotContains(t, string(encoded), newCode)
|
||||
// Audit event and request IDs are long runs of time digits that can
|
||||
// contain the six-digit code by chance; only the whole code is a leak.
|
||||
assert.NotRegexp(t, `(^|\D)`+newCode+`(\D|$)`, string(encoded))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user