use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardAttributeSecurityPolicyPluginTest method testProcessPreUpdate.
@Test
public void testProcessPreUpdate() throws StopProcessingException {
PolicyResponse policyResponse = plugin.processPreUpdate(metacard, new HashMap<>());
assertThat(policyResponse.itemPolicy().size(), is(2));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("A"));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("B"));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("C"));
assertTrue(policyResponse.itemPolicy().get("mapped.countries").contains("USA"));
assertTrue(policyResponse.itemPolicy().get("mapped.countries").contains("CAN"));
assertNull(policyResponse.itemPolicy().get("parsed.security"));
assertNull(policyResponse.itemPolicy().get("parsed.countries"));
assertNull(policyResponse.itemPolicy().get("parsed.other"));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardAttributeSecurityPolicyPluginTest method testProcessPreDelete.
@Test
public void testProcessPreDelete() throws StopProcessingException {
PolicyResponse policyResponse = plugin.processPreDelete(Arrays.asList(metacard, metacard1), new HashMap<>());
assertThat(policyResponse.operationPolicy().size(), is(2));
assertTrue(policyResponse.operationPolicy().get("mapped.security").contains("A"));
assertTrue(policyResponse.operationPolicy().get("mapped.security").contains("B"));
assertTrue(policyResponse.operationPolicy().get("mapped.security").contains("C"));
assertTrue(policyResponse.operationPolicy().get("mapped.security").contains("X"));
assertTrue(policyResponse.operationPolicy().get("mapped.security").contains("Y"));
assertTrue(policyResponse.operationPolicy().get("mapped.security").contains("Z"));
assertTrue(policyResponse.operationPolicy().get("mapped.countries").contains("USA"));
assertTrue(policyResponse.operationPolicy().get("mapped.countries").contains("CAN"));
assertTrue(policyResponse.operationPolicy().get("mapped.countries").contains("GBR"));
assertNull(policyResponse.itemPolicy().get("parsed.security"));
assertNull(policyResponse.itemPolicy().get("parsed.countries"));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardAttributeSecurityPolicyPluginTest method testProcessPostDelete.
@Test
public void testProcessPostDelete() throws StopProcessingException {
PolicyResponse policyResponse = plugin.processPostDelete(metacard, new HashMap<>());
assertThat(policyResponse.itemPolicy().size(), is(2));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("A"));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("B"));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("C"));
assertTrue(policyResponse.itemPolicy().get("mapped.countries").contains("USA"));
assertTrue(policyResponse.itemPolicy().get("mapped.countries").contains("CAN"));
assertNull(policyResponse.itemPolicy().get("parsed.security"));
assertNull(policyResponse.itemPolicy().get("parsed.countries"));
assertNull(policyResponse.itemPolicy().get("parsed.other"));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardAttributeSecurityPolicyPluginTest method testUnionAttributes.
@Test
public void testUnionAttributes() throws Exception {
plugin.setUnionMetacardAttributes(Arrays.asList("source1=dest", "source2=dest", "source3=dest", "source4=dest2"));
PolicyResponse policyResponse = plugin.processPreCreate(metacard2, new HashMap<>());
Map<String, Set<String>> itemPolicy = policyResponse.itemPolicy();
assertThat(itemPolicy.size(), is(2));
assertThat(itemPolicy.get("dest").size(), is(6));
assertTrue(itemPolicy.get("dest").containsAll(ImmutableSet.of("A", "B", "C", "D", "E", "F")));
assertThat(itemPolicy.get("dest2").size(), is(3));
assertTrue(itemPolicy.get("dest2").containsAll(ImmutableSet.of("F", "G", "H")));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardAttributeSecurityPolicyPluginTest method testProcessPostResource.
@Test
public void testProcessPostResource() throws StopProcessingException {
PolicyResponse policyResponse = plugin.processPostResource(mock(ResourceResponse.class), metacard);
assertThat(policyResponse.itemPolicy().size(), is(2));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("A"));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("B"));
assertTrue(policyResponse.itemPolicy().get("mapped.security").contains("C"));
assertTrue(policyResponse.itemPolicy().get("mapped.countries").contains("USA"));
assertTrue(policyResponse.itemPolicy().get("mapped.countries").contains("CAN"));
assertNull(policyResponse.itemPolicy().get("parsed.security"));
assertNull(policyResponse.itemPolicy().get("parsed.countries"));
assertNull(policyResponse.itemPolicy().get("parsed.other"));
}
Aggregations