Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr committed Dec 23, 2024
1 parent 5600b49 commit 2c6dc15
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions selfservice/strategy/code/test/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ func TestPersister(ctx context.Context, p interface {
go func() {
defer wg.Done()
_, err := p.UseRecoveryCode(ctx, f.ID, "i-do-not-exist")
if err == nil {
t.Error("should have rejected incorrect code")
if !assert.Error(t, err) {
return
}
if errors.Is(err, code.ErrCodeSubmittedTooOften) {
Expand All @@ -135,11 +134,9 @@ func TestPersister(ctx context.Context, p interface {
}()
}
wg.Wait()
require.EqualValues(t, 5, wrongCode, "should reject 5 times with wrong code")
require.EqualValues(t, 45, tooOften, "should reject 45 times with too often")

_, err = p.UseRecoveryCode(ctx, f.ID, "i-do-not-exist")
require.ErrorIs(t, err, code.ErrCodeSubmittedTooOften)
require.EqualValues(t, 50, wrongCode+tooOften, "all 50 attempts made")
require.LessOrEqual(t, wrongCode, 5, "max. 5 attempts have gone past the duplication check")

// Submit again, just to be sure
_, err = p.UseRecoveryCode(ctx, f.ID, "i-do-not-exist")
Expand Down

0 comments on commit 2c6dc15

Please sign in to comment.