MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / testOTPOperations

Function testOTPOperations

internal/storage/provider_test.go:436–463  ·  view source on GitHub ↗
(t *testing.T, ctx context.Context, provider Provider)

Source from the content-addressed store, hash-verified

434}
435
436func 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
465func testAuthenticatorOperations(t *testing.T, ctx context.Context, provider Provider) {
466 auth := &schemas.Authenticator{

Callers 1

TestStorageProviderFunction · 0.85

Calls 4

UpsertOTPMethod · 0.65
GetOTPByEmailMethod · 0.65
DeleteOTPMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected