An IdP that signs with a Signer alone publishes EncryptionCertificate and decrypts with DecryptionKeys.
(t *testing.T)
| 132 | // An IdP that signs with a Signer alone publishes EncryptionCertificate and |
| 133 | // decrypts with DecryptionKeys. |
| 134 | func 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. |
nothing calls this directly
no test coverage detected