-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JwtTestResource injecting JwtTokenKeys
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
test-framework/security-jwt/src/main/java/io/quarkus/test/security/jwt/JwtTestResource.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,32 @@ | ||
package io.quarkus.test.security.jwt; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.test.common.DevServicesContext; | ||
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
|
||
public class JwtTestResource implements QuarkusTestResourceLifecycleManager, DevServicesContext.ContextAware { | ||
|
||
final JwtTokenKeys jwtTokenKeys = new JwtTokenKeys(); | ||
|
||
@Override | ||
public void setIntegrationTestContext(DevServicesContext context) { | ||
jwtTokenKeys.setIntegrationTestContext(context); | ||
} | ||
|
||
@Override | ||
public Map<String, String> start() { | ||
return Map.of(); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
} | ||
|
||
@Override | ||
public void inject(TestInjector testInjector) { | ||
testInjector.injectIntoFields( | ||
jwtTokenKeys, | ||
new TestInjector.MatchesType(JwtTokenKeys.class)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
test-framework/security-jwt/src/main/java/io/quarkus/test/security/jwt/JwtTokenKeys.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,20 @@ | ||
package io.quarkus.test.security.jwt; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.test.common.DevServicesContext; | ||
|
||
public class JwtTokenKeys implements DevServicesContext.ContextAware { | ||
|
||
DevServicesContext devServicesContext; | ||
|
||
@Override | ||
public void setIntegrationTestContext(DevServicesContext context) { | ||
this.devServicesContext = context; | ||
} | ||
|
||
public String getSignPrivateKey() { | ||
Map<String, String> properties = this.devServicesContext.devServicesProperties(); | ||
return properties.get("smallrye.jwt.sign.key"); | ||
} | ||
} |