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

Function TestXHTMLServiceProviderForms

xhtml_forms_test.go:138–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestXHTMLServiceProviderForms(t *testing.T) {
139 test := NewIdentityProviderTest(t, applyKey)
140 sp := &test.SP
141
142 authnRequest, err := sp.MakeAuthenticationRequest(xhtmlAwkwardURL, HTTPPostBinding, HTTPPostBinding)
143 assert.NilError(t, err)
144 logoutRequest, err := sp.MakeLogoutRequest(xhtmlAwkwardURL, "alice")
145 assert.NilError(t, err)
146 logoutResponse, err := sp.MakeLogoutResponse(xhtmlAwkwardURL, "id-1234")
147 assert.NilError(t, err)
148
149 for name, fragment := range map[string][]byte{
150 "AuthnRequest": authnRequest.PostWithNonce(xhtmlAwkwardRelay, "n0nce"),
151 "LogoutRequest": logoutRequest.PostWithNonce(xhtmlAwkwardRelay, "n0nce"),
152 "LogoutResponse": logoutResponse.PostWithNonce(xhtmlAwkwardRelay, ""),
153 } {
154 t.Run(name, func(t *testing.T) {
155 assertXHTMLDocument(t, wrapXHTML(fragment))
156 })
157 }
158
159 for name, tmpl := range map[string]interface {
160 Execute(io.Writer, any) error
161 }{
162 "SimpleSign request": simpleSignRequestFormTemplate,
163 "SimpleSign response": simpleSignResponseFormTemplate,
164 } {
165 t.Run(name, func(t *testing.T) {
166 var buf bytes.Buffer
167 assert.NilError(t, tmpl.Execute(&buf, simpleSignFormData{
168 URL: xhtmlAwkwardURL,
169 Message: "PHNhbWxwOlJlc3BvbnNlLz4+/w==",
170 RelayState: xhtmlAwkwardRelay,
171 SigAlg: dsig.RSASHA256SignatureMethod,
172 Signature: "c2lnbmF0dXJl+/w==",
173 Nonce: "n0nce",
174 }))
175 assertXHTMLDocument(t, wrapXHTML(buf.Bytes()))
176 })
177 }
178}
179
180// signedRedirectSSORequest returns an HTTP-Redirect AuthnRequest to the IdP
181// whose query string is signed, with the given Destination.

Callers

nothing calls this directly

Calls 8

NewIdentityProviderTestFunction · 0.85
wrapXHTMLFunction · 0.85
MakeLogoutRequestMethod · 0.80
BytesMethod · 0.80
assertXHTMLDocumentFunction · 0.70
MakeLogoutResponseMethod · 0.45
PostWithNonceMethod · 0.45

Tested by

no test coverage detected