Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Enables OIDC integration tests and fixes a couple of problems in WebClient #7390

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import jakarta.ws.rs.core.Response;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_POST_LOGOUT_TEST_MESSAGE;
Expand All @@ -31,7 +30,6 @@
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;

@Disabled("https://github.com/helidon-io/helidon/issues/7094")
class CookieBasedLoginIT extends CommonLoginBase {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
import org.glassfish.jersey.client.ClientProperties;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_TEST_MESSAGE;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;

@Disabled("https://github.com/helidon-io/helidon/issues/7094")
@AddConfig(key = "security.providers.1.oidc.cookie-use", value = "false")
@AddConfig(key = "security.providers.1.oidc.query-param-use", value = "true")
class QueryBasedLoginIT extends CommonLoginBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientProperties;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
Expand All @@ -42,7 +41,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;

@Disabled("https://github.com/helidon-io/helidon/issues/7094")
@HelidonTest(resetPerTest = true)
@AddBean(TestResource.class)
@AddConfig(key = "security.providers.1.oidc.oidc-metadata-well-known", value = "false")
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/oidc/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
#

client:
cookies:
cookie-manager:
automatic-store-enabled: true
send-expect-continue: false
follow-redirects: true

security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ public ClientUri resolve(URI uri) {

uriBuilder.path(resolvePath(uriBuilder.path().path(), uri.getPath()));

if (uri.getRawQuery() != null) {
query.fromQueryString(uri.getRawQuery());
if (uri.getQuery() != null) {
query.fromQueryString(uri.getQuery());
}

if (uri.getRawFragment() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public void response(ClientUri uri, ClientResponseHeaders headers) {

if (headers.contains(Http.HeaderNames.SET_COOKIE)) {
cookies = new HashMap<>();
cookies.put(SET_COOKIE, headers.values(Http.HeaderNames.SET_COOKIE));
cookies.put(SET_COOKIE, headers.get(Http.HeaderNames.SET_COOKIE).allValues());
}

if (headers.contains(Http.HeaderNames.SET_COOKIE2)) {
cookies = cookies == null ? new HashMap<>() : cookies;
cookies.put(SET_COOKIE2, headers.values(Http.HeaderNames.SET_COOKIE2));
cookies.put(SET_COOKIE2, headers.get(Http.HeaderNames.SET_COOKIE2).allValues());
}

if (cookies != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void testQueryParams() {
assertThat(helper.path(), is(UriPath.create("/loom/quick")));
assertThat(helper.port(), is(8080));
assertThat(helper.scheme(), is("http"));
assertThat(helper.query(), is(query));
assertThat(helper.query().value("p1"), is("v1"));
assertThat(helper.query().value("p2"), is("v2"));
assertThat(helper.query().value("p3"), is("//v3//"));
assertThat(helper.query().getRaw("p3"), is("%2F%2Fv3%2F%2F"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ void testCookiePut() {
}
}

@Test
@Order(3)
void testCookieGetAfterPut() {
try (Http1ClientResponse response = client.get("/cookie").request()) {
assertThat(response.status(), is(Http.Status.OK_200));
}
}

private static void getHandler(ServerRequest req, ServerResponse res) {
if (req.headers().contains(Http.HeaderNames.COOKIE)) {
Http.Header cookies = req.headers().get(Http.HeaderNames.COOKIE);
Expand All @@ -111,6 +119,10 @@ private static void putHandler(ServerRequest req, ServerResponse res) {
&& cookies.allValues().contains("flavor2=vanilla")
&& cookies.allValues().contains("flavor3=strawberry")
&& cookies.allValues().contains("flavor4=raspberry")) {
// clear flavor1 and flavor2
res.header(Http.HeaderNames.SET_COOKIE,
"flavor1=; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Max-Age=0",
"flavor2=; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Max-Age=0");
res.status(Http.Status.OK_200).send();
} else {
res.status(Http.Status.BAD_REQUEST_400).send();
Expand Down