(t *testing.T)
| 274 | } |
| 275 | |
| 276 | func TestParseXMLAttributeQueryResponseEncryptedID(t *testing.T) { |
| 277 | encrypt := func(t *testing.T, e *spcovEnv, nameID NameID) func(*Assertion) { |
| 278 | return func(a *Assertion) { |
| 279 | a.Subject.NameID = nil |
| 280 | a.Subject.EncryptedID = e.encryptedID(t, nameID) |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | t.Run("matches the queried NameID", func(t *testing.T) { |
| 285 | for _, o := range []aqOptions{{signResponse: true}, {signAssertion: true, encrypt: true}} { |
| 286 | e := aqSetup(t) |
| 287 | query := e.aqQuery(t) |
| 288 | o.assertion = encrypt(t, e, aqNameID) |
| 289 | result, err := e.sp.ParseXMLAttributeQueryResponse(e.aqSOAP(t, query, o), query) |
| 290 | assert.NilError(t, err) |
| 291 | assert.Assert(t, is.Len(result.Assertions, 1)) |
| 292 | assert.Check(t, is.DeepEqual(*result.Assertions[0].Subject.NameID, aqNameID)) |
| 293 | assert.Assert(t, is.Len(result.Attributes, 1)) |
| 294 | assert.Check(t, is.Equal(result.Attributes[0].Values[0].Value, "alice@example.com")) |
| 295 | } |
| 296 | }) |
| 297 | |
| 298 | t.Run("another NameID", func(t *testing.T) { |
| 299 | e := aqSetup(t) |
| 300 | query := e.aqQuery(t) |
| 301 | other := aqNameID |
| 302 | other.Value = "bob-persistent-id" |
| 303 | _, err := e.sp.ParseXMLAttributeQueryResponse(e.aqSOAP(t, query, aqOptions{signResponse: true, assertion: encrypt(t, e, other)}), query) |
| 304 | assert.Check(t, is.ErrorContains(spcovPrivateErr(t, err), `does not match the queried NameID`)) |
| 305 | }) |
| 306 | |
| 307 | t.Run("not decryptable", func(t *testing.T) { |
| 308 | e := aqSetup(t) |
| 309 | query := e.aqQuery(t) |
| 310 | _, err := e.sp.ParseXMLAttributeQueryResponse(e.aqSOAP(t, query, aqOptions{signResponse: true, assertion: func(a *Assertion) { |
| 311 | a.Subject.NameID = nil |
| 312 | a.Subject.EncryptedID = eidEncrypt(t, mustParseCertificate(golden.Get(t, "cert_2017.pem")), eidNameIDEl(aqNameID)) |
| 313 | }}), query) |
| 314 | assert.Check(t, is.ErrorContains(spcovPrivateErr(t, err), `assertion "id-assertion": assertion Subject: cannot decrypt EncryptedID`)) |
| 315 | }) |
| 316 | } |
nothing calls this directly
no test coverage detected