(t *testing.T)
| 71 | } |
| 72 | |
| 73 | func 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 | |
| 107 | func TestSPCanProduceMetadataWithEncryptionCert(t *testing.T) { |
| 108 | test := NewServiceProviderTest(t) |
nothing calls this directly
no test coverage detected