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

Function TestStatementsInAssertionNamespace

statement_namespace_test.go:51–82  ·  view source on GitHub ↗

The same elements in the SAML assertion namespace are still read, whatever prefix the document binds to it.

(t *testing.T)

Source from the content-addressed store, hash-verified

49// The same elements in the SAML assertion namespace are still read, whatever
50// prefix the document binds to it.
51func TestStatementsInAssertionNamespace(t *testing.T) {
52 const native = `<Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
53 <AttributeStatement>
54 <Attribute Name="urn:oasis:names:tc:SAML:attribute:subject-id"><AttributeValue>user</AttributeValue></Attribute>
55 </AttributeStatement>
56 <AuthnStatement SessionIndex="native">
57 <SubjectLocality Address="10.0.0.1"/>
58 <AuthnContext><AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef></AuthnContext>
59 </AuthnStatement>
60 <Conditions><OneTimeUse/><ProxyRestriction Count="1"><Audience>https://sp.example.com/</Audience></ProxyRestriction></Conditions>
61</Assertion>`
62 var a Assertion
63 assert.Check(t, xml.Unmarshal([]byte(native), &a))
64
65 assert.Assert(t, is.Len(a.AttributeStatements, 1))
66 assert.Assert(t, is.Len(a.AttributeStatements[0].Attributes, 1))
67 assert.Assert(t, is.Len(a.AttributeStatements[0].Attributes[0].Values, 1))
68 assert.Check(t, is.Equal(a.AttributeStatements[0].Attributes[0].Values[0].Value, "user"))
69
70 assert.Assert(t, is.Len(a.AuthnStatements, 1))
71 assert.Assert(t, a.AuthnStatements[0].SubjectLocality != nil)
72 assert.Check(t, is.Equal(a.AuthnStatements[0].SubjectLocality.Address, "10.0.0.1"))
73 assert.Assert(t, a.AuthnStatements[0].AuthnContext.AuthnContextClassRef != nil)
74
75 assert.Assert(t, a.Conditions != nil)
76 assert.Check(t, a.Conditions.OneTimeUse != nil)
77 assert.Assert(t, a.Conditions.ProxyRestriction != nil)
78 assert.Assert(t, a.Conditions.ProxyRestriction.Count != nil)
79 assert.Check(t, is.Equal(*a.Conditions.ProxyRestriction.Count, 1))
80 assert.Assert(t, is.Len(a.Conditions.ProxyRestriction.Audiences, 1))
81 assert.Check(t, is.Equal(a.Conditions.ProxyRestriction.Audiences[0].Value, "https://sp.example.com/"))
82}

Callers

nothing calls this directly

Calls 1

LenMethod · 0.80

Tested by

no test coverage detected