use of com.google.gerrit.util.http.testutil.FakeHttpServletRequest in project gerrit by GerritCodeReview.
the class ParameterParserTest method rejectDuplicateContentType.
@Test
public void rejectDuplicateContentType() {
FakeHttpServletRequest req = new FakeHttpServletRequest();
req.setQueryString("$ct=json&$ct=string");
BadRequestException bad = assertThrows(BadRequestException.class, () -> ParameterParser.getQueryParams(req));
assertThat(bad).hasMessageThat().isEqualTo("duplicate $ct");
}
use of com.google.gerrit.util.http.testutil.FakeHttpServletRequest in project gerrit by GerritCodeReview.
the class ParameterParserTest method rejectInvalidMethod.
@Test
public void rejectInvalidMethod() {
FakeHttpServletRequest req = new FakeHttpServletRequest();
req.setQueryString("$m=CONNECT");
BadRequestException bad = assertThrows(BadRequestException.class, () -> ParameterParser.getQueryParams(req));
assertThat(bad).hasMessageThat().isEqualTo("invalid $m");
}
use of com.google.gerrit.util.http.testutil.FakeHttpServletRequest in project gerrit by GerritCodeReview.
the class ParameterParserTest method parseXdOverride.
@Test
public void parseXdOverride() throws BadRequestException {
FakeHttpServletRequest req = new FakeHttpServletRequest();
req.setQueryString("$m=PUT&$ct=json&access_token=secret");
QueryParams qp = ParameterParser.getQueryParams(req);
assertThat(qp.accessToken()).isEqualTo("secret");
assertThat(qp.xdMethod()).isEqualTo("PUT");
assertThat(qp.xdContentType()).isEqualTo("json");
assertThat(qp.hasXdOverride()).isTrue();
assertThat(qp.config()).isEmpty();
assertThat(qp.params()).isEmpty();
}
Aggregations