use of org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes in project alliance by codice.
the class DAGConverterTest method setUp.
@Before
public void setUp() throws Exception {
this.orb = ORB.init();
int year = 2016;
int month = 01;
int dayOfMonth = 29;
int hourOfDay = 17;
int minute = 05;
int second = 10;
cal = new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
dagConverter = new DAGConverter(mockResourceReader);
List<MetacardType> types = new ArrayList<>();
types.add(new AssociationsAttributes());
types.add(new ContactAttributes());
types.add(new DateTimeAttributes());
types.add(new LocationAttributes());
types.add(new IsrAttributes());
types.add(new SecurityAttributes());
MetacardTypeImpl metacardTypeImpl = new MetacardTypeImpl("NsiliMetacardType", types);
dagConverter.setNsiliMetacardType(metacardTypeImpl);
setupMocks();
}
use of org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes in project alliance by codice.
the class DefaultSecurityAttributeValuesPluginTest method testComponentManagedUpdateStrategy.
@Test
public void testComponentManagedUpdateStrategy() {
// given
final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin(new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration());
final Map<String, String> newConfiguration = new HashMap<>();
newConfiguration.put(CLASSIFICATION_CONFIGURATION_KEY, "classification");
newConfiguration.put(RELEASABILITY_CONFIGURATION_KEY, "releasableTo");
// this configuration value is different than the first configuration
newConfiguration.put(CODEWORDS_CONFIGURATION_KEY, "FineAccessControls");
newConfiguration.put(DISSEMINATION_CONTROLS_CONFIGURATION_KEY, "disseminationControls");
newConfiguration.put(OTHER_DISSEMINATION_CONTROLS_CONFIGURATION_KEY, "otherDisseminationControls");
newConfiguration.put(OWNER_PRODUCER_CONFIGURATION_KEY, "ownerProducer");
// when
defaultSecurityAttributeValuesPlugin.update(newConfiguration);
// then
final CreateRequest modifiedCreateRequest = defaultSecurityAttributeValuesPlugin.process(createCreateRequest(createUnmarkedMetacardWithoutSecurityDescriptors()));
final List<Metacard> resultMetacards = modifiedCreateRequest.getMetacards();
assertThat(resultMetacards, hasSize(1));
final Metacard modifiedMetacard = resultMetacards.get(0);
assertThat(modifiedMetacard.getAttribute(Security.CLASSIFICATION), allOf(notNullValue(), hasProperty("values", containsInAnyOrder("U"))));
assertThat(modifiedMetacard.getAttribute(Security.RELEASABILITY), allOf(notNullValue(), hasProperty("values", containsInAnyOrder("USA"))));
// this assert is different than the first configuration
assertThat(modifiedMetacard.getAttribute(Security.CODEWORDS), allOf(notNullValue(), hasProperty("values", containsInAnyOrder("SCI1", "SCI2"))));
assertThat(modifiedMetacard.getAttribute(Security.DISSEMINATION_CONTROLS), allOf(notNullValue(), hasProperty("values", containsInAnyOrder("NF"))));
assertThat(modifiedMetacard.getAttribute(Security.OTHER_DISSEMINATION_CONTROLS), nullValue());
assertThat(modifiedMetacard.getAttribute(Security.OWNER_PRODUCER), allOf(notNullValue(), hasProperty("values", containsInAnyOrder("USA"))));
assertThat(modifiedMetacard.getTags(), hasItem(DEFAULT_MARKINGS_TAG));
}
use of org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes in project alliance by codice.
the class DefaultSecurityAttributeValuesPluginTest method testProcessUpdateRequest.
@Test
public void testProcessUpdateRequest() {
// given
final UpdateRequest updateRequest = mock(UpdateRequest.class);
final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin(new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration());
// when
final UpdateRequest modifiedRequest = defaultSecurityAttributeValuesPlugin.process(updateRequest);
// then
verifyZeroInteractions(updateRequest);
assertThat(updateRequest, is(modifiedRequest));
}
use of org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes in project alliance by codice.
the class DefaultSecurityAttributeValuesPluginTest method testProcessUnmarkedMetacardWithSecurityAttributeDescriptors.
@Test
public void testProcessUnmarkedMetacardWithSecurityAttributeDescriptors() {
// given
final Metacard unmarkedMetacardWithSecurityAttributeDescriptors = new MetacardImpl(new SecurityAttributes());
final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin(new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration());
// when
final CreateRequest modifiedCreateRequest = defaultSecurityAttributeValuesPlugin.process(createCreateRequest(unmarkedMetacardWithSecurityAttributeDescriptors));
// then
final List<Metacard> resultMetacards = modifiedCreateRequest.getMetacards();
assertThat(resultMetacards, hasSize(1));
assertTestDefaultsAdded(resultMetacards.get(0));
}
use of org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes in project alliance by codice.
the class DefaultSecurityAttributeValuesPluginTest method testProcessDeleteRequest.
@Test
public void testProcessDeleteRequest() {
// given
final DeleteRequest deleteRequest = mock(DeleteRequest.class);
final DefaultSecurityAttributeValuesPlugin defaultSecurityAttributeValuesPlugin = new DefaultSecurityAttributeValuesPlugin(new SecurityAttributes(), createTestSystemHighAttributes(), createTestInitialConfiguration());
// when
final DeleteRequest modifiedRequest = defaultSecurityAttributeValuesPlugin.process(deleteRequest);
// then
verifyZeroInteractions(deleteRequest);
assertThat(deleteRequest, is(modifiedRequest));
}
Aggregations