Skip to content

Commit

Permalink
Add JwtTestResource injecting JwtTokenKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
mcruzdev committed Nov 5, 2024
1 parent 1654dd4 commit 1076854
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
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));
}
}
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");
}
}

0 comments on commit 1076854

Please sign in to comment.