Skip to content

Commit

Permalink
fix filter properties (#6722)
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <[email protected]>
  • Loading branch information
tvallin authored Apr 28, 2023
1 parent 33a1727 commit 07ea8b3
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 16 deletions.
4 changes: 2 additions & 2 deletions archetypes/helidon/filters.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022 Oracle and/or its affiliates.
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,7 @@ metrics=!${metrics} || (${metrics.builtin})
tracing=!${tracing} || (${tracing} && ${metrics.provider} == 'microprofile')

# group extra options
extra=${extra} == [] || ${extra} == ['cors', 'webclient', 'fault-tolerance']
extra=${extra} == [] || ${extra} == ['cors', 'fault-tolerance']

# group docker, k8s and v8o
packaging=!(${docker} || ${k8s} || ${v8o}) || (${docker} && ${k8s} && ${v8o})
Expand Down
20 changes: 20 additions & 0 deletions archetypes/helidon/src/main/archetype/common/extra.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@
<list key="Main-other-imports">
<value>java.util.concurrent.TimeoutException</value>
</list>
<list key="maven-plugins">
<value><![CDATA[
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<sun.net.http.allowRestrictedHeaders>true</sun.net.http.allowRestrictedHeaders>
</systemPropertyVariables>
</configuration>
</plugin>
]]></value>
</list>
</model>
</output>
</option>
Expand All @@ -74,6 +87,13 @@
<value>jakarta.ws.rs.core.Response</value>
<value>jakarta.ws.rs.HttpMethod</value>
</list>

<list key="FileServiceTest-annotations" if="${media} contains 'multipart'">
<value>@AddExtension(CorsCdiExtension.class)</value>
</list>
<list key="FileServiceTest-helidon-imports" if="${media} contains 'multipart'">
<value>io.helidon.microprofile.cors.CorsCdiExtension</value>
</list>
<list key="SimpleGreetService-methods" if="${flavor} == 'mp'">
<value><![CDATA[
@PUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ curl -s -X GET http://localhost:8080/health
<list key="readme-sections">
<value file="/common/files/README.jaeger.md"/>
</list>
<list key="config-properties">
<value>tracing.global=false</value>
</list>
</model>
</output>
</option>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#config-properties}}
{{.}}
{{/config-properties}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

{{#FileServiceTest-helidon-imports}}
import {{.}};
{{/FileServiceTest-helidon-imports}}
import io.helidon.microprofile.server.JaxRsCdiExtension;
import io.helidon.microprofile.server.ServerCdiExtension;
import io.helidon.microprofile.tests.junit5.AddBean;
Expand Down Expand Up @@ -46,6 +49,9 @@ import static org.hamcrest.Matchers.notNullValue;
@AddExtension(ServerCdiExtension.class)
@AddExtension(JaxRsCdiExtension.class)
@AddExtension(CdiComponentProvider.class)
{{#FileServiceTest-annotations}}
{{.}}
{{/FileServiceTest-annotations}}
@AddBean(FileService.class)
@AddBean(FileStorage.class)
@AddBean(MultiPartFeatureProvider.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ class FtResourceTest {
assertThat(response, is("failures: 2"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ class TestCORS {
@Inject
private WebTarget target;
private static final String ALLOW_RESTRICTED_HEADERS = "sun.net.http.allowRestrictedHeaders";
private static boolean originalAllowRestrictedHeaders;
@BeforeAll
static void permitCorsHeaders() {
originalAllowRestrictedHeaders = Boolean.getBoolean(ALLOW_RESTRICTED_HEADERS);
System.setProperty(ALLOW_RESTRICTED_HEADERS, "true");
}

@AfterAll
static void restoreHeadersSetting() {
System.setProperty(ALLOW_RESTRICTED_HEADERS, Boolean.toString(originalAllowRestrictedHeaders));
}
@Test
void testAnonymousGreetWithCors() {
Expand All @@ -48,7 +35,7 @@ class TestCORS {
assertThat("HTTP response", r.getStatus(), is(200));
String payload = fromPayload(r);
assertThat("HTTP response payload", payload, is("{\"message\":\"Hello World!\"}"));
assertThat("HTTP response payload", payload.contains("Hello World!"), is(true));
assertThat("CORS header " + CrossOriginConfig.ACCESS_CONTROL_ALLOW_ORIGIN,
r.getHeaders().getFirst(Http.Header.ACCESS_CONTROL_ALLOW_ORIGIN.defaultCase()),
is("http://foo.com"));
Expand Down

0 comments on commit 07ea8b3

Please sign in to comment.