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

Function TestAttributeNameIgnoresNamespaceDeclaration

attribute_namespace_test.go:31–37  ·  view source on GitHub ↗

A namespace declaration is not an attribute. encoding/xml reports xmlns:Name="..." as an attribute named Name, and exclusive canonicalization drops declarations that nothing uses, so one added to a signed element would otherwise replace the value of the field without invalidating the signature.

(t *testing.T)

Source from the content-addressed store, hash-verified

29// signed element would otherwise replace the value of the field without
30// invalidating the signature.
31func TestAttributeNameIgnoresNamespaceDeclaration(t *testing.T) {
32 var a Attribute
33 unmarshalForTest(t, `<saml:Attribute `+assertionNS+` Name="displayName" xmlns:Name="role"><saml:AttributeValue>admin</saml:AttributeValue></saml:Attribute>`, &a)
34 assert.Check(t, is.Equal(a.Name, "displayName"))
35 assert.Assert(t, is.Len(a.Values, 1))
36 assert.Check(t, is.Equal(a.Values[0].Value, "admin"))
37}
38
39func TestAttributeNameNotReadFromNamespaceDeclarationAlone(t *testing.T) {
40 var a Attribute

Callers

nothing calls this directly

Calls 2

unmarshalForTestFunction · 0.85
LenMethod · 0.80

Tested by

no test coverage detected