Search in sources :

Example 1 with ActorBase

use of com.sequenceiq.cloudbreak.audit.model.ActorBase in project cloudbreak by hortonworks.

the class AuditEventToGrpcAuditEventConverterTest method convertNoEventData.

@Test
void convertNoEventData() {
    ActorBase actor = ActorService.builder().withActorServiceName(ACTOR_SERVICE_NAME).build();
    AuditEvent source = makeAuditEvent(actor, null);
    underTest.convert(source);
    assertGeneric();
}
Also used : ActorBase(com.sequenceiq.cloudbreak.audit.model.ActorBase) AuditEvent(com.sequenceiq.cloudbreak.audit.model.AuditEvent) Test(org.junit.jupiter.api.Test)

Example 2 with ActorBase

use of com.sequenceiq.cloudbreak.audit.model.ActorBase in project cloudbreak by hortonworks.

the class AuditEventToGrpcAuditEventConverterTest method testWhenResultEventDataIsNullThenNoUtilizerCallHappens.

@Test
void testWhenResultEventDataIsNullThenNoUtilizerCallHappens() {
    ActorBase actor = ActorCrn.builder().withActorCrn(USER_CRN).build();
    AuditEvent source = makeMinimalAuditEvent(actor, null);
    underTest.convert(source);
    verify(mockAuditEventBuilderUpdater, never()).update(any(), any());
}
Also used : ActorBase(com.sequenceiq.cloudbreak.audit.model.ActorBase) AuditEvent(com.sequenceiq.cloudbreak.audit.model.AuditEvent) Test(org.junit.jupiter.api.Test)

Example 3 with ActorBase

use of com.sequenceiq.cloudbreak.audit.model.ActorBase in project cloudbreak by hortonworks.

the class AuditEventToGrpcAuditEventConverterTest method convertUnknownActorThrows.

@Test
void convertUnknownActorThrows() {
    class Unknown extends ActorBase {
    }
    AuditEvent source = makeAuditEvent(new Unknown(), null);
    assertThatThrownBy(() -> underTest.convert(source)).isInstanceOf(IllegalArgumentException.class);
}
Also used : ActorBase(com.sequenceiq.cloudbreak.audit.model.ActorBase) AuditEvent(com.sequenceiq.cloudbreak.audit.model.AuditEvent) Test(org.junit.jupiter.api.Test)

Example 4 with ActorBase

use of com.sequenceiq.cloudbreak.audit.model.ActorBase in project cloudbreak by hortonworks.

the class AuditEventToGrpcAuditEventConverterTest method convertWithApiRequestData.

@Test
void convertWithApiRequestData() {
    ActorBase actor = ActorCrn.builder().withActorCrn(USER_CRN).build();
    EventData eventData = ApiRequestData.builder().withApiVersion(API_VERSION).withMutating(MUTATING).withRequestParameters(REQUEST_PARAMETERS).withUserAgent(USER_AGENT).build();
    AuditEvent source = makeAuditEvent(actor, eventData);
    underTest = new AuditEventToGrpcAuditEventConverter(createMockUtilizer(ApiRequestData.class), mockBuilderProvider);
    underTest.convert(source);
    assertGeneric();
    verify(mockAuditEventBuilderUpdater, times(1)).update(any(), any());
}
Also used : ActorBase(com.sequenceiq.cloudbreak.audit.model.ActorBase) AuditEvent(com.sequenceiq.cloudbreak.audit.model.AuditEvent) ServiceEventData(com.sequenceiq.cloudbreak.audit.model.ServiceEventData) EventData(com.sequenceiq.cloudbreak.audit.model.EventData) Test(org.junit.jupiter.api.Test)

Example 5 with ActorBase

use of com.sequenceiq.cloudbreak.audit.model.ActorBase in project cloudbreak by hortonworks.

the class AuditEventToGrpcAuditEventConverterTest method convertUnknownEventDataThrows.

@Test
void convertUnknownEventDataThrows() {
    ActorBase actor = ActorCrn.builder().withActorCrn(USER_CRN).build();
    class Unknown extends EventData {
    }
    AuditEvent source = makeAuditEvent(actor, new Unknown());
    assertThatThrownBy(() -> underTest.convert(source)).isInstanceOf(IllegalArgumentException.class);
}
Also used : ActorBase(com.sequenceiq.cloudbreak.audit.model.ActorBase) AuditEvent(com.sequenceiq.cloudbreak.audit.model.AuditEvent) ServiceEventData(com.sequenceiq.cloudbreak.audit.model.ServiceEventData) EventData(com.sequenceiq.cloudbreak.audit.model.EventData) Test(org.junit.jupiter.api.Test)

Aggregations

ActorBase (com.sequenceiq.cloudbreak.audit.model.ActorBase)9 AuditEvent (com.sequenceiq.cloudbreak.audit.model.AuditEvent)9 Test (org.junit.jupiter.api.Test)9 EventData (com.sequenceiq.cloudbreak.audit.model.EventData)5 ServiceEventData (com.sequenceiq.cloudbreak.audit.model.ServiceEventData)5