Search in sources :

Example 16 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class CatalogPolicyTest method testPreUpdate.

@Test
public void testPreUpdate() throws StopProcessingException {
    policyPlugin.setUpdatePermissions(new String[] { "role=admin" });
    PolicyResponse response = policyPlugin.processPreUpdate(mock(Metacard.class), new HashMap<>());
    assertThat(response.itemPolicy().size(), equalTo(0));
    assertThat(response.operationPolicy().size(), equalTo(1));
    response = policyPlugin.processPreUpdate(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 17 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class PointOfContactPolicyPluginTest method processPreQueryDoesNothing.

@Test
public void processPreQueryDoesNothing() throws java.lang.Exception {
    PolicyResponse response = pointOfContactPolicyPlugin.processPreQuery(mock(Query.class), Collections.emptyMap());
    responseIsEmpty(response);
}
Also used : Query(ddf.catalog.operation.Query) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 18 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class PointOfContactPolicyPluginTest method processPreUpdateReturnsPolicyWhenOldPointOfContactIsNull.

@Test
public void processPreUpdateReturnsPolicyWhenOldPointOfContactIsNull() throws java.lang.Exception {
    MetacardImpl oldMetacard = getMetacardWithPointOfContact(null);
    PolicyResponse response = pointOfContactPolicyPlugin.processPreUpdate(getMetacardWithPointOfContact(TEST_POINT_OF_CONTACT), setupAndGetInputProperties(oldMetacard));
    responseHasPolicy(response);
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 19 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class PointOfContactPolicyPluginTest method processPreResourceDoesNothing.

@Test
public void processPreResourceDoesNothing() throws java.lang.Exception {
    PolicyResponse response = pointOfContactPolicyPlugin.processPreResource(new ResourceRequestById(TEST_ID));
    responseIsEmpty(response);
}
Also used : ResourceRequestById(ddf.catalog.operation.impl.ResourceRequestById) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 20 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class RegistryPolicyPluginTest method testSecurityValueInvalidStrings.

@Test
public void testSecurityValueInvalidStrings() throws Exception {
    RegistryPolicyPlugin rpp = createRegistryPlugin();
    Metacard mcard = new MetacardImpl();
    mcard.setAttribute(new AttributeImpl(Metacard.TAGS, RegistryConstants.REGISTRY_TAG));
    mcard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "validId"));
    mcard.setAttribute(new AttributeImpl(Metacard.ID, "1234567890abcdefg987654321"));
    List<Serializable> securityValues = new ArrayList<>();
    securityValues.add(" ");
    securityValues.add("");
    securityValues.add("badString");
    mcard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.SECURITY_LEVEL, securityValues));
    PolicyResponse response = rpp.processPreCreate(mcard, null);
    assertThat(response.operationPolicy().size(), is(0));
    assertThat(response.itemPolicy().size(), is(0));
}
Also used : Metacard(ddf.catalog.data.Metacard) Serializable(java.io.Serializable) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList) PolicyResponse(ddf.catalog.plugin.PolicyResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) 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