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

Function TestIDPDecryptionKeysWithSignerOnly

logout_request_identifiers_test.go:134–162  ·  view source on GitHub ↗

An IdP that signs with a Signer alone publishes EncryptionCertificate and decrypts with DecryptionKeys.

(t *testing.T)

Source from the content-addressed store, hash-verified

132// An IdP that signs with a Signer alone publishes EncryptionCertificate and
133// decrypts with DecryptionKeys.
134func TestIDPDecryptionKeysWithSignerOnly(t *testing.T) {
135 test := newSLOTest(t)
136 test.IDP.Signer = test.IDP.Key.(*rsa.PrivateKey)
137 test.IDP.Key = nil
138 decryptionKey, encryptionCert := aqKeyPair(t)
139 test.IDP.EncryptionCertificate = encryptionCert
140 test.IDP.DecryptionKeys = []*rsa.PrivateKey{decryptionKey}
141
142 // The metadata publishes EncryptionCertificate for encryption, and
143 // Certificate for signing.
144 test.SP.IDPMetadata = test.IDP.Metadata()
145 for _, kd := range test.SP.IDPMetadata.IDPSSODescriptors[0].KeyDescriptors {
146 want := test.IDP.Certificate.Raw
147 if kd.Use == "encryption" {
148 want = encryptionCert.Raw
149 }
150 assert.Check(t, is.Equal(base64.StdEncoding.EncodeToString(want), kd.KeyInfo.X509Data.X509Certificates[0].Data), kd.Use)
151 }
152
153 test.SP.EncryptLogoutNameID = true
154 req, err := test.SP.MakeLogoutRequest(test.IDP.LogoutURL.String(), sloTestNameID, WithSessionIndex(sloTestSessionIndex))
155 assert.NilError(t, err)
156 w := test.serve(test.postRequest(t, req))
157 resp, err := test.SP.ParseLogoutResponse(spRequestForResponse(t, w), []string{req.ID})
158 assert.NilError(t, err)
159 assert.Check(t, is.Equal(StatusSuccess, resp.Status.StatusCode.Value))
160 assert.Assert(t, is.Len(test.sessions.invalidated, 1))
161 assert.Check(t, is.Equal("s1", test.sessions.invalidated[0].ID))
162}
163
164// While the IdP encryption key is rotated, an EncryptedID encrypted to the
165// previous certificate is decrypted with DecryptionKeys.

Callers

nothing calls this directly

Calls 11

newSLOTestFunction · 0.85
aqKeyPairFunction · 0.85
WithSessionIndexFunction · 0.85
spRequestForResponseFunction · 0.85
MakeLogoutRequestMethod · 0.80
StringMethod · 0.80
postRequestMethod · 0.80
ParseLogoutResponseMethod · 0.80
LenMethod · 0.80
MetadataMethod · 0.45
serveMethod · 0.45

Tested by

no test coverage detected