Skip to content

Commit

Permalink
test: amr persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent eedb60b commit b0b2d81
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions session/test/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func TestPersister(ctx context.Context, conf *config.Config, p interface {
var expected session.Session
require.NoError(t, faker.FakeData(&expected))
expected.Active = true
expected.AMR = session.AuthenticationMethods{
{Method: identity.CredentialsTypePassword, CompletedAt: time.Now().UTC().Round(time.Second)},
{Method: identity.CredentialsTypeOIDC, CompletedAt: time.Now().UTC().Round(time.Second)},
}
require.NoError(t, p.CreateIdentity(ctx, expected.Identity))

assert.Equal(t, uuid.Nil, expected.ID)
Expand Down Expand Up @@ -87,6 +91,15 @@ func TestPersister(ctx context.Context, conf *config.Config, p interface {
check(actual, err)
assert.Equal(t, identity.AuthenticatorAssuranceLevel3, actual.AuthenticatorAssuranceLevel)
})

t.Run("case=remove amr and update", func(t *testing.T) {
expected.AMR = nil
require.NoError(t, p.UpsertSession(ctx, &expected))

actual, err := p.GetSessionByToken(ctx, expected.Token)
check(actual, err)
assert.Empty(t, actual.AMR)
})
})

t.Run("case=delete session", func(t *testing.T) {
Expand Down

0 comments on commit b0b2d81

Please sign in to comment.