Search in sources :

Example 1 with SecurityAttributes

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();
}
Also used : ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) LocationAttributes(ddf.catalog.data.impl.types.LocationAttributes) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) MetacardType(ddf.catalog.data.MetacardType) SecurityAttributes(org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes) ResultDAGConverter(org.codice.alliance.nsili.common.ResultDAGConverter) DateTimeAttributes(ddf.catalog.data.impl.types.DateTimeAttributes) AssociationsAttributes(ddf.catalog.data.impl.types.AssociationsAttributes) IsrAttributes(org.codice.alliance.catalog.core.api.impl.types.IsrAttributes) Before(org.junit.Before)

Example 2 with SecurityAttributes

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) HashMap(java.util.HashMap) CreateRequest(ddf.catalog.operation.CreateRequest) Matchers.anyString(org.mockito.Matchers.anyString) SecurityAttributes(org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes) Test(org.junit.Test)

Example 3 with SecurityAttributes

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));
}
Also used : UpdateRequest(ddf.catalog.operation.UpdateRequest) SecurityAttributes(org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes) Test(org.junit.Test)

Example 4 with SecurityAttributes

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) SecurityAttributes(org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes) Test(org.junit.Test)

Example 5 with SecurityAttributes

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));
}
Also used : DeleteRequest(ddf.catalog.operation.DeleteRequest) SecurityAttributes(org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes) Test(org.junit.Test)

Aggregations

SecurityAttributes (org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes)7 Test (org.junit.Test)6 Metacard (ddf.catalog.data.Metacard)4 CreateRequest (ddf.catalog.operation.CreateRequest)4 HashMap (java.util.HashMap)2 Matchers.anyString (org.mockito.Matchers.anyString)2 MetacardType (ddf.catalog.data.MetacardType)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)1 AssociationsAttributes (ddf.catalog.data.impl.types.AssociationsAttributes)1 ContactAttributes (ddf.catalog.data.impl.types.ContactAttributes)1 DateTimeAttributes (ddf.catalog.data.impl.types.DateTimeAttributes)1 LocationAttributes (ddf.catalog.data.impl.types.LocationAttributes)1 DeleteRequest (ddf.catalog.operation.DeleteRequest)1 UpdateRequest (ddf.catalog.operation.UpdateRequest)1 ArrayList (java.util.ArrayList)1 GregorianCalendar (java.util.GregorianCalendar)1 IsrAttributes (org.codice.alliance.catalog.core.api.impl.types.IsrAttributes)1 ResultDAGConverter (org.codice.alliance.nsili.common.ResultDAGConverter)1 Before (org.junit.Before)1