Skip to content

Commit 2d8bd1e

Browse files
committed
Adjust tests
1 parent e3b6a55 commit 2d8bd1e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ void testChallengeMetricsIncrement() {
269269
.andExpect(status().isOk())
270270
.andExpect(jsonPath("$.measurements[0].value", is((double) i)))
271271
.andExpect(jsonPath("$.availableTags[?(@.tag=='difficulty')].values[0]", hasItem("1000")))
272-
.andExpect(jsonPath("$.availableTags[?(@.tag=='site_key')].values[0]", hasItem("test_site")));
272+
.andExpect(jsonPath("$.availableTags[?(@.tag=='site_key')].values[0]", hasItem("test_site")))
273+
.andExpect(jsonPath("$.availableTags[?(@.tag=='same_source_address_request_count')].values[*]", hasItem(String.valueOf(i))));
273274
}
274275
}
275276

@@ -299,15 +300,17 @@ void testVerifyMetricsIncrement() {
299300
.andExpect(status().isOk())
300301
.andExpect(jsonPath("$.measurements[0].value", is((double) i)))
301302
.andExpect(jsonPath("$.availableTags[?(@.tag=='difficulty')].values[0]", hasItem("1000")))
302-
.andExpect(jsonPath("$.availableTags[?(@.tag=='site_key')].values[0]", hasItem("test_site")));
303+
.andExpect(jsonPath("$.availableTags[?(@.tag=='site_key')].values[0]", hasItem("test_site")))
304+
.andExpect(jsonPath("$.availableTags[?(@.tag=='same_source_address_request_count')]").exists());
303305

304306
mockMvc.perform(get("/actuator/metrics/captcha.client.solve.time"))
305307
.andExpect(status().isOk())
306308
.andExpect(jsonPath("$.measurements[?(@.statistic=='COUNT')].value", hasItem((double) i)))
307309
.andExpect(jsonPath("$.measurements[?(@.statistic=='TOTAL')].value", hasItem((double) i * TEST_PAYLOAD.getTook())))
308310
.andExpect(jsonPath("$.measurements[?(@.statistic=='MAX')].value", hasItem((double) TEST_PAYLOAD.getTook())))
309311
.andExpect(jsonPath("$.availableTags[?(@.tag=='difficulty')].values[0]", hasItem("1000")))
310-
.andExpect(jsonPath("$.availableTags[?(@.tag=='site_key')].values[0]", hasItem("test_site")));
312+
.andExpect(jsonPath("$.availableTags[?(@.tag=='site_key')].values[0]", hasItem("test_site")))
313+
.andExpect(jsonPath("$.availableTags[?(@.tag=='same_source_address_request_count')]").exists());
311314

312315
databaseTestUtil.clearDatabase();
313316
}

0 commit comments

Comments
 (0)