forked from Versent/saml2aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saml_test.go
44 lines (34 loc) · 1.05 KB
/
saml_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
package saml2aws
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
)
func TestExtractAwsRoles(t *testing.T) {
data, err := ioutil.ReadFile("testdata/assertion.xml")
assert.Nil(t, err)
roles, err := ExtractAwsRoles(data)
assert.Nil(t, err)
assert.Len(t, roles, 2)
}
func TestExtractSessionDuration(t *testing.T) {
data, err := ioutil.ReadFile("testdata/assertion.xml")
assert.Nil(t, err)
duration, err := ExtractSessionDuration(data)
assert.Nil(t, err)
assert.Equal(t, int64(28800), duration)
}
func TestExtractDestinationURL(t *testing.T) {
data, err := ioutil.ReadFile("testdata/assertion.xml")
assert.Nil(t, err)
destination, err := ExtractDestinationURL(data)
assert.Nil(t, err)
assert.Equal(t, "https://signin.aws.amazon.com/saml", destination)
}
func TestExtractDestinationURL2(t *testing.T) {
data, err := ioutil.ReadFile("testdata/assertion_no_destination.xml")
assert.Nil(t, err)
destination, err := ExtractDestinationURL(data)
assert.Nil(t, err)
assert.Equal(t, "https://signin.aws.amazon.com/saml", destination)
}