Skip to content

Commit 6435326

Browse files
committed
Update CaptchaControllerTest to use configurable captcha timeout
1 parent 30d94ed commit 6435326

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.mockito.MockedStatic;
1616
import org.mockito.Mockito;
1717
import org.springframework.beans.factory.annotation.Autowired;
18+
import org.springframework.beans.factory.annotation.Value;
1819
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
1920
import org.springframework.boot.test.context.SpringBootTest;
2021
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
@@ -78,6 +79,10 @@ class CaptchaControllerTest {
7879
@Autowired
7980
private CaptchaRequestRepository captchaRequestRepository;
8081

82+
@Autowired
83+
@Value("${captcha.captcha-timeout-seconds}")
84+
private int captchaTimeoutSeconds;
85+
8186
@Test
8287
void postChallenge_basic() {
8388
final Altcha.ChallengeOptions challengeOptions = new Altcha.ChallengeOptions();
@@ -319,7 +324,7 @@ void testInvalidatedPayloadsGauge() {
319324
.andExpect(status().isOk())
320325
.andExpect(jsonPath("$.measurements[0].value", is(1.0)));
321326

322-
Thread.sleep(5000); // Wait for the payload to expire
327+
Thread.sleep(captchaTimeoutSeconds * 1000); // Wait for the payload to expire
323328

324329
mockMvc.perform(get("/actuator/metrics/captcha.invalidated.payloads"))
325330
.andExpect(status().isOk())

0 commit comments

Comments
 (0)