MCPcopy Create free account
hub / github.com/crewjam/saml / TestSPCanSetAuthenticationNameIDFormat

Function TestSPCanSetAuthenticationNameIDFormat

service_provider_test.go:73–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestSPCanSetAuthenticationNameIDFormat(t *testing.T) {
74 test := NewServiceProviderTest(t)
75
76 s := ServiceProvider{
77 Key: test.Key,
78 Certificate: test.Certificate,
79 MetadataURL: mustParseURL("https://15661444.ngrok.io/saml2/metadata"),
80 AcsURL: mustParseURL("https://15661444.ngrok.io/saml2/acs"),
81 }
82
83 // defaults to "transient"
84 req, err := s.MakeAuthenticationRequest("", HTTPRedirectBinding, HTTPPostBinding)
85 assert.Check(t, err)
86 assert.Check(t, is.Equal(string(TransientNameIDFormat), *req.NameIDPolicy.Format))
87
88 // explicitly set to "transient"
89 s.AuthnNameIDFormat = TransientNameIDFormat
90 req, err = s.MakeAuthenticationRequest("", HTTPRedirectBinding, HTTPPostBinding)
91 assert.Check(t, err)
92 assert.Check(t, is.Equal(string(TransientNameIDFormat), *req.NameIDPolicy.Format))
93
94 // explicitly set to "unspecified"
95 s.AuthnNameIDFormat = UnspecifiedNameIDFormat
96 req, err = s.MakeAuthenticationRequest("", HTTPRedirectBinding, HTTPPostBinding)
97 assert.Check(t, err)
98 assert.Check(t, is.Equal("", *req.NameIDPolicy.Format))
99
100 // explicitly set to "emailAddress"
101 s.AuthnNameIDFormat = EmailAddressNameIDFormat
102 req, err = s.MakeAuthenticationRequest("", HTTPRedirectBinding, HTTPPostBinding)
103 assert.Check(t, err)
104 assert.Check(t, is.Equal(string(EmailAddressNameIDFormat), *req.NameIDPolicy.Format))
105}
106
107func TestSPCanProduceMetadataWithEncryptionCert(t *testing.T) {
108 test := NewServiceProviderTest(t)

Callers

nothing calls this directly

Calls 3

NewServiceProviderTestFunction · 0.85
mustParseURLFunction · 0.50

Tested by

no test coverage detected