Skip to content

Commit 4de96df

Browse files
authored
Enables OIDC integration tests. Fixes two additional issues in WebClient: (#7390)
1. In ClientUri, UriQueryWriteable is initialized from a decoded string. If initialized using an encoded string as before, a second encoding will take place internally. 2. The WebClientCookieManager now correctly handles cookie values, including those that may contain commas (such as expiration values). There are new or updated tests to cover the changes in (1) and (2).
1 parent 5d6c941 commit 4de96df

File tree

8 files changed

+22
-12
lines changed

8 files changed

+22
-12
lines changed

tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/CookieBasedLoginIT.java

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import jakarta.ws.rs.core.Response;
2323
import org.jsoup.Jsoup;
2424
import org.jsoup.nodes.Document;
25-
import org.junit.jupiter.api.Disabled;
2625
import org.junit.jupiter.api.Test;
2726

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

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

3735
@Test

tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/QueryBasedLoginIT.java

-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
import org.glassfish.jersey.client.ClientProperties;
2727
import org.jsoup.Jsoup;
2828
import org.jsoup.nodes.Document;
29-
import org.junit.jupiter.api.Disabled;
3029
import org.junit.jupiter.api.Test;
3130

3231
import static io.helidon.tests.integration.oidc.TestResource.EXPECTED_TEST_MESSAGE;
3332
import static org.hamcrest.CoreMatchers.is;
3433
import static org.hamcrest.CoreMatchers.not;
3534
import static org.hamcrest.MatcherAssert.assertThat;
3635

37-
@Disabled("https://github.com/helidon-io/helidon/issues/7094")
3836
@AddConfig(key = "security.providers.1.oidc.cookie-use", value = "false")
3937
@AddConfig(key = "security.providers.1.oidc.query-param-use", value = "true")
4038
class QueryBasedLoginIT extends CommonLoginBase {

tests/integration/oidc/src/test/java/io/helidon/tests/integration/oidc/TenantIdentificationIT.java

-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import jakarta.ws.rs.core.HttpHeaders;
3434
import jakarta.ws.rs.core.Response;
3535
import org.glassfish.jersey.client.ClientProperties;
36-
import org.junit.jupiter.api.Disabled;
3736
import org.junit.jupiter.api.Test;
3837

3938
import static org.hamcrest.CoreMatchers.is;
@@ -42,7 +41,6 @@
4241
import static org.hamcrest.MatcherAssert.assertThat;
4342
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
4443

45-
@Disabled("https://github.com/helidon-io/helidon/issues/7094")
4644
@HelidonTest(resetPerTest = true)
4745
@AddBean(TestResource.class)
4846
@AddConfig(key = "security.providers.1.oidc.oidc-metadata-well-known", value = "false")

tests/integration/oidc/src/test/resources/application.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
#
1616

1717
client:
18-
cookies:
18+
cookie-manager:
1919
automatic-store-enabled: true
20+
send-expect-continue: false
2021
follow-redirects: true
2122

2223
security:

webclient/api/src/main/java/io/helidon/webclient/api/ClientUri.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ public ClientUri resolve(URI uri) {
193193

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

196-
if (uri.getRawQuery() != null) {
197-
query.fromQueryString(uri.getRawQuery());
196+
if (uri.getQuery() != null) {
197+
query.fromQueryString(uri.getQuery());
198198
}
199199

200200
if (uri.getRawFragment() != null) {

webclient/api/src/main/java/io/helidon/webclient/api/WebClientCookieManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ public void response(ClientUri uri, ClientResponseHeaders headers) {
142142

143143
if (headers.contains(Http.HeaderNames.SET_COOKIE)) {
144144
cookies = new HashMap<>();
145-
cookies.put(SET_COOKIE, headers.values(Http.HeaderNames.SET_COOKIE));
145+
cookies.put(SET_COOKIE, headers.get(Http.HeaderNames.SET_COOKIE).allValues());
146146
}
147147

148148
if (headers.contains(Http.HeaderNames.SET_COOKIE2)) {
149149
cookies = cookies == null ? new HashMap<>() : cookies;
150-
cookies.put(SET_COOKIE2, headers.values(Http.HeaderNames.SET_COOKIE2));
150+
cookies.put(SET_COOKIE2, headers.get(Http.HeaderNames.SET_COOKIE2).allValues());
151151
}
152152

153153
if (cookies != null) {

webclient/api/src/test/java/io/helidon/webclient/api/ClientUriTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ void testQueryParams() {
7070
assertThat(helper.path(), is(UriPath.create("/loom/quick")));
7171
assertThat(helper.port(), is(8080));
7272
assertThat(helper.scheme(), is("http"));
73-
assertThat(helper.query(), is(query));
73+
assertThat(helper.query().value("p1"), is("v1"));
74+
assertThat(helper.query().value("p2"), is("v2"));
75+
assertThat(helper.query().value("p3"), is("//v3//"));
76+
assertThat(helper.query().getRaw("p3"), is("%2F%2Fv3%2F%2F"));
7477
}
7578

7679
@Test

webclient/tests/http1/src/test/java/io/helidon/webclient/tests/CookieTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ void testCookiePut() {
8787
}
8888
}
8989

90+
@Test
91+
@Order(3)
92+
void testCookieGetAfterPut() {
93+
try (Http1ClientResponse response = client.get("/cookie").request()) {
94+
assertThat(response.status(), is(Http.Status.OK_200));
95+
}
96+
}
97+
9098
private static void getHandler(ServerRequest req, ServerResponse res) {
9199
if (req.headers().contains(Http.HeaderNames.COOKIE)) {
92100
Http.Header cookies = req.headers().get(Http.HeaderNames.COOKIE);
@@ -111,6 +119,10 @@ private static void putHandler(ServerRequest req, ServerResponse res) {
111119
&& cookies.allValues().contains("flavor2=vanilla")
112120
&& cookies.allValues().contains("flavor3=strawberry")
113121
&& cookies.allValues().contains("flavor4=raspberry")) {
122+
// clear flavor1 and flavor2
123+
res.header(Http.HeaderNames.SET_COOKIE,
124+
"flavor1=; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Max-Age=0",
125+
"flavor2=; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Max-Age=0");
114126
res.status(Http.Status.OK_200).send();
115127
} else {
116128
res.status(Http.Status.BAD_REQUEST_400).send();

0 commit comments

Comments
 (0)