Search in sources :

Example 31 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RegistryPublicationHandlerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mcard = new MetacardImpl();
    mcard.setAttribute(Metacard.TAGS, RegistryConstants.REGISTRY_TAG);
    rph = new RegistryPublicationHandler(service, executorService);
    eventProperties = new Hashtable<>();
    eventProperties.put("ddf.catalog.event.metacard", mcard);
    event = new Event("myevent", eventProperties);
}
Also used : Event(org.osgi.service.event.Event) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Before(org.junit.Before)

Example 32 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RegistryPublicationActionProviderTest method testGetActionMcardBadSubject.

@Test
public void testGetActionMcardBadSubject() throws Exception {
    List<Action> actions = publicationActionProvider.getActions(new MetacardImpl());
    assertThat(actions.size(), is(0));
}
Also used : Action(ddf.action.Action) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 33 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl 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)

Example 34 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RegistryPolicyPluginTest method testUnusedMethods.

@Test
public void testUnusedMethods() throws Exception {
    RegistryPolicyPlugin rpp = createRegistryPlugin();
    rpp.setRegistryBypassPolicyStrings(Collections.singletonList("role=system-admin"));
    rpp.setCreateAccessPolicyStrings(Collections.singletonList("role=guest"));
    rpp.setUpdateAccessPolicyStrings(Collections.singletonList("role=guest"));
    rpp.setDeleteAccessPolicyStrings(Collections.singletonList("role=guest"));
    rpp.setReadAccessPolicyStrings(Collections.singletonList("role=guest"));
    rpp.setRegistryEntryIds(Collections.singleton("1234567890abcdefg987654321"));
    assertThat(rpp.isRegistryDisabled(), is(false));
    assertThat(rpp.getBypassAccessPolicy().get("role").iterator().next(), equalTo("system-admin"));
    assertThat(rpp.getCreateAccessPolicy().get("role").iterator().next(), equalTo("guest"));
    assertThat(rpp.getReadAccessPolicy().get("role").iterator().next(), equalTo("guest"));
    assertThat(rpp.getRegistryEntryIds().contains("1234567890abcdefg987654321"), is(true));
    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"));
    assertThat(rpp.processPostDelete(mcard, null).itemPolicy().isEmpty(), is(true));
    assertThat(rpp.processPostDelete(mcard, null).operationPolicy().isEmpty(), is(true));
    assertThat(rpp.processPreQuery(null, null).itemPolicy().isEmpty(), is(true));
    assertThat(rpp.processPreQuery(null, null).operationPolicy().isEmpty(), is(true));
    assertThat(rpp.processPreResource(null).itemPolicy().isEmpty(), is(true));
    assertThat(rpp.processPreResource(null).operationPolicy().isEmpty(), is(true));
    assertThat(rpp.processPostResource(null, mcard).itemPolicy().isEmpty(), is(true));
    assertThat(rpp.processPostResource(null, mcard).operationPolicy().isEmpty(), is(true));
    assertThat(rpp.isWhiteList(), is(false));
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 35 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RegistryPolicyPluginTest method testBlackListPostQuery.

@Test
public void testBlackListPostQuery() throws Exception {
    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"));
    RegistryPolicyPlugin rpp = createRegistryPlugin();
    rpp.setRegistryBypassPolicyStrings(Collections.singletonList("role=system-admin"));
    PolicyResponse response = rpp.processPostQuery(new ResultImpl(mcard), null);
    assertThat(response.operationPolicy().size(), is(0));
    assertThat(response.itemPolicy().size(), is(0));
    rpp.setRegistryEntryIds(Collections.singleton("1234567890abcdefg987654321"));
    response = rpp.processPostQuery(new ResultImpl(mcard), null);
    assertThat(response.itemPolicy(), equalTo(rpp.getBypassAccessPolicy()));
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) PolicyResponse(ddf.catalog.plugin.PolicyResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Aggregations

MetacardImpl (ddf.catalog.data.impl.MetacardImpl)384 Test (org.junit.Test)247 Metacard (ddf.catalog.data.Metacard)144 ArrayList (java.util.ArrayList)102 Result (ddf.catalog.data.Result)62 HashMap (java.util.HashMap)59 Date (java.util.Date)52 ResultImpl (ddf.catalog.data.impl.ResultImpl)51 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)49 URI (java.net.URI)38 Matchers.anyString (org.mockito.Matchers.anyString)38 QueryRequest (ddf.catalog.operation.QueryRequest)36 QueryResponse (ddf.catalog.operation.QueryResponse)35 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)35 Serializable (java.io.Serializable)33 HashSet (java.util.HashSet)31 QueryImpl (ddf.catalog.operation.impl.QueryImpl)29 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)28 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)27 List (java.util.List)27