(t *testing.T, ctx context.Context, provider Provider)
| 434 | } |
| 435 | |
| 436 | func testOTPOperations(t *testing.T, ctx context.Context, provider Provider) { |
| 437 | otp := &schemas.OTP{ |
| 438 | Email: "test_" + uuid.New().String() + "@test.com", |
| 439 | Otp: "123456", |
| 440 | ExpiresAt: time.Now().Add(5 * time.Minute).Unix(), |
| 441 | } |
| 442 | |
| 443 | // Test UpsertOTP |
| 444 | created, err := provider.UpsertOTP(ctx, otp) |
| 445 | assert.NoError(t, err) |
| 446 | assert.NotNil(t, created) |
| 447 | |
| 448 | // Test GetOTPByEmail |
| 449 | fetched, err := provider.GetOTPByEmail(ctx, otp.Email) |
| 450 | assert.NoError(t, err) |
| 451 | assert.Equal(t, otp.Otp, fetched.Otp) |
| 452 | |
| 453 | // For same email address, upsert should update the OTP |
| 454 | otp.Otp = "789012" |
| 455 | updated, err := provider.UpsertOTP(ctx, otp) |
| 456 | assert.NoError(t, err) |
| 457 | assert.NotNil(t, updated) |
| 458 | assert.Equal(t, otp.Otp, updated.Otp) |
| 459 | |
| 460 | // Test DeleteOTP |
| 461 | err = provider.DeleteOTP(ctx, updated) |
| 462 | assert.NoError(t, err) |
| 463 | } |
| 464 | |
| 465 | func testAuthenticatorOperations(t *testing.T, ctx context.Context, provider Provider) { |
| 466 | auth := &schemas.Authenticator{ |
no test coverage detected