I am trying to test rate-limiter logic, it should result with too many request at the 6th trial
I want to get rid of the repetition of calling service 5 times and asserting 200 for the first 5 trial, but no luck, there is an exception Groovyc: Exception conditions are only allowed in 'then' blocks
def "POST request towards service is successfully limited"() {
IntStream.range(1, 6).forEach({
when:
def result = client.post().uri("/test").exchange()
then:
noExceptionThrown()
result != null
result.expectStatus().isOk()
})
when:
def result6 = client.post().uri("/test").exchange()
then:
noExceptionThrown()
result6 != null
result6.expectStatus().is4xxClientError()
}