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

Function TestSimpleSignSignedContent

simplesign_binding_test.go:82–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestSimpleSignSignedContent(t *testing.T) {
83 // sstc-saml-binding-simplesign-cs-01 section 2.5: the raw XML (not the
84 // base64 text), the RelayState and the SigAlg, none URL encoded and
85 // whitespace kept as is.
86 xml := []byte("<samlp:LogoutRequest ID=\"a&amp;b\">\n <Issuer>x</Issuer>\r\n</samlp:LogoutRequest>")
87 assert.Equal(t,
88 string(simpleSignSignedContent("SAMLRequest", xml, "a b&c=d/é", true, dsig.RSASHA1SignatureMethod)),
89 "SAMLRequest=<samlp:LogoutRequest ID=\"a&amp;b\">\n <Issuer>x</Issuer>\r\n</samlp:LogoutRequest>"+
90 "&RelayState=a b&c=d/é&SigAlg=http://www.w3.org/2000/09/xmldsig#rsa-sha1")
91 assert.Equal(t,
92 string(simpleSignSignedContent("SAMLResponse", []byte("<r/>"), "", false, dsig.RSASHA256SignatureMethod)),
93 "SAMLResponse=<r/>&SigAlg=http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")
94 // A RelayState control that is present but empty is still signed, as
95 // OpenSAML's SAML2HTTPPostSimpleSignSecurityHandler does.
96 assert.Equal(t,
97 string(simpleSignSignedContent("SAMLResponse", []byte("<r/>"), "", true, dsig.RSASHA256SignatureMethod)),
98 "SAMLResponse=<r/>&RelayState=&SigAlg=http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")
99}
100
101// TestSimpleSignKnownAnswer pins the whole signing path: RSA PKCS#1 v1.5 is
102// deterministic, so the Signature for a fixed message, relay state and key

Callers

nothing calls this directly

Calls 1

simpleSignSignedContentFunction · 0.85

Tested by

no test coverage detected