-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with build time config in dev mode
- Loading branch information
1 parent
4d45b0e
commit 7c6284f
Showing
2 changed files
with
83 additions
and
52 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
50 changes: 50 additions & 0 deletions
50
...ployment/src/test/java/io/quarkus/elytron/security/jdbc/CustomRoleDecoderDevModeTest.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,50 @@ | ||
package io.quarkus.elytron.security.jdbc; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Stream; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
|
||
//see https://github.com/quarkusio/quarkus/issues/9296 | ||
public class CustomRoleDecoderDevModeTest extends JdbcSecurityRealmTest { | ||
|
||
static Class[] testClassesWithCustomRoleDecoder = Stream.concat( | ||
Arrays.stream(testClasses), | ||
Arrays.stream(new Class[] { CustomRoleDecoder.class })).toArray(Class[]::new); | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(testClassesWithCustomRoleDecoder) | ||
.addAsResource("custom-role-decoder/import.sql") | ||
.addAsResource("custom-role-decoder/application.properties", "application.properties")); | ||
|
||
@Test | ||
public void testConfigChange() { | ||
RestAssured.given().auth().preemptive().basic("user", "user") | ||
.when().get("/servlet-secured").then() | ||
.statusCode(200); | ||
//break the build time config | ||
config.modifyResourceFile("application.properties", | ||
s -> s.replace("quarkus.security.jdbc.principal-query.attribute-mappings.0.index=2", | ||
"quarkus.security.jdbc.principal-query.attribute-mappings.0.index=3")); | ||
RestAssured.given().auth().preemptive().basic("user", "user") | ||
.when().get("/servlet-secured").then() | ||
.statusCode(500); | ||
|
||
//now fix it again | ||
config.modifyResourceFile("application.properties", | ||
s -> s.replace("quarkus.security.jdbc.principal-query.attribute-mappings.0.index=3", | ||
"quarkus.security.jdbc.principal-query.attribute-mappings.0.index=2")); | ||
RestAssured.given().auth().preemptive().basic("user", "user") | ||
.when().get("/servlet-secured").then() | ||
.statusCode(200); | ||
} | ||
|
||
} |