Search in sources :

Example 61 with PolicyResponse

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));
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 62 with PolicyResponse

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));
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ResourceRequest(ddf.catalog.operation.ResourceRequest) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 63 with PolicyResponse

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));
}
Also used : ArrayList(java.util.ArrayList) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 64 with PolicyResponse

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 65 with PolicyResponse

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);
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Aggregations

PolicyResponse (ddf.catalog.plugin.PolicyResponse)75 Test (org.junit.Test)64 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)20 Metacard (ddf.catalog.data.Metacard)19 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)14 Serializable (java.io.Serializable)14 Set (java.util.Set)14 Result (ddf.catalog.data.Result)13 HashMap (java.util.HashMap)12 PolicyPlugin (ddf.catalog.plugin.PolicyPlugin)10 HashSet (java.util.HashSet)7 ResultImpl (ddf.catalog.data.impl.ResultImpl)6 ResourceResponse (ddf.catalog.operation.ResourceResponse)6 Query (ddf.catalog.operation.Query)5 StopProcessingException (ddf.catalog.plugin.StopProcessingException)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ResourceRequest (ddf.catalog.operation.ResourceRequest)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 OPERATION_TRANSACTION_KEY (ddf.catalog.Constants.OPERATION_TRANSACTION_KEY)2