attributeQueryResponse returns the SOAP response of the attribute authority to query: a Response signed by the IdP with an assertion about the queried NameID.
(t *testing.T, query *saml.AttributeQuery)
| 182 | // authority to query: a Response signed by the IdP with an assertion about |
| 183 | // the queried NameID. |
| 184 | func (lt *logoutTest) attributeQueryResponse(t *testing.T, query *saml.AttributeQuery) []byte { |
| 185 | audience := lt.m.ServiceProvider.EntityID |
| 186 | if audience == "" { |
| 187 | audience = lt.m.ServiceProvider.MetadataURL.String() |
| 188 | } |
| 189 | issuer := &saml.Issuer{Value: logoutTestIDPEntityID} |
| 190 | nameID := *query.Subject.NameID |
| 191 | response := &saml.Response{ |
| 192 | ID: "id-attribute-response", |
| 193 | InResponseTo: query.ID, |
| 194 | Version: "2.0", |
| 195 | IssueInstant: logoutTestNow, |
| 196 | Issuer: issuer, |
| 197 | Status: saml.Status{StatusCode: saml.StatusCode{Value: saml.StatusSuccess}}, |
| 198 | Assertion: &saml.Assertion{ |
| 199 | ID: "id-attribute-assertion", |
| 200 | Version: "2.0", |
| 201 | IssueInstant: logoutTestNow, |
| 202 | Issuer: *issuer, |
| 203 | Subject: &saml.Subject{ |
| 204 | NameID: &nameID, |
| 205 | SubjectConfirmations: []saml.SubjectConfirmation{{Method: "urn:oasis:names:tc:SAML:2.0:cm:sender-vouches"}}, |
| 206 | }, |
| 207 | Conditions: &saml.Conditions{ |
| 208 | NotBefore: logoutTestNow.Add(-time.Minute), |
| 209 | NotOnOrAfter: logoutTestNow.Add(time.Minute), |
| 210 | AudienceRestrictions: []saml.AudienceRestriction{{Audience: saml.Audience{Value: audience}}}, |
| 211 | }, |
| 212 | AttributeStatements: []saml.AttributeStatement{{Attributes: []saml.Attribute{{ |
| 213 | FriendlyName: "mail", |
| 214 | Name: aqTestMailOID, |
| 215 | NameFormat: aqTestURINameFormat, |
| 216 | Values: []saml.AttributeValue{{Type: "xs:string", Value: "alice@example.com"}}, |
| 217 | }}}}, |
| 218 | }, |
| 219 | } |
| 220 | signed, err := base64.StdEncoding.DecodeString(lt.signedIDPMessage(t, response.Element())) |
| 221 | assert.Check(t, err) |
| 222 | return []byte(`<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>` + |
| 223 | strings.TrimPrefix(string(signed), `<?xml version="1.0" encoding="UTF-8"?>`) + |
| 224 | `</soapenv:Body></soapenv:Envelope>`) |
| 225 | } |
| 226 | |
| 227 | // loginCookie creates a session for an assertion about nameID, as ServeACS |
| 228 | // does, and returns its cookie. |
no test coverage detected