Add consent page

This commit is contained in:
Andreas Svanberg 2025-04-22 00:08:03 +02:00
parent 1b08cdaf44
commit c8f28d8283
Signed by: ansv7779
GPG Key ID: 729B051CFFD42F92
3 changed files with 34 additions and 0 deletions
src
main
java/se/su/dsv/oauth2/web/oauth2
resources/templates
test/java/se/su/dsv/oauth2

@ -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";
}
}

@ -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) {
assertNotNull(url);