use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class CatalogPolicyTest method testPostResources.
@Test
public void testPostResources() throws StopProcessingException {
ResourceResponse resourceResponse = mock(ResourceResponse.class);
PolicyResponse response = policyPlugin.processPostResource(resourceResponse, mock(Metacard.class));
assertThat(response.itemPolicy().size(), equalTo(0));
assertThat(response.operationPolicy().size(), equalTo(0));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceUriPolicyTest method testInputUriNotEmptyAndDifferentThanCatalogUri.
@Test
public void testInputUriNotEmptyAndDifferentThanCatalogUri() throws URISyntaxException, StopProcessingException {
PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard("differentURI"), getMockProperties("foo"));
assertNotEmpty(response, "If metacard and update each has resource URI, but differ, policy needed to ensure no overwriting occurs");
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceUriPolicyTest method testInputUriNotEmptyAndMatchesCatalogUri.
@Test
public void testInputUriNotEmptyAndMatchesCatalogUri() throws URISyntaxException, StopProcessingException {
PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard("sampleURI"), getMockProperties("sampleURI"));
assertEmptyResponse(response);
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceUriPolicyTest method testCreatePermission.
@Test
public void testCreatePermission() throws URISyntaxException, StopProcessingException {
PolicyResponse response = getPolicyPlugin().processPreCreate(getMockMetacard("sampleURI"), getMockProperties("zoom"));
Map<String, Set<String>> itemPolicy = response.itemPolicy();
assertThat("Creating a metacard with a resource URI requires special permissions", itemPolicy.containsKey("fizzle"), is(true));
assertThat(itemPolicy.get("fizzle"), containsInAnyOrder("bang"));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceUriPolicyTest method testInputUriEmptyButCatalogUriNotEmpty.
@Test
public void testInputUriEmptyButCatalogUriNotEmpty() throws URISyntaxException, StopProcessingException {
PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard(""), getMockProperties("sampleURI"));
assertNotEmpty(response, "If metacard has resource URI, but update does not, policy needed to ensure no overwriting occurs");
}
Aggregations