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

Function TestNamespacedAttributesStillRead

attribute_namespace_test.go:94–109  ·  view source on GitHub ↗

Fields read by namespace, and the prefixes documents normally use, are unaffected.

(t *testing.T)

Source from the content-addressed store, hash-verified

92// Fields read by namespace, and the prefixes documents normally use, are
93// unaffected.
94func TestNamespacedAttributesStillRead(t *testing.T) {
95 var a Assertion
96 unmarshalForTest(t, `<saml:Assertion `+assertionNS+` xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="id-1">
97 <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo/></ds:Signature>
98 <saml:AttributeStatement><saml:Attribute Name="mail"><saml:AttributeValue xsi:type="xs:string">a@example.com</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>
99</saml:Assertion>`, &a)
100 assert.Check(t, is.Equal(a.ID, "id-1"))
101 assert.Assert(t, a.Signature != nil)
102 assert.Check(t, is.Equal(a.Signature.Space, "ds"))
103 assert.Assert(t, is.Len(a.AttributeStatements, 1))
104 assert.Assert(t, is.Len(a.AttributeStatements[0].Attributes, 1))
105 v := a.AttributeStatements[0].Attributes[0].Values
106 assert.Assert(t, is.Len(v, 1))
107 assert.Check(t, is.Equal(v[0].Type, "xs:string"))
108 assert.Check(t, is.Equal(v[0].Value, "a@example.com"))
109}
110
111// A prefix that could be an attribute field's name is renamed, and the
112// element that uses it is still read in the right namespace.

Callers

nothing calls this directly

Calls 2

unmarshalForTestFunction · 0.85
LenMethod · 0.80

Tested by

no test coverage detected