mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
ee26f99ebf
This PR changes the information stored on the SessionLinkedEvent and (OIDC Session) AddedEvent from OIDC AMR strings to domain.UserAuthMethodTypes, so no information is lost in the process (e.g. authentication with an IDP)
70 lines
1.2 KiB
Go
70 lines
1.2 KiB
Go
package oidc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
)
|
|
|
|
func TestAMR(t *testing.T) {
|
|
type args struct {
|
|
methodTypes []domain.UserAuthMethodType
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want []string
|
|
}{
|
|
{
|
|
"no checks, empty",
|
|
args{
|
|
nil,
|
|
},
|
|
[]string{},
|
|
},
|
|
{
|
|
"pw checked",
|
|
args{
|
|
[]domain.UserAuthMethodType{domain.UserAuthMethodTypePassword},
|
|
},
|
|
[]string{PWD},
|
|
},
|
|
{
|
|
"passkey checked",
|
|
args{
|
|
[]domain.UserAuthMethodType{domain.UserAuthMethodTypePasswordless},
|
|
},
|
|
[]string{UserPresence, MFA},
|
|
},
|
|
{
|
|
"u2f checked",
|
|
args{
|
|
[]domain.UserAuthMethodType{domain.UserAuthMethodTypeU2F},
|
|
},
|
|
[]string{UserPresence},
|
|
},
|
|
{
|
|
"otp checked",
|
|
args{
|
|
[]domain.UserAuthMethodType{domain.UserAuthMethodTypeOTP},
|
|
},
|
|
[]string{OTP},
|
|
},
|
|
{
|
|
"multiple checked",
|
|
args{
|
|
[]domain.UserAuthMethodType{domain.UserAuthMethodTypePassword, domain.UserAuthMethodTypeU2F},
|
|
},
|
|
[]string{PWD, UserPresence, MFA},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := AuthMethodTypesToAMR(tt.args.methodTypes)
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|