use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class CatalogPolicyTest method testPostQuery.
@Test
public void testPostQuery() throws StopProcessingException {
PolicyResponse response = policyPlugin.processPostQuery(mock(Result.class), new HashMap<>());
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(0));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class CatalogPolicyTest method testPreResource.
@Test
public void testPreResource() throws StopProcessingException {
policyPlugin.setReadPermissions(new String[] { "role=admin" });
ResourceRequest mock = mock(ResourceRequest.class);
Map<String, Serializable> properties = new HashMap<>();
properties.put(Constants.LOCAL_DESTINATION_KEY, true);
when(mock.getProperties()).thenReturn(properties);
PolicyResponse response = policyPlugin.processPreResource(mock);
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(1));
properties.put(Constants.LOCAL_DESTINATION_KEY, false);
response = policyPlugin.processPreResource(mock);
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(0));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class CatalogPolicyTest method testPreDelete.
@Test
public void testPreDelete() throws StopProcessingException {
policyPlugin.setDeletePermissions(new String[] { "role=admin" });
PolicyResponse response = policyPlugin.processPreDelete(new ArrayList<>(), new HashMap<>());
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(1));
response = policyPlugin.processPreDelete(new ArrayList<>(), Collections.singletonMap(Constants.LOCAL_DESTINATION_KEY, false));
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(0));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class CatalogPolicyTest method testPreCreate.
@Test
public void testPreCreate() throws StopProcessingException {
policyPlugin.setCreatePermissions(new String[] { "role=admin" });
PolicyResponse response = policyPlugin.processPreCreate(mock(Metacard.class), new HashMap<>());
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(1));
response = policyPlugin.processPreCreate(mock(Metacard.class), Collections.singletonMap(Constants.LOCAL_DESTINATION_KEY, false));
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(0));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class PointOfContactPolicyPluginTest method processPreDeleteDoesNothing.
@Test
public void processPreDeleteDoesNothing() throws java.lang.Exception {
PolicyResponse response = pointOfContactPolicyPlugin.processPreDelete(Collections.emptyList(), Collections.emptyMap());
responseIsEmpty(response);
}
Aggregations