DefaultSecurityAttributeValuesPlugin implements PreIngestPlugin { @Override public CreateRequest process(CreateRequest createRequest) { List<Metacard> updatedMetacards = createRequest.getMetacards().stream() .filter(Objects::nonNull) .map(this::addDefaults) .collect(Collectors.toList()); return new CreateRequestImpl( updatedMetacards, createRequest.getProperties(), createRequest.getStoreIds()); } DefaultSecurityAttributeValuesPlugin(
      SecurityAttributes securityAttributes,
      SystemHighAttributes systemHighAttributes,
      Map<String, String> initialValues); @Override CreateRequest process(CreateRequest createRequest); @Override UpdateRequest process(UpdateRequest updateRequest); @Override DeleteRequest process(DeleteRequest input); void setAttributeMappings(List<String> attributeMappings);  }
@Test public void testProcessUnmarkedMetacard() { final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin( new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration()); final CreateRequest modifiedCreateRequest = defaultSecurityAttributeValuesPlugin.process( createCreateRequest(createUnmarkedMetacardWithoutSecurityDescriptors())); final List<Metacard> resultMetacards = modifiedCreateRequest.getMetacards(); assertThat(resultMetacards, hasSize(1)); assertTestDefaultsAdded(resultMetacards.get(0)); }
@Test public void testProcessUnmarkedMetacardWithSecurityAttributeDescriptors() { final MetacardImpl unmarkedMetacardWithSecurityAttributeDescriptors = new MetacardImpl(new SecurityAttributes()); unmarkedMetacardWithSecurityAttributeDescriptors.setTags( Collections.singleton(Metacard.DEFAULT_TAG)); final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin( new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration()); final CreateRequest modifiedCreateRequest = defaultSecurityAttributeValuesPlugin.process( createCreateRequest(unmarkedMetacardWithSecurityAttributeDescriptors)); final List<Metacard> resultMetacards = modifiedCreateRequest.getMetacards(); assertThat(resultMetacards, hasSize(1)); assertTestDefaultsAdded(resultMetacards.get(0)); }
@Test public void testProcessUpdateRequest() { final UpdateRequest updateRequest = mock(UpdateRequest.class); final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin( new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration()); final UpdateRequest modifiedRequest = defaultSecurityAttributeValuesPlugin.process(updateRequest); verifyZeroInteractions(updateRequest); assertThat(updateRequest, is(modifiedRequest)); }
@Test public void testProcessDeleteRequest() { final DeleteRequest deleteRequest = mock(DeleteRequest.class); final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin( new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration()); final DeleteRequest modifiedRequest = defaultSecurityAttributeValuesPlugin.process(deleteRequest); verifyZeroInteractions(deleteRequest); assertThat(deleteRequest, is(modifiedRequest)); }