mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +00:00
feat(api/v2): implement U2F session check (#6339)
This commit is contained in:
75
internal/command/session_model_test.go
Normal file
75
internal/command/session_model_test.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
func TestSessionWriteModel_AuthMethodTypes(t *testing.T) {
|
||||
type fields struct {
|
||||
PasswordCheckedAt time.Time
|
||||
IntentCheckedAt time.Time
|
||||
WebAuthNCheckedAt time.Time
|
||||
WebAuthNUserVerified bool
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want []domain.UserAuthMethodType
|
||||
}{
|
||||
{
|
||||
name: "password",
|
||||
fields: fields{
|
||||
PasswordCheckedAt: testNow,
|
||||
},
|
||||
want: []domain.UserAuthMethodType{
|
||||
domain.UserAuthMethodTypePassword,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "passwordless",
|
||||
fields: fields{
|
||||
WebAuthNCheckedAt: testNow,
|
||||
WebAuthNUserVerified: true,
|
||||
},
|
||||
want: []domain.UserAuthMethodType{
|
||||
domain.UserAuthMethodTypePasswordless,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "u2f",
|
||||
fields: fields{
|
||||
WebAuthNCheckedAt: testNow,
|
||||
WebAuthNUserVerified: false,
|
||||
},
|
||||
want: []domain.UserAuthMethodType{
|
||||
domain.UserAuthMethodTypeU2F,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "intent",
|
||||
fields: fields{
|
||||
IntentCheckedAt: testNow,
|
||||
},
|
||||
want: []domain.UserAuthMethodType{
|
||||
domain.UserAuthMethodTypeIDP,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
wm := &SessionWriteModel{
|
||||
PasswordCheckedAt: tt.fields.PasswordCheckedAt,
|
||||
IntentCheckedAt: tt.fields.IntentCheckedAt,
|
||||
WebAuthNCheckedAt: tt.fields.WebAuthNCheckedAt,
|
||||
WebAuthNUserVerified: tt.fields.WebAuthNUserVerified,
|
||||
}
|
||||
got := wm.AuthMethodTypes()
|
||||
assert.Equal(t, got, tt.want)
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user