6565import static org .assertj .core .api .Assertions .assertThatCode ;
6666import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
6767import static org .assertj .core .api .Assertions .assertThatThrownBy ;
68+ import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
6869import static org .junit .jupiter .api .Assertions .assertThrows ;
6970import static org .mockito .Mockito .mock ;
7071import static org .mockito .Mockito .mockStatic ;
@@ -123,6 +124,8 @@ void whenOcspUrlIsInvalid_thenThrows() throws Exception {
123124 final OcspCertificateRevocationChecker validator = getOcspCertificateRevocationChecker (ocspServiceProvider );
124125 assertThatCode (() ->
125126 validator .validateCertificateNotRevoked (estEid2018Cert , testEsteid2018CA ))
127+ .isInstanceOf (UserCertificateOCSPCheckFailedException .class )
128+ .cause ()
126129 .isInstanceOf (OCSPClientException .class )
127130 .cause ()
128131 .isInstanceOf (ConnectException .class );
@@ -132,10 +135,11 @@ void whenOcspUrlIsInvalid_thenThrows() throws Exception {
132135 void whenOcspRequestFails_thenThrows () throws Exception {
133136 final OcspServiceProvider ocspServiceProvider = getDesignatedOcspServiceProvider ("http://demo.sk.ee/ocsps" );
134137 final OcspCertificateRevocationChecker validator = getOcspCertificateRevocationChecker (ocspServiceProvider );
135- OCSPClientException ex = assertThrows (OCSPClientException .class , () ->
138+ UserCertificateOCSPCheckFailedException ex = assertThrows (UserCertificateOCSPCheckFailedException .class , () ->
136139 validator .validateCertificateNotRevoked (estEid2018Cert , testEsteid2018CA ));
137- assertThat (ex ).hasMessageStartingWith ("OCSP request was not successful" );
138- assertThat (ex .getStatusCode ()).isEqualTo (404 );
140+ OCSPClientException ocspClientException = assertInstanceOf (OCSPClientException .class , ex .getCause ());
141+ assertThat (ocspClientException ).hasMessageStartingWith ("OCSP request was not successful" );
142+ assertThat (ocspClientException .getStatusCode ()).isEqualTo (404 );
139143 }
140144
141145 @ Test
@@ -145,6 +149,8 @@ void whenOcspRequestHasInvalidBody_thenThrows() throws Exception {
145149 );
146150 assertThatCode (() ->
147151 validator .validateCertificateNotRevoked (estEid2018Cert , testEsteid2018CA ))
152+ .isInstanceOf (UserCertificateOCSPCheckFailedException .class )
153+ .cause ()
148154 .isInstanceOf (OCSPClientException .class )
149155 .cause ()
150156 .isInstanceOf (IOException .class )
0 commit comments