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

Function assertStandalone

element_to_bytes_test.go:24–37  ·  view source on GitHub ↗

The serialized element must be well-formed XML on its own: every prefix it uses has to be declared, and the default namespace must be written as xmlns="..." rather than the invalid xmlns:="...".

(t *testing.T, el *etree.Element)

Source from the content-addressed store, hash-verified

22// it uses has to be declared, and the default namespace must be written as
23// xmlns="..." rather than the invalid xmlns:="...".
24func assertStandalone(t *testing.T, el *etree.Element) {
25 t.Helper()
26 buf, err := elementToBytes(el)
27 assert.Check(t, err)
28 assert.Check(t, !strings.Contains(string(buf), `xmlns:=`), "invalid default namespace declaration in %s", buf)
29
30 doc := etree.NewDocument()
31 assert.Check(t, doc.ReadFromBytes(buf))
32 for _, child := range doc.FindElements("//*") {
33 if child.Space != "" {
34 assert.Check(t, child.NamespaceURI() != "", "prefix %q is not declared in %s", child.Space, buf)
35 }
36 }
37}
38
39// An assertion in the default namespace, declared on the enclosing Response
40// (as FusionAuth sends it), must keep that namespace when serialized alone.

Calls 1

elementToBytesFunction · 0.85

Tested by

no test coverage detected