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

Function TestElementToBytesInheritedDefaultNamespace

element_to_bytes_test.go:41–53  ·  view source on GitHub ↗

An assertion in the default namespace, declared on the enclosing Response (as FusionAuth sends it), must keep that namespace when serialized alone.

(t *testing.T)

Source from the content-addressed store, hash-verified

39// An assertion in the default namespace, declared on the enclosing Response
40// (as FusionAuth sends it), must keep that namespace when serialized alone.
41func TestElementToBytesInheritedDefaultNamespace(t *testing.T) {
42 const response = `<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">` +
43 `<Assertion ID="a"><Issuer>idp</Issuer><Subject><NameID>alice</NameID></Subject></Assertion>` +
44 `</samlp:Response>`
45 el := mustFindElement(t, response, "//Assertion")
46 assertStandalone(t, el)
47
48 var assertion Assertion
49 assert.Assert(t, unmarshalElement(el, &assertion))
50 assert.Check(t, is.Equal("idp", assertion.Issuer.Value))
51 assert.Assert(t, assertion.Subject != nil && assertion.Subject.NameID != nil)
52 assert.Check(t, is.Equal("alice", assertion.Subject.NameID.Value))
53}
54
55// A prefix declared on an ancestor that differs from the element's own
56// prefix (here ds:, declared only on the Response) must still be declared.

Callers

nothing calls this directly

Calls 3

mustFindElementFunction · 0.85
assertStandaloneFunction · 0.85
unmarshalElementFunction · 0.85

Tested by

no test coverage detected