forked from Versent/saml2aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saml2aws_test.go
50 lines (41 loc) · 1.15 KB
/
saml2aws_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package saml2aws
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/versent/saml2aws/v2/pkg/cfg"
"github.com/versent/saml2aws/v2/pkg/creds"
)
func TestProviderList_Keys(t *testing.T) {
names := MFAsByProvider.Names()
require.Len(t, names, 18)
}
func TestProviderList_Mfas(t *testing.T) {
mfas := MFAsByProvider.Mfas("Ping")
require.Len(t, mfas, 1)
}
func TestProviderInvalid(t *testing.T) {
account := &cfg.IDPAccount{
Provider: "foo1",
}
_, err := NewSAMLClient(account)
assert.ErrorContains(t, err, "Invalid provider: foo1")
}
func TestProviderAzureADInvalidMFA(t *testing.T) {
account := &cfg.IDPAccount{
Provider: "AzureAD",
}
_, err := NewSAMLClient(account)
assert.ErrorContains(t, err, "Invalid MFA type: ")
}
func TestProviderAzureADMFA(t *testing.T) {
account := &cfg.IDPAccount{
Provider: "AzureAD",
MFA: "PhoneAppOTP",
}
client, err := NewSAMLClient(account)
assert.Nil(t, err)
loginDetails := &creds.LoginDetails{Username: "testuser", Password: "testtestlol", URL: "https://id.example.com", MFAToken: "123456"}
err = client.Validate(loginDetails)
assert.Nil(t, err)
}