Skip to content

Commit

Permalink
🔧 rm default Expires response header filter (#303)
Browse files Browse the repository at this point in the history
* 🔧 rm default Expires response header remove

* 🔥 rm expires header checks from tests
  • Loading branch information
simonhir authored Dec 5, 2024
1 parent 0e6047c commit 74acd8c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 16 deletions.
1 change: 0 additions & 1 deletion refarch-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ spring:
allowedHeaders: "*"
allowCredentials: true
default-filters:
- RemoveResponseHeader=Expires
- RemoveRequestHeader=cookie
- RemoveRequestHeader=x-xsrf-token
- TokenRelay=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ void setup() {
.withStatus(HttpStatus.UNAUTHORIZED.value())
.withHeaders(new HttpHeaders(
new HttpHeader("Content-Type", "application/json"),
new HttpHeader("WWW-Authenticate", "Bearer realm=\"Access to the staging site\", charset=\"UTF-8\""),
new HttpHeader("Expires", "Wed, 21 Oct 2099 07:28:06 GMT")))
new HttpHeader("WWW-Authenticate", "Bearer realm=\"Access to the staging site\", charset=\"UTF-8\"")))
.withBody("{ \"testkey\" : \"testvalue\" }")));
}

Expand All @@ -49,7 +48,6 @@ void backendAuthenticationError() {
.expectStatus().isEqualTo(HttpStatus.UNAUTHORIZED)
.expectHeader().valueMatches("Content-Type", "application/json")
.expectHeader().doesNotExist("WWW-Authenticate")
.expectHeader().valueMatches("Expires", "0")
.expectBody()
.jsonPath("$.status").isEqualTo("401")
.jsonPath("$.error").isEqualTo("Authentication Error");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ void backendError500() {
.withHeaders(new HttpHeaders(
new HttpHeader(org.springframework.http.HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()),
new HttpHeader(org.springframework.http.HttpHeaders.WWW_AUTHENTICATE,
"Bearer realm=\"Access to the staging site\", charset=\"UTF-8\""),
new HttpHeader(org.springframework.http.HttpHeaders.EXPIRES, "Wed, 21 Oct 2099 07:28:06 GMT")))
"Bearer realm=\"Access to the staging site\", charset=\"UTF-8\"")))
.withBody("{ \"testkey\" : \"testvalue\" }")));

webTestClient.get().uri("/api/refarch-gateway-backend-service/remote").exchange()
.expectStatus().isEqualTo(HttpStatus.BAD_REQUEST)
.expectHeader().valueMatches(org.springframework.http.HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType())
.expectHeader().doesNotExist(org.springframework.http.HttpHeaders.WWW_AUTHENTICATE)
.expectHeader().valueMatches(org.springframework.http.HttpHeaders.EXPIRES, "0")
.expectBody()
.jsonPath("$.status").isEqualTo("400")
.jsonPath("$.error").isEqualTo("Bad Request");
Expand All @@ -69,15 +67,13 @@ void backendError200() {
.withHeaders(new HttpHeaders(
new HttpHeader(org.springframework.http.HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()),
new HttpHeader(org.springframework.http.HttpHeaders.WWW_AUTHENTICATE,
"Bearer realm=\"Access to the staging site\", charset=\"UTF-8\""),
new HttpHeader(org.springframework.http.HttpHeaders.EXPIRES, "Wed, 21 Oct 2099 07:28:06 GMT")))
"Bearer realm=\"Access to the staging site\", charset=\"UTF-8\"")))
.withBody("{ \"testkey\" : \"testvalue\" }")));

webTestClient.get().uri("/api/refarch-gateway-backend-service/remote").exchange()
.expectStatus().isEqualTo(HttpStatus.OK)
.expectHeader().valueMatches(org.springframework.http.HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType())
.expectHeader().doesNotExist(org.springframework.http.HttpHeaders.WWW_AUTHENTICATE)
.expectHeader().valueMatches(org.springframework.http.HttpHeaders.EXPIRES, "0")
.expectBody()
.jsonPath("$.testkey").isEqualTo("testvalue");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ void setup() {
.withStatus(HttpStatus.INTERNAL_SERVER_ERROR.value())
.withHeaders(new HttpHeaders(
new HttpHeader("Content-Type", "application/json"),
new HttpHeader("WWW-Authenticate", "Bearer realm=\"Access to the staging site\", charset=\"UTF-8\""),
new HttpHeader("Expires", "Wed, 21 Oct 2099 07:28:06 GMT")))
new HttpHeader("WWW-Authenticate", "Bearer realm=\"Access to the staging site\", charset=\"UTF-8\"")))
.withBody("{ \"testkey\" : \"testvalue\" }")));
}

Expand All @@ -55,7 +54,6 @@ void backendError() {
.expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR)
.expectHeader().valueMatches("Content-Type", "application/json")
.expectHeader().doesNotExist("WWW-Authenticate")
.expectHeader().valueMatches("Expires", "0")
.expectBody()
.jsonPath("$.status").isEqualTo("500")
.jsonPath("$.error").isEqualTo("Internal Server Error");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ void setup() {
.withHeaders(new HttpHeaders(
new HttpHeader(org.springframework.http.HttpHeaders.CONTENT_TYPE, "application/json"),
new HttpHeader(org.springframework.http.HttpHeaders.WWW_AUTHENTICATE,
"Bearer realm=\"Access to the staging site\", charset=\"UTF-8\""), // removed by route filter
new HttpHeader(org.springframework.http.HttpHeaders.EXPIRES, "Wed, 21 Oct 2099 07:28:06 GMT") // removed by route filter
"Bearer realm=\"Access to the staging site\", charset=\"UTF-8\"") // removed by route filter
))
.withBody("{ \"testkey\" : \"testvalue\" }")));
}
Expand All @@ -58,7 +57,6 @@ void backendRouteResponse() {
.expectStatus().isEqualTo(HttpStatus.OK)
.expectHeader().valueMatches(org.springframework.http.HttpHeaders.CONTENT_TYPE, "application/json")
.expectHeader().doesNotExist(org.springframework.http.HttpHeaders.WWW_AUTHENTICATE)
.expectHeader().valueMatches(org.springframework.http.HttpHeaders.EXPIRES, "0")
.expectBody().jsonPath("$.testkey").isEqualTo("testvalue");

verify(getRequestedFor(urlEqualTo("/remote/endpoint"))
Expand Down

0 comments on commit 74acd8c

Please sign in to comment.