forked from CiscoM31/gosaml2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise.go
40 lines (34 loc) · 1.13 KB
/
exercise.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
// +build go1.7
package providertests
import (
"testing"
saml2 "github.com/russellhaering/gosaml2"
"github.com/stretchr/testify/require"
)
func ExerciseProviderTestScenarios(t *testing.T, scenarios []ProviderTestScenario) {
for _, scenario := range scenarios {
t.Run(scenario.ScenarioName, func(t *testing.T) {
_, err := saml2.DecodeUnverifiedBaseResponse(scenario.Response)
// DecodeUnverifiedBaseResponse is more permissive than RetrieveAssertionInfo.
// If an error _is_ returned it should match, but it is OK for no error to be
// returned even when one is expected during full validation.
if err != nil {
scenario.CheckError(t, err)
}
assertionInfo, err := scenario.ServiceProvider.RetrieveAssertionInfo(scenario.Response)
if scenario.CheckError != nil {
scenario.CheckError(t, err)
} else {
require.NoError(t, err)
}
if err == nil {
if scenario.CheckWarningInfo != nil {
scenario.CheckWarningInfo(t, assertionInfo.WarningInfo)
} else {
require.False(t, assertionInfo.WarningInfo.InvalidTime)
require.False(t, assertionInfo.WarningInfo.NotInAudience)
}
}
})
}
}