TestIDPSigningWithNilKey is a regression test for https://github.com/crewjam/saml/issues/405: a nil or typed-nil key used to panic deep inside the XML signature code instead of returning an error.
(t *testing.T)
| 537 | // https://github.com/crewjam/saml/issues/405: a nil or typed-nil key used to |
| 538 | // panic deep inside the XML signature code instead of returning an error. |
| 539 | func TestIDPSigningWithNilKey(t *testing.T) { |
| 540 | cases := map[string]func(idp *IdentityProvider){ |
| 541 | "NilKey": func(idp *IdentityProvider) { idp.Key = nil }, |
| 542 | "TypedNilKey": func(idp *IdentityProvider) { idp.Key = (*rsa.PrivateKey)(nil) }, |
| 543 | "TypedNilBoth": func(idp *IdentityProvider) { idp.Key = nil; idp.Signer = (*rsa.PrivateKey)(nil) }, |
| 544 | "NilCert": func(idp *IdentityProvider) { idp.Certificate = nil }, |
| 545 | } |
| 546 | for name, mutate := range cases { |
| 547 | t.Run(name, func(t *testing.T) { |
| 548 | test := idpcovNewTest(t) |
| 549 | req := idpcovMadeAssertion(t, test) |
| 550 | mutate(&test.IDP) |
| 551 | assert.Check(t, is.ErrorContains(req.MakeResponse(), "cannot sign")) |
| 552 | }) |
| 553 | } |
| 554 | } |
nothing calls this directly
no test coverage detected