|
22 | 22 |
|
23 | 23 | package eu.webeid.security.validator.certvalidators; |
24 | 24 |
|
| 25 | +import eu.webeid.security.exceptions.CertificateExpiredException; |
25 | 26 | import eu.webeid.security.exceptions.CertificateNotTrustedException; |
26 | 27 | import eu.webeid.security.exceptions.JceException; |
27 | 28 | import eu.webeid.security.exceptions.UserCertificateOCSPCheckFailedException; |
@@ -251,14 +252,28 @@ void whenOcspResponseUnknown_thenThrows() throws Exception { |
251 | 252 | } |
252 | 253 |
|
253 | 254 | @Test |
254 | | - void whenOcspResponseCANotTrusted_thenThrows() throws Exception { |
| 255 | + void whenOcspResponseCACertNotTrusted_thenThrows() throws Exception { |
255 | 256 | final SubjectCertificateNotRevokedValidator validator = getSubjectCertificateNotRevokedValidatorWithAiaOcsp( |
256 | 257 | getMockedResponse(getOcspResponseBytesFromResources("ocsp_response_unknown.der")) |
257 | 258 | ); |
258 | | - assertThatExceptionOfType(CertificateNotTrustedException.class) |
| 259 | + try (var mockedClock = mockStatic(DateAndTime.DefaultClock.class)) { |
| 260 | + mockDate("2021-09-18T00:16:25", mockedClock); |
| 261 | + assertThatExceptionOfType(CertificateNotTrustedException.class) |
| 262 | + .isThrownBy(() -> |
| 263 | + validator.validateCertificateNotRevoked(estEid2018Cert)) |
| 264 | + .withMessage("Certificate EMAILADDRESS=pki@sk.ee, CN=TEST of SK OCSP RESPONDER 2020, OU=OCSP, O=AS Sertifitseerimiskeskus, C=EE is not trusted"); |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + @Test |
| 269 | + void whenOcspResponseCACertExpired_thenThrows() throws Exception { |
| 270 | + final SubjectCertificateNotRevokedValidator validator = getSubjectCertificateNotRevokedValidatorWithAiaOcsp( |
| 271 | + getMockedResponse(getOcspResponseBytesFromResources("ocsp_response_unknown.der")) |
| 272 | + ); |
| 273 | + assertThatExceptionOfType(CertificateExpiredException.class) |
259 | 274 | .isThrownBy(() -> |
260 | 275 | validator.validateCertificateNotRevoked(estEid2018Cert)) |
261 | | - .withMessage("Certificate EMAILADDRESS=pki@sk.ee, CN=TEST of SK OCSP RESPONDER 2020, OU=OCSP, O=AS Sertifitseerimiskeskus, C=EE is not trusted"); |
| 276 | + .withMessage("AIA OCSP responder certificate has expired"); |
262 | 277 | } |
263 | 278 |
|
264 | 279 | @Test |
|
0 commit comments