MCPcopy Create free account
hub / github.com/crewjam/saml / TestIDPSigningWithNilKey

Function TestIDPSigningWithNilKey

idp_coverage_test.go:539–554  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
539func 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}

Callers

nothing calls this directly

Calls 3

idpcovNewTestFunction · 0.85
idpcovMadeAssertionFunction · 0.85
MakeResponseMethod · 0.80

Tested by

no test coverage detected