Skip to content

Commit

Permalink
Merge pull request #618 from bancolombia/feature/webflux-router-test
Browse files Browse the repository at this point in the history
fix: add config test when router option is true
  • Loading branch information
santicalleg authored Jan 13, 2025
2 parents a6f6912 + 0f32161 commit 8f919eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"entry-point/rest-webflux/cors-config.java.mustache": "infrastructure/entry-points/reactive-web/src/main/java/{{packagePath}}/api/config/CorsConfig.java",
"entry-point/rest-webflux/security-headers-filter.java.mustache": "infrastructure/entry-points/reactive-web/src/main/java/{{packagePath}}/api/config/SecurityHeadersConfig.java",
"entry-point/rest-webflux/router-functions/router.unit.test.java.mustache": "infrastructure/entry-points/reactive-web/src/test/java/{{packagePath}}/api/RouterRestTest.java",
"entry-point/rest-webflux/router-functions/config.unit.test.java.mustache": "infrastructure/entry-points/reactive-web/src/test/java/{{packagePath}}/api/config/ConfigTest.java",
"entry-point/rest-webflux/build.gradle.mustache": "infrastructure/entry-points/reactive-web/build.gradle"
}
}

0 comments on commit 8f919eb

Please sign in to comment.