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

Function TestQueryAttributes

service_provider_attribute_query_test.go:641–666  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

639}
640
641func TestQueryAttributes(t *testing.T) {
642 e := aqSetup(t)
643 s := newAQServer(t, e)
644 s.respond = func(query *AttributeQuery) []byte {
645 return e.aqSOAP(t, query, aqOptions{signAssertion: true, encrypt: true})
646 }
647
648 result, err := e.sp.QueryAttributes(context.Background(), aqNameID, Attribute{Name: aqMailOID, NameFormat: aqURINameFormat})
649 assert.NilError(t, err)
650 assert.Assert(t, is.Len(result.Attributes, 1))
651 assert.Check(t, is.Equal(result.Attributes[0].Values[0].Value, "alice@example.com"))
652
653 // What the attribute authority received: a signed query in a SOAP
654 // envelope, sent with the SOAP binding's headers.
655 assert.Assert(t, is.Len(s.requests, 1))
656 assert.Check(t, is.Equal(s.headers[0].Get("Content-Type"), "text/xml; charset=utf-8"))
657 assert.Check(t, is.Equal(s.headers[0].Get("SOAPAction"), "http://www.oasis-open.org/committees/security"))
658 doc := etree.NewDocument()
659 assert.NilError(t, doc.ReadFromBytes(s.requests[0]))
660 assert.Check(t, is.Equal(doc.Root().NamespaceURI(), soapEnvelopeNamespace))
661 queryEl := doc.FindElement("/Envelope/Body/AttributeQuery")
662 assert.Assert(t, queryEl != nil)
663 assert.Check(t, is.Equal(queryEl.NamespaceURI(), "urn:oasis:names:tc:SAML:2.0:protocol"))
664 assert.Check(t, is.Equal(queryEl.SelectAttrValue("Destination", ""), s.URL))
665 aqVerify(t, e, queryEl)
666}
667
668func TestQueryAttributesErrors(t *testing.T) {
669 t.Run("HTTP error status", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

aqSetupFunction · 0.85
newAQServerFunction · 0.85
aqVerifyFunction · 0.85
aqSOAPMethod · 0.80
LenMethod · 0.80
GetMethod · 0.65
QueryAttributesMethod · 0.45

Tested by

no test coverage detected