(t *testing.T)
| 639 | } |
| 640 | |
| 641 | func 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 | |
| 668 | func TestQueryAttributesErrors(t *testing.T) { |
| 669 | t.Run("HTTP error status", func(t *testing.T) { |
nothing calls this directly
no test coverage detected