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);
}
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));
}
use of ddf.catalog.plugin.PolicyResponse 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()));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class RegistryPolicyPluginTest method testNoRegistryBypassPermissions.
@Test
public void testNoRegistryBypassPermissions() 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(null);
PolicyResponse response = rpp.processPostQuery(new ResultImpl(mcard), null);
assertThat(response.itemPolicy().isEmpty(), is(true));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class WorkspaceSharingPolicyPluginTest method testOwnerOnCreate.
@Test
public void testOwnerOnCreate() throws Exception {
String email = "a@b.c";
WorkspaceMetacardImpl workspace = new WorkspaceMetacardImpl();
workspace.setOwner(email);
PolicyResponse response = plugin.processPreCreate(workspace, properties);
assertThat(response.itemPolicy(), is(Collections.emptyMap()));
}
Aggregations