(t *testing.T)
| 136 | } |
| 137 | |
| 138 | func TestMakeAttributeQuery(t *testing.T) { |
| 139 | e := aqSetup(t) |
| 140 | query := e.aqQuery(t) |
| 141 | |
| 142 | assert.Check(t, strings.HasPrefix(query.ID, "id-")) |
| 143 | assert.Check(t, is.Equal(query.Version, "2.0")) |
| 144 | assert.Check(t, query.IssueInstant.Equal(spcovNow)) |
| 145 | assert.Check(t, is.Equal(query.Destination, aqLocation)) |
| 146 | assert.Check(t, is.Equal(query.Issuer.Value, "https://sp.example.com/saml/metadata")) |
| 147 | assert.Check(t, is.Equal(query.Issuer.Format, "urn:oasis:names:tc:SAML:2.0:nameid-format:entity")) |
| 148 | assert.Check(t, is.DeepEqual(*query.Subject.NameID, aqNameID)) |
| 149 | assert.Check(t, is.Len(query.Attributes, 1)) |
| 150 | |
| 151 | // Signed with SHA-256 by default, although SignatureMethod is not set. |
| 152 | assert.Assert(t, query.Signature != nil) |
| 153 | method := query.Signature.FindElement("./SignedInfo/SignatureMethod") |
| 154 | assert.Assert(t, method != nil) |
| 155 | assert.Check(t, is.Equal(method.SelectAttrValue("Algorithm", ""), dsig.RSASHA256SignatureMethod)) |
| 156 | aqVerify(t, e, query.Element()) |
| 157 | |
| 158 | // The signature still verifies in the SOAP envelope sent on the wire. |
| 159 | buf, err := elementToBytes(query.SoapRequest()) |
| 160 | assert.NilError(t, err) |
| 161 | doc := etree.NewDocument() |
| 162 | assert.NilError(t, doc.ReadFromBytes(buf)) |
| 163 | body, err := findOneChild(doc.Root(), soapEnvelopeNamespace, "Body") |
| 164 | assert.NilError(t, err) |
| 165 | queryEl, err := findOneChild(body, "urn:oasis:names:tc:SAML:2.0:protocol", "AttributeQuery") |
| 166 | assert.NilError(t, err) |
| 167 | aqVerify(t, e, queryEl) |
| 168 | children := queryEl.ChildElements() |
| 169 | assert.Assert(t, is.Len(children, 4)) |
| 170 | for i, tag := range []string{"Issuer", "Signature", "Subject", "Attribute"} { |
| 171 | assert.Check(t, is.Equal(children[i].Tag, tag)) |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func TestMakeAttributeQuerySignatureMethod(t *testing.T) { |
| 176 | e := aqSetup(t) |
nothing calls this directly
no test coverage detected