-
Notifications
You must be signed in to change notification settings - Fork 155
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 #618 from bancolombia/feature/webflux-router-test
fix: add config test when router option is true
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/resources/entry-point/rest-webflux/router-functions/config.unit.test.java.mustache
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,36 @@ | ||
package {{package}}.api.config; | ||
|
||
import {{package}}.api.Handler; | ||
import {{package}}.api.RouterRest; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
|
||
@ContextConfiguration(classes = {RouterRest.class, Handler.class}) | ||
@WebFluxTest | ||
@Import({CorsConfig.class, SecurityHeadersConfig.class}) | ||
class ConfigTest { | ||
@Autowired | ||
private WebTestClient webTestClient; | ||
@Test | ||
void corsConfigurationShouldAllowOrigins() { | ||
webTestClient.get() | ||
.uri("/api/usecase/path") | ||
.exchange() | ||
.expectStatus().isOk() | ||
.expectHeader().valueEquals("Content-Security-Policy", | ||
"default-src 'self'; frame-ancestors 'self'; form-action 'self'") | ||
.expectHeader().valueEquals("Strict-Transport-Security", "max-age=31536000;") | ||
.expectHeader().valueEquals("X-Content-Type-Options", "nosniff") | ||
.expectHeader().valueEquals("Server", "") | ||
.expectHeader().valueEquals("Cache-Control", "no-store") | ||
.expectHeader().valueEquals("Pragma", "no-cache") | ||
.expectHeader().valueEquals("Referrer-Policy", "strict-origin-when-cross-origin"); | ||
} | ||
|
||
} |
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