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);
}
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));
}
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));
}
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));
}
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()));
}
Aggregations