CorsHandlerTest Class — netty Architecture
Architecture documentation for the CorsHandlerTest class in CorsHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e946b2e4_b243_053e_5c0a_3d1a9a50042d["CorsHandlerTest"] ed631854_6ad2_3720_d4f9_206659e21a40["CorsHandlerTest.java"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|defined in| ed631854_6ad2_3720_d4f9_206659e21a40 3facffed_792a_79d6_7714_0d3e1bc2a69f["nonCorsRequest()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| 3facffed_792a_79d6_7714_0d3e1bc2a69f 09209bba_f858_a828_3880_1775604694da["simpleRequestWithAnyOrigin()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| 09209bba_f858_a828_3880_1775604694da e1b1997c_2e2b_e44b_c1df_811142843847["simpleRequestWithNullOrigin()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| e1b1997c_2e2b_e44b_c1df_811142843847 a2e78f9e_d4cc_3293_1351_314665fdfea5["simpleRequestWithOrigin()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| a2e78f9e_d4cc_3293_1351_314665fdfea5 f44b88ed_ac75_7cf8_1908_3748f0a25f80["simpleRequestWithOrigins()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| f44b88ed_ac75_7cf8_1908_3748f0a25f80 cec1d6c0_e9fa_b172_c200_5aee29c88d20["simpleRequestWithNoMatchingOrigin()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| cec1d6c0_e9fa_b172_c200_5aee29c88d20 bc872e0f_b245_8bfd_4f6a_3e6449277fd9["preflightDeleteRequestWithCustomHeaders()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| bc872e0f_b245_8bfd_4f6a_3e6449277fd9 5213db82_0515_537c_923b_5c45eeeb002a["preflightGetRequestWithCustomHeaders()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| 5213db82_0515_537c_923b_5c45eeeb002a 63bfbea2_c99b_426d_3a02_b954d3c8aa7a["preflightRequestWithDefaultHeaders()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| 63bfbea2_c99b_426d_3a02_b954d3c8aa7a 73b8a6f7_d151_ade1_0aa5_6f66442ff9b4["preflightRequestWithCustomHeader()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| 73b8a6f7_d151_ade1_0aa5_6f66442ff9b4 4c24b8a0_7210_6447_e10d_2a2f66a5d027["preflightRequestWithUnauthorizedOrigin()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| 4c24b8a0_7210_6447_e10d_2a2f66a5d027 a1162a4a_4700_a1a5_aab5_60ab14d92e11["preflightRequestWithCustomHeaders()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| a1162a4a_4700_a1a5_aab5_60ab14d92e11 9ad9c509_22e1_9dea_d0f6_6ecc51829f77["preflightRequestWithCustomHeadersIterable()"] e946b2e4_b243_053e_5c0a_3d1a9a50042d -->|method| 9ad9c509_22e1_9dea_d0f6_6ecc51829f77
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java lines 59–746
public class CorsHandlerTest {
@Test
public void nonCorsRequest() {
final HttpResponse response = simpleRequest(forAnyOrigin().build(), null);
assertFalse(response.headers().contains(ACCESS_CONTROL_ALLOW_ORIGIN));
assertTrue(ReferenceCountUtil.release(response));
}
@Test
public void simpleRequestWithAnyOrigin() {
final HttpResponse response = simpleRequest(forAnyOrigin().build(), "http://localhost:7777");
assertEquals("*", response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN));
assertNull(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS));
assertTrue(ReferenceCountUtil.release(response));
}
@Test
public void simpleRequestWithNullOrigin() {
final HttpResponse response = simpleRequest(forOrigin("http://test.com").allowNullOrigin()
.allowCredentials()
.build(), "null");
assertEquals("null", response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN));
assertEquals("true", response.headers().get(ACCESS_CONTROL_ALLOW_CREDENTIALS));
assertNull(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS));
assertTrue(ReferenceCountUtil.release(response));
}
@Test
public void simpleRequestWithOrigin() {
final String origin = "http://localhost:8888";
final HttpResponse response = simpleRequest(forOrigin(origin).build(), origin);
assertEquals(origin, response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN));
assertNull(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS));
assertTrue(ReferenceCountUtil.release(response));
}
@Test
public void simpleRequestWithOrigins() {
final String origin1 = "http://localhost:8888";
final String origin2 = "https://localhost:8888";
final String[] origins = {origin1, origin2};
final HttpResponse response1 = simpleRequest(forOrigins(origins).build(), origin1);
assertEquals(origin1, response1.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN));
assertNull(response1.headers().get(ACCESS_CONTROL_ALLOW_HEADERS));
assertTrue(ReferenceCountUtil.release(response1));
final HttpResponse response2 = simpleRequest(forOrigins(origins).build(), origin2);
assertEquals(origin2, response2.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN));
assertNull(response2.headers().get(ACCESS_CONTROL_ALLOW_HEADERS));
assertTrue(ReferenceCountUtil.release(response2));
}
@Test
public void simpleRequestWithNoMatchingOrigin() {
final String origin = "http://localhost:8888";
final HttpResponse response = simpleRequest(
forOrigins("https://localhost:8888").build(), origin);
assertNull(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN));
assertNull(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS));
assertTrue(ReferenceCountUtil.release(response));
}
@Test
public void preflightDeleteRequestWithCustomHeaders() {
final CorsConfig config = forOrigin("http://localhost:8888")
.allowedRequestMethods(GET, DELETE)
.build();
final HttpResponse response = preflightRequest(config, "http://localhost:8888", "content-type, xheader1");
assertEquals("http://localhost:8888", response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN));
assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_METHODS)).contains("GET");
assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_METHODS)).contains("DELETE");
assertEquals(ORIGIN.toString(), response.headers().get(VARY));
assertTrue(ReferenceCountUtil.release(response));
}
@Test
public void preflightGetRequestWithCustomHeaders() {
final CorsConfig config = forOrigin("http://localhost:8888")
.allowedRequestMethods(OPTIONS, GET, DELETE)
.allowedRequestHeaders("content-type", "xheader1")
Source
Frequently Asked Questions
What is the CorsHandlerTest class?
CorsHandlerTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java.
Where is CorsHandlerTest defined?
CorsHandlerTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java at line 59.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free