String scope = "bogus";
String redirectUri = "http://anywhere?key=value";
String clientId = "my-client-with-registered-redirect";
UriBuilder uri = http.buildUri(authorizePath()).queryParam("response_type", "code")
.queryParam("state", "mystateid").queryParam("scope", scope);
if (clientId != null) {
uri.queryParam("client_id", clientId);
}
if (redirectUri != null) {
uri.queryParam("redirect_uri", redirectUri);
}
ResponseEntity<String> response = http.getForString(uri.pattern(), headers, uri.params());
assertEquals(HttpStatus.FOUND, response.getStatusCode());
String location = response.getHeaders().getLocation().toString();
assertTrue(location.startsWith("http://anywhere"));
assertTrue(location.contains("error=invalid_scope"));
assertFalse(location.contains("redirect_uri="));