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

Function TestElementToBytesNearestDeclarationWins

element_to_bytes_test.go:92–104  ·  view source on GitHub ↗

The nearest declaration of a prefix wins over one further out, and a declaration on the element itself is never overridden.

(t *testing.T)

Source from the content-addressed store, hash-verified

90// The nearest declaration of a prefix wins over one further out, and a
91// declaration on the element itself is never overridden.
92func TestElementToBytesNearestDeclarationWins(t *testing.T) {
93 const doc = `<a xmlns:p="urn:outer" xmlns="urn:outer-default">` +
94 `<b xmlns:p="urn:inner" xmlns="urn:inner-default"><c xmlns="urn:own"><p:d/></c></b></a>`
95 el := mustFindElement(t, doc, "//c")
96 assertStandalone(t, el)
97
98 buf, err := elementToBytes(el)
99 assert.Assert(t, err)
100 out := etree.NewDocument()
101 assert.Assert(t, out.ReadFromBytes(buf))
102 assert.Check(t, is.Equal("urn:own", out.Root().NamespaceURI()))
103 assert.Check(t, is.Equal("urn:inner", out.FindElement("//d").NamespaceURI()))
104}
105
106// Azure AD sends the Assertion and its Signature unprefixed, each declaring
107// its own default namespace. The serialized assertion must keep both

Callers

nothing calls this directly

Calls 3

mustFindElementFunction · 0.85
assertStandaloneFunction · 0.85
elementToBytesFunction · 0.85

Tested by

no test coverage detected