use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class TokenServiceTest method issueAccessCode.
private String issueAccessCode(String perryToken) {
OAuth2AccessToken accessToken = new DefaultOAuth2AccessToken(ACCESS_TOKEN);
UniversalUserToken universalUserToken = new UniversalUserToken();
universalUserToken.setUserId(USER_ID);
universalUserToken.setToken(perryToken);
return tokenService.issueAccessCode(universalUserToken, accessToken);
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class BaseScriptTest method test.
public void test(String script, String json, String userAuthorization) throws Exception {
IdentityMappingScript identityMappingScript = loadScript(script);
UniversalUserToken user = new UniversalUserToken();
UserAuthorization authorization = MAPPER.readValue(fixture(userAuthorization), UserAuthorization.class);
user.setAuthorization(authorization);
String result = identityMappingScript.map(user);
System.out.println(result);
String expectedResult = readResource(json);
Assert.assertEquals(expectedResult, result);
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class IdentityMappingServiceTest method test.
@Test
public void test() {
IdentityMappingService identityMappingService = new IdentityMappingService();
PerryProperties configuration = new PerryProperties();
identityMappingService.setConfiguration(configuration);
UniversalUserToken universalUserToken = new UniversalUserToken();
universalUserToken.setUserId("user");
String user = identityMappingService.map(universalUserToken, "test");
assert user.equals("user");
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class IdpMappingScriptTest method testGroovyMapping.
@Test
public void testGroovyMapping() throws Exception {
String path = Paths.get(getClass().getResource("/idp.groovy").toURI()).toString();
IdpMappingScript idpMappingScript = new IdpMappingScript(path);
Map<String, Object> userInfo = new HashMap<>();
userInfo.put("safid.racfid", "racfid");
userInfo.put("ok", "true");
UniversalUserToken userToken = idpMappingScript.map(userInfo);
assertEquals("racfid", userToken.getUserId());
}
use of gov.ca.cwds.UniversalUserToken in project perry by ca-cwds.
the class UniversalUserTokenExtractorTest method test.
@Test
public void test() throws Exception {
PerryProperties perryProperties = new PerryProperties();
PerryProperties.IdentityProviderConfiguration identityProviderConfiguration = new PerryProperties.IdentityProviderConfiguration();
String path = Paths.get(getClass().getResource("/idp.groovy").toURI()).toString();
identityProviderConfiguration.setIdpMapping(path);
perryProperties.setIdentityProvider(identityProviderConfiguration);
UniversalUserTokenExtractor userTokenExtractor = new UniversalUserTokenExtractor();
userTokenExtractor.setConfiguration(perryProperties);
Map<String, Object> userInfo = new HashMap<>();
userInfo.put("safid.racfid", "racfid");
userInfo.put("ok", "true");
UniversalUserToken token = userTokenExtractor.extractPrincipal(userInfo);
assertEquals("racfid", token.getUserId());
}
Aggregations