(t *testing.T)
| 414 | } |
| 415 | |
| 416 | func TestInvalidCertificateErrorKinds(t *testing.T) { |
| 417 | t.Run("IdP: SP encryption certificate", func(t *testing.T) { |
| 418 | test := idpcovNewTest(t) |
| 419 | for _, data := range []string{"!!!", base64.StdEncoding.EncodeToString([]byte("not a certificate"))} { |
| 420 | req := idpcovMadeAssertion(t, test) |
| 421 | req.SPSSODescriptor.KeyDescriptors = []KeyDescriptor{idpcovCertKeyDescriptor("encryption", data)} |
| 422 | _, err := req.getSPEncryptionCert() |
| 423 | checkOnlyKind(t, err, ErrInvalidCertificate) |
| 424 | checkOnlyKind(t, req.MakeAssertionEl(), ErrInvalidCertificate) |
| 425 | } |
| 426 | }) |
| 427 | |
| 428 | e := spcovSetup(t) |
| 429 | notACert := base64.StdEncoding.EncodeToString([]byte("not a certificate")) |
| 430 | tests := []struct { |
| 431 | name string |
| 432 | mutate func(sp *ServiceProvider) |
| 433 | }{ |
| 434 | {"SP: IdP metadata certificate base64", func(sp *ServiceProvider) { |
| 435 | sp.IDPMetadata.IDPSSODescriptors[0].KeyDescriptors[0].KeyInfo.X509Data.X509Certificates[0].Data = "!!!" |
| 436 | }}, |
| 437 | {"SP: IdP metadata certificate", func(sp *ServiceProvider) { |
| 438 | sp.IDPMetadata.IDPSSODescriptors[0].KeyDescriptors[0].KeyInfo.X509Data.X509Certificates[0].Data = notACert |
| 439 | }}, |
| 440 | {"SP: IDPCertificate", func(sp *ServiceProvider) { sp.IDPCertificate = ¬ACert }}, |
| 441 | } |
| 442 | for _, tc := range tests { |
| 443 | t.Run(tc.name, func(t *testing.T) { |
| 444 | sp := *e.sp |
| 445 | sp.IDPMetadata = spcovIDPMetadata(e.idpCert) |
| 446 | tc.mutate(&sp) |
| 447 | _, err := sp.ParseXMLResponse(e.signedResponse(t), []string{spcovRequestID}, sp.AcsURL) |
| 448 | assert.Check(t, errors.Is(err, ErrInvalidCertificate)) |
| 449 | assert.Check(t, errors.Is(err, ErrInvalidSignature)) |
| 450 | assert.Check(t, !errors.Is(err, ErrUntrustedCertificate)) |
| 451 | }) |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | func TestIdentityProviderOnError(t *testing.T) { |
| 456 | type call struct { |
nothing calls this directly
no test coverage detected