-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30068 from brunolmfg/allow-static-resources-config
Allow tuning some static resources serving properties
- Loading branch information
Showing
10 changed files
with
214 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...tp/deployment/src/test/java/io/quarkus/vertx/http/StaticResourcesCachingDisabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.vertx.http; | ||
|
||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class StaticResourcesCachingDisabledTest { | ||
|
||
@RegisterExtension | ||
final static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.add(new StringAsset( | ||
"quarkus.http.static-resources.caching-enabled=false\n"), | ||
"application.properties") | ||
.addAsResource("static-file.html", "META-INF/resources/index.html")); | ||
|
||
@Test | ||
public void shouldNotContainCachingHeaders() { | ||
RestAssured.when().get("/") | ||
.then() | ||
.header("Cache-Control", nullValue()) | ||
.header("Last-Modified", nullValue()) | ||
.statusCode(200); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...tp/deployment/src/test/java/io/quarkus/vertx/http/StaticResourcesCustomizedPagesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.quarkus.vertx.http; | ||
|
||
import static org.hamcrest.Matchers.containsStringIgnoringCase; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class StaticResourcesCustomizedPagesTest { | ||
|
||
@RegisterExtension | ||
final static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.add(new StringAsset("" + | ||
"quarkus.http.static-resources.index-page=default.html\n" + | ||
"quarkus.http.static-resources.include-hidden=false\n" + | ||
"quarkus.http.static-resources.enable-range-support=false\n"), | ||
"application.properties") | ||
.addAsResource("static-file.html", "META-INF/resources/.hidden-file.html") | ||
.addAsResource("static-file.html", "META-INF/resources/default.html")); | ||
|
||
@Test | ||
public void shouldContainCachingHeaders() { | ||
RestAssured.when().get("/") | ||
.then() | ||
.header("Cache-Control", containsStringIgnoringCase("max-age=")) | ||
.header("Last-Modified", notNullValue()) | ||
.statusCode(200); | ||
} | ||
|
||
@Test | ||
public void shouldNotReturnHiddenHtmlPage() { | ||
RestAssured.when().get("/.hidden-file.html") | ||
.then() | ||
.statusCode(404); | ||
} | ||
|
||
@Test | ||
public void shouldNotReturnRangeSupport() { | ||
RestAssured.when().head("/") | ||
.then() | ||
.header("Accept-Ranges", nullValue()) | ||
.header("Content-Length", nullValue()) | ||
.statusCode(200); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.