Implement support for user consent #4
@ -0,0 +1,12 @@
|
|||||||
|
package se.su.dsv.oauth2.web.oauth2;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ConsentController {
|
||||||
|
@GetMapping("/oauth2/consent")
|
||||||
|
public String showConsentForm() {
|
||||||
|
return "consent";
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/main/resources/templates/consent.jte
Normal file
3
src/main/resources/templates/consent.jte
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@template.base(title = "Consent", content = @`
|
||||||
|
<h1>Consent</h1>
|
||||||
|
`)
|
||||||
@ -60,6 +60,25 @@ public class ConsentFlowTest extends AbstractMetadataTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void consent_page_exists() throws Exception {
|
||||||
|
MvcResult result = mockMvc.perform(get(getAuthorizationEndpoint())
|
||||||
|
.with(remoteUser("some-other-end-user"))
|
||||||
|
.queryParam("response_type", "code")
|
||||||
|
.queryParam("client_id", TestConfig.CLIENT_ID)
|
||||||
|
.queryParam("redirect_uri", TestConfig.REDIRECT_URI))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(redirectedUrlPattern("**/oauth2/consent?**"))
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
|
String consentUrl = result.getResponse().getRedirectedUrl();
|
||||||
|
assertNotNull(consentUrl, "Should have redirected to the consent page");
|
||||||
|
|
||||||
|
mockMvc.perform(get(consentUrl)
|
||||||
|
.with(remoteUser("some-end-user")))
|
||||||
|
.andExpect(status().isOk());
|
||||||
|
}
|
||||||
|
|
||||||
private static UriComponents parseUrl(final String url) {
|
private static UriComponents parseUrl(final String url) {
|
||||||
assertNotNull(url);
|
assertNotNull(url);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user