use of org.pac4j.core.util.generator.StaticValueGenerator in project pac4j by pac4j.
the class JwtTests method testPlainJwtNoSubjectButIdentifierGenerator.
@Test
public void testPlainJwtNoSubjectButIdentifierGenerator() {
final var generator = new JwtGenerator();
final var token = generator.generate(new HashMap<>());
var authenticator = new JwtAuthenticator();
authenticator.setIdentifierGenerator(new StaticValueGenerator(VALUE));
final var profile = authenticator.validateToken(token);
assertEquals(VALUE, profile.getId());
}
use of org.pac4j.core.util.generator.StaticValueGenerator in project pac4j by pac4j.
the class OAuth20ClientTests method testSetState.
@Test
public void testSetState() throws MalformedURLException {
var client = new FacebookClient(KEY, SECRET);
client.setCallbackUrl(CALLBACK_URL);
client.getConfiguration().setStateGenerator(new StaticValueGenerator("oldstate"));
final var mockWebContext = MockWebContext.create();
var action = (FoundAction) client.getRedirectionAction(mockWebContext, new MockSessionStore()).get();
var url = new URL(action.getLocation());
final var stringMap = TestsHelper.splitQuery(url);
assertEquals(stringMap.get("state"), "oldstate");
action = (FoundAction) client.getRedirectionAction(mockWebContext, new MockSessionStore()).get();
var url2 = new URL(action.getLocation());
final var stringMap2 = TestsHelper.splitQuery(url2);
assertEquals(stringMap2.get("state"), "oldstate");
}
use of org.pac4j.core.util.generator.StaticValueGenerator in project pac4j by pac4j.
the class OAuth20ClientTests method testState.
@Test
public void testState() throws MalformedURLException {
var client = new FacebookClient(KEY, SECRET);
client.setCallbackUrl(CALLBACK_URL);
client.getConfiguration().setStateGenerator(new StaticValueGenerator("OK"));
final var action = (FoundAction) client.getRedirectionAction(MockWebContext.create(), new MockSessionStore()).get();
var url = new URL(action.getLocation());
assertTrue(url.getQuery().contains("state=OK"));
}
Aggregations