use of ddf.security.claims.ClaimsParameters in project ddf by codice.
the class PropertyFileClaimsHandlerTest method testRetrieveClaimValues.
@Test
public void testRetrieveClaimValues() {
PropertyFileClaimsHandler propertyFileClaimsHandler = new PropertyFileClaimsHandler();
propertyFileClaimsHandler.setPropertyFileLocation("/users.properties");
propertyFileClaimsHandler.setRoleClaimType("http://myroletype");
propertyFileClaimsHandler.setIdClaimType("http://myidtype");
ClaimsParameters claimsParameters = mock(ClaimsParameters.class);
Principal principal = mock(Principal.class);
when(principal.getName()).thenReturn("admin");
when(claimsParameters.getPrincipal()).thenReturn(principal);
ClaimsCollection processedClaimCollection = propertyFileClaimsHandler.retrieveClaims(claimsParameters);
assertEquals(2, processedClaimCollection.size());
assertEquals(4, processedClaimCollection.get(0).getValues().size());
assertEquals("admin", processedClaimCollection.get(1).getValues().get(0));
}
use of ddf.security.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesNoCertValues.
@Test
public void testRetrieveClaimValuesNoCertValues() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
ClaimsParameters parameters = new ClaimsParametersImpl(mock(Principal.class), new HashSet<>(), new HashMap<>());
ClaimsCollection processedClaims = certificateClaimsHandler.retrieveClaims(parameters);
assertThat(processedClaims.size(), is(0));
}
use of ddf.security.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithCountry.
@Test
public void testRetrieveClaimValuesWithCountry() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
Map<String, Object> map = new HashMap<>();
map.put(SubjectOperations.COUNTRY_CLAIM_URI, "USA");
ClaimsParameters parameters = new ClaimsParametersImpl(mock(Principal.class), new HashSet<>(), map);
ClaimsCollection processedClaims = certificateClaimsHandler.retrieveClaims(parameters);
assertThat(processedClaims.size(), is(1));
assertThat(processedClaims.stream().map(ddf.security.claims.Claim::getName).collect(Collectors.toList()), containsInAnyOrder(SubjectOperations.COUNTRY_CLAIM_URI));
}
use of ddf.security.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithCertValues.
@Test
public void testRetrieveClaimValuesWithCertValues() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
Map<String, Object> map = new HashMap<>();
map.put(SubjectOperations.EMAIL_ADDRESS_CLAIM_URI, "local@localhost");
map.put(SubjectOperations.COUNTRY_CLAIM_URI, "USA");
ClaimsParameters parameters = new ClaimsParametersImpl(mock(Principal.class), new HashSet<>(), map);
ClaimsCollection processedClaims = certificateClaimsHandler.retrieveClaims(parameters);
assertThat(processedClaims.size(), is(2));
assertThat(processedClaims.stream().map(ddf.security.claims.Claim::getName).collect(Collectors.toList()), containsInAnyOrder(SubjectOperations.EMAIL_ADDRESS_CLAIM_URI, SubjectOperations.COUNTRY_CLAIM_URI));
}
use of ddf.security.claims.ClaimsParameters in project ddf by codice.
the class CertificateClaimsHandlerTest method testRetrieveClaimValuesWithAltNamesRequested.
@Test
public void testRetrieveClaimValuesWithAltNamesRequested() throws URISyntaxException {
CertificateClaimsHandler certificateClaimsHandler = new CertificateClaimsHandler();
certificateClaimsHandler.setCountryClaim("Country");
certificateClaimsHandler.setEmailClaim("Email");
Map<String, Object> map = new HashMap<>();
map.put(SubjectOperations.EMAIL_ADDRESS_CLAIM_URI, "local@localhost");
map.put(SubjectOperations.COUNTRY_CLAIM_URI, "USA");
ClaimsParameters parameters = new ClaimsParametersImpl(mock(Principal.class), new HashSet<>(), map);
ClaimsCollection processedClaims = certificateClaimsHandler.retrieveClaims(parameters);
assertThat(processedClaims.size(), is(2));
assertThat(processedClaims.stream().map(ddf.security.claims.Claim::getName).collect(Collectors.toList()), containsInAnyOrder("Email", "Country"));
}
Aggregations