mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +00:00
76 lines
1.5 KiB
Go
76 lines
1.5 KiB
Go
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)
|
|
})
|
|
}
|
|
}
|