Skip to content

Commit a6f8b1d

Browse files
committed
Fix unit tests
1 parent fb44dba commit a6f8b1d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

captchaservice-backend/src/test/java/de/muenchen/captchaservice/controller/captcha/CaptchaControllerTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void postVerify_success() {
183183
final String requestBody = objectMapper.writeValueAsString(request);
184184
try (MockedStatic<Altcha> mock = Mockito.mockStatic(Altcha.class)) {
185185
mock
186-
.when(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(true)))
186+
.when(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(false)))
187187
.thenReturn(true);
188188
// --
189189
mockMvc.perform(
@@ -194,7 +194,7 @@ void postVerify_success() {
194194
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
195195
.andExpect(jsonPath("$.valid", is(true)));
196196
// --
197-
mock.verify(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(true)));
197+
mock.verify(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(false)));
198198
} catch (Exception e) {
199199
fail(e.getMessage());
200200
}
@@ -222,7 +222,7 @@ void postVerify_expired() {
222222
try (MockedStatic<Altcha> mock = Mockito.mockStatic(Altcha.class)) {
223223
// Successful request
224224
mock
225-
.when(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(true)))
225+
.when(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(false)))
226226
.thenReturn(true);
227227
mockMvc.perform(
228228
post("/api/v1/captcha/verify")
@@ -231,11 +231,11 @@ void postVerify_expired() {
231231
.andExpect(status().isOk())
232232
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
233233
.andExpect(jsonPath("$.valid", is(true)));
234-
mock.verify(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(true)));
234+
mock.verify(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(false)));
235235

236236
// Expired request
237237
mock
238-
.when(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(true)))
238+
.when(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(false)))
239239
.thenReturn(true);
240240
mockMvc.perform(
241241
post("/api/v1/captcha/verify")
@@ -244,7 +244,7 @@ void postVerify_expired() {
244244
.andExpect(status().isOk())
245245
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
246246
.andExpect(jsonPath("$.valid", is(false)));
247-
mock.verify(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(true)));
247+
mock.verify(() -> Altcha.verifySolution(ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()), eq(TEST_HMAC_KEY), eq(false)));
248248
} catch (Exception e) {
249249
fail(e.getMessage());
250250
}
@@ -286,7 +286,7 @@ void testVerifyMetricsIncrement() {
286286
mock.when(() -> Altcha.verifySolution(
287287
ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()),
288288
eq(TEST_HMAC_KEY),
289-
eq(true)))
289+
eq(false)))
290290
.thenReturn(true);
291291

292292
for (int i = 1; i <= calls; i++) {
@@ -328,7 +328,7 @@ void testInvalidatedPayloadsGauge() {
328328
mock.when(() -> Altcha.verifySolution(
329329
ArgumentMatchers.<Altcha.Payload>argThat(p -> p.algorithm.isEmpty()),
330330
eq(TEST_HMAC_KEY),
331-
eq(true)))
331+
eq(false)))
332332
.thenReturn(true);
333333

334334
mockMvc.perform(post("/api/v1/captcha/verify")

0 commit comments

Comments
 (0)