Skip to content

Commit 7ef5527

Browse files
committed
test: fix raw response test
1 parent 14395a1 commit 7ef5527

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/test/java/fr/insee/genesis/controller/rest/ControllerAccessTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ private static Stream<Arguments> endpointsReader() {
9999

100100
private static Stream<Arguments> responseEndpoint() {
101101
return Stream.of(
102-
Arguments.of(GET,"/response/lunatic-json/get/unprocessed"),
103-
Arguments.of(GET,"/response//lunatic-json/get/by-interrogation-mode-and-campaign"),
104-
Arguments.of(POST,"/response//lunatic-json/process"),
105-
Arguments.of(GET,"/response//lunatic-json/campaignId=TOTO")
102+
Arguments.of(GET,"/responses/raw/lunatic-json/get/unprocessed"),
103+
Arguments.of(GET,"/responses/raw/lunatic-json/get/by-interrogation-mode-and-campaign?interrogationId=test&campaignName=test&mode=WEB"),
104+
Arguments.of(GET,"/responses/raw/lunatic-json/campaignId=TOTO"),
105+
Arguments.of(POST,"/responses/raw/lunatic-json/process?campaignName=test&questionnaireId=idTest")
106106
);
107107
}
108108

@@ -211,11 +211,12 @@ void reader_should_not_access_other_schedules_services() throws Exception {
211211
@MethodSource("responseEndpoint")
212212
@DisplayName("Reader should not access /responses endpoints")
213213
void reader_should_not_access_response_services(HttpMethod method,String endpointURI) throws Exception {
214+
String requestBody = "[\"id1\"]";
214215
MockHttpServletRequestBuilder requestBuilder;
215216
if (method == HttpMethod.GET) {
216217
requestBuilder = get(endpointURI);
217218
} else if (method == HttpMethod.POST) {
218-
requestBuilder = post(endpointURI);
219+
requestBuilder = post(endpointURI).contentType("application/json").content(requestBody);
219220
} else if (method == HttpMethod.PUT) {
220221
requestBuilder = put(endpointURI);
221222
} else if (method == HttpMethod.DELETE) {
@@ -228,7 +229,7 @@ void reader_should_not_access_response_services(HttpMethod method,String endpoin
228229
requestBuilder.with(
229230
jwt().authorities(new SimpleGrantedAuthority("ROLE_READER")))
230231
)
231-
.andExpect(status().is(oneOf(200, 404)));
232+
.andExpect(status().isForbidden());
232233
}
233234

234235

0 commit comments

Comments
 (0)