Skip to content

Commit

Permalink
test: session activate
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 19, 2021
1 parent b0b2d81 commit c86fa03
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,18 @@ func TestSession(t *testing.T) {
assert.EqualValues(t, identity.CredentialsTypeOIDC, s.AMR[0].Method)
assert.EqualValues(t, identity.CredentialsTypeRecoveryLink, s.AMR[1].Method)
})

t.Run("case=activate", func(t *testing.T) {
s := session.NewInactiveSession()
require.NoError(t, s.Activate(&identity.Identity{State: identity.StateActive}, conf, authAt))
assert.True(t, s.Active)
assert.Equal(t, identity.NoAuthenticatorAssuranceLevel, s.AuthenticatorAssuranceLevel)
assert.Equal(t, authAt, s.AuthenticatedAt)

s = session.NewInactiveSession()
require.ErrorIs(t, s.Activate(&identity.Identity{State: identity.StateInactive}, conf, authAt), session.ErrIdentityDisabled)
assert.False(t, s.Active)
assert.Equal(t, identity.NoAuthenticatorAssuranceLevel, s.AuthenticatorAssuranceLevel)
assert.Empty(t, s.AuthenticatedAt)
})
}

0 comments on commit c86fa03

Please sign in to comment.