Skip to content

Commit

Permalink
Add test coverage for quarkusio/quarkus#35582
Browse files Browse the repository at this point in the history
  • Loading branch information
jedla97 authored and michalvavrik committed Nov 21, 2023
1 parent 16cb736 commit 07f9a8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.ts.http.advanced.reactive;

import java.util.Map;

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.CookieParam;
import jakarta.ws.rs.FormParam;
Expand Down Expand Up @@ -56,6 +58,19 @@ public Response getSameSiteAttributeFromFormParam(@FormParam(TEST_COOKIE) String
return responseBuilder.cookie(newCookie).build();
}

@GET
@Path("newcookie-serialization")
public Map<String, NewCookie> getRequestCookies(HttpHeaders httpHeaders) {
NewCookie cookie = new NewCookie.Builder(TEST_COOKIE).value("test-cookie-value").build();
return Map.of(cookie.getName(), cookie);
}

@GET
@Path("cookie-serialization")
public Map<String, jakarta.ws.rs.core.Cookie> test(HttpHeaders httpHeaders) {
return httpHeaders.getCookies();
}

public static String toRawCookie(String sameSite) {
if (sameSite == null || sameSite.isEmpty()) {
return String.format("%s=\"test-cookie-value\";Version=\"1\";", TEST_COOKIE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.quarkus.ts.http.advanced.reactive;

import static io.quarkus.ts.http.advanced.reactive.CookiesResource.TEST_COOKIE;
import static io.restassured.RestAssured.get;
import static io.restassured.RestAssured.given;
import static io.restassured.matcher.RestAssuredMatchers.detailedCookie;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -52,6 +52,26 @@ void testSameSiteAttributeAddedByVertxHttpExt() {
.cookie("vertx", detailedCookie().sameSite(sameSite).secured(true));
}

@Test
void testNewCookiesSerialization() {
given()
.get("/cookie/newcookie-serialization")
.then()
.statusCode(200)
.body(containsString(String.format("\"name\":\"%s\"", TEST_COOKIE)),
containsString("\"value\":\"test-cookie-value\""));
}

@Test
void testCookiesSerialization() {
given().cookie(String.format("%s=\"test-cookie-value\";", TEST_COOKIE))
.get("/cookie/cookie-serialization")
.then()
.statusCode(200)
.body(containsString(String.format("\"name\":\"%s\"", TEST_COOKIE)),
containsString("\"value\":\"test-cookie-value\""));
}

private static void assertSameSiteAttribute(String sameSite) {
ValidatableResponse response;

Expand Down

0 comments on commit 07f9a8f

Please sign in to comment.