Search in sources :

Example 6 with PerryProperties

use of gov.ca.cwds.PerryProperties in project perry by ca-cwds.

the class WhiteListTest method testDisabled.

@Test
public void testDisabled() {
    WhiteList whiteList = new WhiteList();
    PerryProperties perryProperties = new PerryProperties();
    perryProperties.setWhiteList("*");
    whiteList.configuration = perryProperties;
    whiteList.validate("", "url3");
}
Also used : PerryProperties(gov.ca.cwds.PerryProperties) Test(org.junit.Test)

Example 7 with PerryProperties

use of gov.ca.cwds.PerryProperties in project perry by ca-cwds.

the class WhiteListTest method testEnabledValidUrl.

@Test
public void testEnabledValidUrl() {
    WhiteList whiteList = new WhiteList();
    PerryProperties perryProperties = new PerryProperties();
    perryProperties.setWhiteList("url1 url2");
    whiteList.configuration = perryProperties;
    whiteList.validate("", "url1");
}
Also used : PerryProperties(gov.ca.cwds.PerryProperties) Test(org.junit.Test)

Example 8 with PerryProperties

use of gov.ca.cwds.PerryProperties in project perry by ca-cwds.

the class WhiteListTest method testEnabledInvalidUrl.

@Test(expected = PerryException.class)
public void testEnabledInvalidUrl() {
    WhiteList whiteList = new WhiteList();
    PerryProperties perryProperties = new PerryProperties();
    perryProperties.setWhiteList("url1 url2");
    whiteList.configuration = perryProperties;
    whiteList.validate("", "url3");
}
Also used : PerryProperties(gov.ca.cwds.PerryProperties) Test(org.junit.Test)

Example 9 with PerryProperties

use of gov.ca.cwds.PerryProperties 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)9 Test (org.junit.Test)8 WhiteList (gov.ca.cwds.service.WhiteList)3 FilterChain (javax.servlet.FilterChain)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 RequestMatcher (org.springframework.security.web.util.matcher.RequestMatcher)3 UniversalUserToken (gov.ca.cwds.UniversalUserToken)2 UniversalUserTokenExtractor (gov.ca.cwds.service.oauth.UniversalUserTokenExtractor)1 HashMap (java.util.HashMap)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 Before (org.junit.Before)1