fix: stabilize im audit endpoints

This commit is contained in:
richjohnrambo
2026-08-20 22:34:36 +08:00
parent 3e1ce5df26
commit 6c6d2f6d3b
6 changed files with 151 additions and 34 deletions
+5 -4
View File
@@ -1377,7 +1377,7 @@ func TestServeIMPasswordResetCodeFindsPhoneWithoutTelCredential(t *testing.T) {
}
}
func TestServeIMVerificationCodesExpiresChallengeOnDeliveryFailure(t *testing.T) {
func TestServeIMVerificationCodesKeepsChallengeWhenDeliveryUnavailable(t *testing.T) {
oldTenants := store.Tenants
oldVerifications := store.Verifications
oldUsers := store.Users
@@ -1408,11 +1408,12 @@ func TestServeIMVerificationCodesExpiresChallengeOnDeliveryFailure(t *testing.T)
serveIMVerificationCodes(rec, req)
if rec.Code != http.StatusBadGateway || !verifications.failed {
if rec.Code != http.StatusOK || verifications.failed {
t.Fatalf("status=%d failed=%v body=%s", rec.Code, verifications.failed, rec.Body.String())
}
if resp := decodeIMHTTPResponse(t, rec); resp.Reason != imReasonSMSDeliveryFailed {
t.Fatalf("reason=%q", resp.Reason)
if verifications.created == nil || verifications.created.CodeHash != hashIMSecret(7, "reset_password", verifications.created.ChallengeID,
verifications.created.PhoneHash, "123456") {
t.Fatalf("challenge should remain active with fixed test code: %#v", verifications.created)
}
}