error handling split among:

1. user visible exception (directly shown to users as html)
2. redirect exception (pass back to redirect uri)
3. api exception (json)
This commit is contained in:
Dusan Jakub
2023-09-19 21:23:38 +02:00
parent 470600d7f1
commit e081da00da
10 changed files with 141 additions and 46 deletions

View File

@@ -2,6 +2,7 @@ package com.ysoft.geecon;
import com.ysoft.geecon.dto.OAuthClient;
import com.ysoft.geecon.dto.User;
import com.ysoft.geecon.error.ErrorResponse;
import com.ysoft.geecon.helpers.AuthorizationCodeFlow;
import com.ysoft.geecon.helpers.ConsentScreen;
import com.ysoft.geecon.helpers.LoginScreen;
@@ -10,6 +11,7 @@ import com.ysoft.geecon.repo.UsersRepo;
import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.jsoup.Connection;
import org.jsoup.nodes.Document;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -56,6 +58,14 @@ public class AuthCodeGrantTest {
assertThat(flow.getAccessToken(), is(notNullValue()));
}
@Test
public void authCodeGrant_invalidResponseType() throws IOException {
AuthorizationCodeFlow flow = new AuthorizationCodeFlow(authUrl, CLIENT);
Connection.Response response = flow.startExpectError(Map.of("response_type", ""));
Map<String, String> query = flow.parseAndValidateRedirectError(response);
assertThat(query.get("error"), is(ErrorResponse.Error.unsupported_response_type.name()));
}
@Test
public void implicitGrant() throws IOException {
AuthorizationCodeFlow flow = new AuthorizationCodeFlow(authUrl, CLIENT);