Search in sources :

Example 1 with UniversalUserTokenExtractor

use of gov.ca.cwds.service.oauth.UniversalUserTokenExtractor 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());
}
Also used : UniversalUserToken(gov.ca.cwds.UniversalUserToken) HashMap(java.util.HashMap) PerryProperties(gov.ca.cwds.PerryProperties) UniversalUserTokenExtractor(gov.ca.cwds.service.oauth.UniversalUserTokenExtractor) Test(org.junit.Test)

Aggregations

PerryProperties (gov.ca.cwds.PerryProperties)1 UniversalUserToken (gov.ca.cwds.UniversalUserToken)1 UniversalUserTokenExtractor (gov.ca.cwds.service.oauth.UniversalUserTokenExtractor)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1