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

Function TestSimpleSignDecodesLineWrappedSpecExample

simplesign_binding_test.go:130–159  ·  view source on GitHub ↗

The example form values in sstc-saml-binding-simplesign-cs-01 section 2.11 are line wrapped; they must still decode.

(t *testing.T)

Source from the content-addressed store, hash-verified

128// The example form values in sstc-saml-binding-simplesign-cs-01 section 2.11
129// are line wrapped; they must still decode.
130func TestSimpleSignDecodesLineWrappedSpecExample(t *testing.T) {
131 const samlRequest = "PHNhbWxwOkxvZ291dFJlcXVlc3QgeG1sbnM6c2FtbHA9InVybjpvYXNpczpuYW1l\n" +
132 "czp0YzpTQU1MOjIuMDpwcm90b2NvbCIgeG1sbnM9InVybjpvYXNpczpuYW1lczp0\n" +
133 "YzpTQU1MOjIuMDphc3NlcnRpb24iCiAgICBJRD0iZDJiN2MzODhjZWMzNmZhN2Mz\n" +
134 "OWMyOGZkMjk4NjQ0YTgiIElzc3VlSW5zdGFudD0iMjAwNC0wMS0yMVQxOTowMDo0\n" +
135 "OVoiIFZlcnNpb249IjIuMCI+CiAgICA8SXNzdWVyPmh0dHBzOi8vSWRlbnRpdHlQ\n" +
136 "cm92aWRlci5jb20vU0FNTDwvSXNzdWVyPgogICAgPE5hbWVJRCBGb3JtYXQ9InVy\n" +
137 "bjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpuYW1laWQtZm9ybWF0OnBlcnNpc3Rl\n" +
138 "bnQiPjAwNWEwNmUwLWFkODItMTEwZC1hNTU2LTAwNDAwNWIxM2EyYjwvTmFtZUlE\n" +
139 "PgogICAgPHNhbWxwOlNlc3Npb25JbmRleD4xPC9zYW1scDpTZXNzaW9uSW5kZXg+\n" +
140 "Cjwvc2FtbHA6TG9nb3V0UmVxdWVzdD4K"
141 v := url.Values{}
142 v.Set("RelayState", "0043bfc1bc45110dae17004005b13a2b")
143 v.Set("SAMLRequest", samlRequest)
144 v.Set("SigAlg", "http://www.w3.org/2000/09/xmldsig#rsa-sha1")
145 v.Set("Signature", "J4if7CCeHVfn4H6hMZN5fijOjQIyZ/laoFUZWz4LCRN3J82UeoyYvAiTDoQOUZHT\n"+
146 "RJNU1lWGub1pW4QR9MH5bwfLEa8XDivA118dR0Q7YN5L/U5rmbxnGlQ9pV0jT44c\n"+
147 "RNeqtbLW0YF4plfcqg7E5iOSljE3QLkiaAdkAec2a4HwPFkn/JP7wO11Mc6kU8ML\n"+
148 "CBbZAa3+94ZvVwHBEdyCdU+1yEvf+JGxTw66BwI2ugmPfxvoJdsOOAWwS3KhAFhL\n"+
149 "LSPXnhb3nd/ovKNNV/khZYwqsFTFNTMA+0JraKsZiCRtEZzEPXaP9KilrjPIIvRV\n"+
150 "xDQhETj96flk5zMkEM3ruw==")
151 m, err := parseSimpleSignRequest(simpleSignPost(t, "https://sp.example.com/saml/slo", v), "SAMLRequest")
152 assert.NilError(t, err)
153 content := string(m.signedContent())
154 assert.Check(t, strings.HasPrefix(content, "SAMLRequest=<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" xmlns=\"urn:oasis:names:tc:SAML:2.0:assertion\"\n ID=\"d2b7c388cec36fa7c39c28fd298644a8\""), content)
155 assert.Check(t, strings.HasSuffix(content, "</samlp:LogoutRequest>\n&RelayState=0043bfc1bc45110dae17004005b13a2b&SigAlg=http://www.w3.org/2000/09/xmldsig#rsa-sha1"), content)
156 _, sig, err := decodeDetachedSignature(m.SigAlg, m.Signature, simpleSignBase64)
157 assert.NilError(t, err)
158 assert.Check(t, is.Len(sig, 256))
159}
160
161// simpleSignResponse returns a valid Response for e.sp whose assertion is
162// not signed.

Callers

nothing calls this directly

Calls 5

parseSimpleSignRequestFunction · 0.85
simpleSignPostFunction · 0.85
decodeDetachedSignatureFunction · 0.85
signedContentMethod · 0.80
LenMethod · 0.80

Tested by

no test coverage detected