Skip to content

Commit 3714891

Browse files
committed
AUT-2623 Fix broken tests
1 parent d917099 commit 3714891

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

src/test/java/eu/webeid/ocsp/OcspCertificateRevocationCheckerTest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package eu.webeid.ocsp;
2424

25+
import eu.webeid.ocsp.exceptions.OCSPClientException;
2526
import eu.webeid.security.exceptions.CertificateExpiredException;
2627
import eu.webeid.security.exceptions.CertificateNotTrustedException;
2728
import eu.webeid.security.exceptions.JceException;
@@ -60,15 +61,15 @@
6061
import static eu.webeid.security.testutil.DateMocker.mockDate;
6162
import static eu.webeid.ocsp.service.OcspServiceMaker.getAiaOcspServiceProvider;
6263
import static eu.webeid.ocsp.service.OcspServiceMaker.getDesignatedOcspServiceProvider;
64+
import static org.assertj.core.api.Assertions.assertThat;
6365
import static org.assertj.core.api.Assertions.assertThatCode;
6466
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
6567
import static org.assertj.core.api.Assertions.assertThatThrownBy;
68+
import static org.junit.jupiter.api.Assertions.assertThrows;
6669
import static org.mockito.Mockito.mock;
6770
import static org.mockito.Mockito.mockStatic;
6871
import static org.mockito.Mockito.when;
6972

70-
// TODO Fix failing tests
71-
@Disabled
7273
public class OcspCertificateRevocationCheckerTest extends AbstractTestWithValidator {
7374

7475
private final OcspClient ocspClient = OcspClientImpl.build(Duration.ofSeconds(5));
@@ -122,7 +123,7 @@ void whenOcspUrlIsInvalid_thenThrows() throws Exception {
122123
final OcspCertificateRevocationChecker validator = getOcspCertificateRevocationChecker(ocspServiceProvider);
123124
assertThatCode(() ->
124125
validator.validateCertificateNotRevoked(estEid2018Cert, testEsteid2018CA))
125-
.isInstanceOf(UserCertificateOCSPCheckFailedException.class)
126+
.isInstanceOf(OCSPClientException.class)
126127
.cause()
127128
.isInstanceOf(ConnectException.class);
128129
}
@@ -131,12 +132,10 @@ void whenOcspUrlIsInvalid_thenThrows() throws Exception {
131132
void whenOcspRequestFails_thenThrows() throws Exception {
132133
final OcspServiceProvider ocspServiceProvider = getDesignatedOcspServiceProvider("http://demo.sk.ee/ocsps");
133134
final OcspCertificateRevocationChecker validator = getOcspCertificateRevocationChecker(ocspServiceProvider);
134-
assertThatCode(() ->
135-
validator.validateCertificateNotRevoked(estEid2018Cert, testEsteid2018CA))
136-
.isInstanceOf(UserCertificateOCSPCheckFailedException.class)
137-
.cause()
138-
.isInstanceOf(IOException.class)
139-
.hasMessageStartingWith("OCSP request was not successful, response: (POST http://demo.sk.ee/ocsps) 404");
135+
OCSPClientException ex = assertThrows(OCSPClientException.class, () ->
136+
validator.validateCertificateNotRevoked(estEid2018Cert, testEsteid2018CA));
137+
assertThat(ex).hasMessageStartingWith("OCSP request was not successful");
138+
assertThat(ex.getStatusCode()).isEqualTo(404);
140139
}
141140

142141
@Test
@@ -146,7 +145,7 @@ void whenOcspRequestHasInvalidBody_thenThrows() throws Exception {
146145
);
147146
assertThatCode(() ->
148147
validator.validateCertificateNotRevoked(estEid2018Cert, testEsteid2018CA))
149-
.isInstanceOf(UserCertificateOCSPCheckFailedException.class)
148+
.isInstanceOf(OCSPClientException.class)
150149
.cause()
151150
.isInstanceOf(IOException.class)
152151
.hasMessage("DEF length 110 object truncated by 105");
@@ -410,7 +409,7 @@ private OcspClient getMockClient(HttpResponse<byte[]> response) {
410409
try {
411410
return new OCSPResp(Objects.requireNonNull(response.body()));
412411
} catch (IOException e) {
413-
throw new RuntimeException(e);
412+
throw new OCSPClientException(e);
414413
}
415414
};
416415
}

src/test/java/eu/webeid/ocsp/client/OcspClientOverrideTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import eu.webeid.security.validator.AuthTokenValidator;
3131
import org.bouncycastle.cert.ocsp.OCSPReq;
3232
import org.bouncycastle.cert.ocsp.OCSPResp;
33-
import org.junit.jupiter.api.Disabled;
3433
import org.junit.jupiter.api.Test;
3534

3635
import java.io.IOException;
@@ -43,15 +42,12 @@
4342
import static org.assertj.core.api.Assertions.assertThatCode;
4443
import static org.assertj.core.api.Assertions.assertThatThrownBy;
4544

46-
// TODO Fix failing tests
47-
@Disabled
4845
class OcspClientOverrideTest extends AbstractTestWithValidator {
4946

5047
@Test
5148
void whenOcspClientIsOverridden_thenItIsUsed() throws JceException, CertificateException, IOException {
5249
final AuthTokenValidator validator = getAuthTokenValidatorWithOverriddenOcspClient(new OcpClientThatThrows());
5350
assertThatThrownBy(() -> validator.validate(validAuthToken, VALID_CHALLENGE_NONCE))
54-
.cause()
5551
.isInstanceOf(OcpClientThatThrowsException.class);
5652
}
5753

src/test/java/eu/webeid/resilientocsp/ResilientOcspCertificateRevocationCheckerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ void setUp() throws Exception {
8181
ocspRespGood = new OCSPResp(getOcspResponseBytesFromResources("ocsp_response.der"));
8282
}
8383

84-
// TODO Rename to match the expected result
8584
@Test
86-
void whenMultipleValidationCalls_thenStaleListenersMutatePreviousResults() throws Exception {
85+
void whenMultipleValidationCalls_thenPreviousResultsAreNotModified() throws Exception {
8786
OcspClient ocspClient = mock(OcspClient.class);
8887
when(ocspClient.request(eq(PRIMARY_URI), any()))
8988
.thenThrow(new OCSPClientException("Primary OCSP service unavailable (call1)"))

0 commit comments

Comments
 (0)