forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
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 quarkusio#36728 from michalvavrik/feature/security…
…-jpa-named-unit JPA Security: allow pointing to a named persistence unit
- Loading branch information
Showing
6 changed files
with
103 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
...ployment/src/main/java/io/quarkus/security/jpa/deployment/SecurityJpaBuildTimeConfig.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,19 @@ | ||
package io.quarkus.security.jpa.deployment; | ||
|
||
import static io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil.DEFAULT_PERSISTENCE_UNIT_NAME; | ||
|
||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
|
||
@ConfigRoot | ||
@ConfigMapping(prefix = "quarkus.security-jpa") | ||
public interface SecurityJpaBuildTimeConfig { | ||
|
||
/** | ||
* Selects the Hibernate ORM persistence unit. Default persistence unit is used when no value is specified. | ||
*/ | ||
@WithDefault(DEFAULT_PERSISTENCE_UNIT_NAME) | ||
String persistenceUnitName(); | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...curity-jpa/deployment/src/test/java/io/quarkus/security/jpa/NamedPersistenceUnitTest.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,17 @@ | ||
package io.quarkus.security.jpa; | ||
|
||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class NamedPersistenceUnitTest extends JpaSecurityRealmTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(testClasses) | ||
.addClass(MinimalUserEntity.class) | ||
.addAsResource("named-persistence-unit/import.sql", "import.sql") | ||
.addAsResource("named-persistence-unit/application.properties", "application.properties")); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
.../security-jpa/deployment/src/test/resources/named-persistence-unit/application.properties
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,11 @@ | ||
quarkus.datasource.heureka.db-kind=h2 | ||
quarkus.datasource.heureka.username=sa | ||
quarkus.datasource.heureka.password=sa | ||
quarkus.datasource.heureka.jdbc.url=jdbc:h2:mem:named-pu' | ||
quarkus.hibernate-orm.heureka.datasource=heureka | ||
quarkus.hibernate-orm.heureka.sql-load-script=import.sql | ||
quarkus.hibernate-orm.heureka.database.generation=drop-and-create | ||
quarkus.hibernate-orm.heureka.packages=io.quarkus.security.jpa | ||
quarkus.security-jpa.persistence-unit-name=heureka |
3 changes: 3 additions & 0 deletions
3
extensions/security-jpa/deployment/src/test/resources/named-persistence-unit/import.sql
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,3 @@ | ||
INSERT INTO test_user (id, username, password, role) VALUES (1, 'admin', 'admin', 'admin'); | ||
INSERT INTO test_user (id, username, password, role) VALUES (2, 'user','user', 'user'); | ||
INSERT INTO test_user (id, username, password, role) VALUES (3, 'noRoleUser','noRoleUser', ''); |