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

Function TestElementToBytesArtifactResponseInSOAPEnvelope

element_to_bytes_test.go:74–88  ·  view source on GitHub ↗

In the artifact binding the SAML prefixes are often declared on the SOAP envelope. The assertion nested in the ArtifactResponse must still bind.

(t *testing.T)

Source from the content-addressed store, hash-verified

72// In the artifact binding the SAML prefixes are often declared on the SOAP
73// envelope. The assertion nested in the ArtifactResponse must still bind.
74func TestElementToBytesArtifactResponseInSOAPEnvelope(t *testing.T) {
75 const envelope = `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">` +
76 `<soap:Body><samlp:ArtifactResponse ID="ar" InResponseTo="req"><samlp:Response ID="r"><saml:Issuer>idp</saml:Issuer>` +
77 `<saml:Assertion ID="a"><saml:Issuer>idp</saml:Issuer><saml:Subject><saml:NameID>alice</saml:NameID></saml:Subject></saml:Assertion>` +
78 `</samlp:Response></samlp:ArtifactResponse></soap:Body></soap:Envelope>`
79 el := mustFindElement(t, envelope, "//ArtifactResponse")
80 assertStandalone(t, el)
81
82 var artifactResponse ArtifactResponse
83 assert.Assert(t, unmarshalElement(el, &artifactResponse))
84 assert.Check(t, is.Equal("req", artifactResponse.InResponseTo))
85 assert.Assert(t, artifactResponse.Response.Assertion != nil)
86 assert.Assert(t, artifactResponse.Response.Assertion.Subject != nil)
87 assert.Check(t, is.Equal("alice", artifactResponse.Response.Assertion.Subject.NameID.Value))
88}
89
90// The nearest declaration of a prefix wins over one further out, and a
91// declaration on the element itself is never overridden.

Callers

nothing calls this directly

Calls 3

mustFindElementFunction · 0.85
assertStandaloneFunction · 0.85
unmarshalElementFunction · 0.85

Tested by

no test coverage detected