Search in sources :

Example 16 with LogAuditLogParams

use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.

the class ContentServiceImplTest_media method audit_data.

@Test
public void audit_data() throws Exception {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final CreateMediaParams createMediaParams = new CreateMediaParams();
    createMediaParams.byteSource(loadImage("cat-small.jpg")).name("Small cat").parent(ContentPath.ROOT);
    final Content content = this.contentService.create(createMediaParams);
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(1)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    assertEquals(content.getId().toString(), logResultSet.getString("id"));
    assertEquals(content.getPath().toString(), logResultSet.getString("path"));
}
Also used : CreateMediaParams(com.enonic.xp.content.CreateMediaParams) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) Content(com.enonic.xp.content.Content) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 17 with LogAuditLogParams

use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.

the class ContentServiceImplTest_publish method audit_data.

@Test
public void audit_data() throws Exception {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").name("myContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final PublishContentResult push = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).build());
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(2)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    assertEquals(content.getId().toString(), logResultSet.getStrings("pushedContents").iterator().next());
    assertFalse(logResultSet.getStrings("deletedContents").iterator().hasNext());
    assertFalse(logResultSet.getStrings("pendingContents").iterator().hasNext());
}
Also used : PublishContentResult(com.enonic.xp.content.PublishContentResult) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 18 with LogAuditLogParams

use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.

the class ContentServiceImplTest_undoPendingDelete method audit_data.

@Test
public void audit_data() {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final Content content = this.createTestContent("myContent");
    int result = resurrect(ContentIds.from(ContentIds.from(content.getId())));
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(3)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    assertEquals(content.getId().toString(), logResultSet.getString("id"));
    assertEquals(content.getPath().toString(), logResultSet.getString("path"));
}
Also used : LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) Content(com.enonic.xp.content.Content) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 19 with LogAuditLogParams

use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.

the class ContentServiceImplTest_update method audit_data.

@Test
public void audit_data() {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final PropertyTree data = new PropertyTree();
    data.setString("testString", "value");
    data.setString("testString2", "value");
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(data).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final UpdateContentParams updateContentParams = new UpdateContentParams();
    updateContentParams.contentId(content.getId()).editor(edit -> {
        final PropertyTree editData = edit.data;
        editData.setString("testString", "value-updated");
    });
    this.contentService.update(updateContentParams);
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(2)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    assertEquals(content.getId().toString(), logResultSet.getString("id"));
    assertEquals(content.getPath().toString(), logResultSet.getString("path"));
}
Also used : UpdateContentParams(com.enonic.xp.content.UpdateContentParams) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 20 with LogAuditLogParams

use of com.enonic.xp.audit.LogAuditLogParams in project xp by enonic.

the class ContentServiceImplTest_move method audit_data.

@Test
public void audit_data() throws Exception {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final Content site = createContent(ContentPath.ROOT, "site");
    final Content child1 = createContent(site.getPath(), "child1");
    final MoveContentParams params = MoveContentParams.create().contentId(child1.getId()).parentContentPath(ContentPath.ROOT).build();
    final MoveContentsResult result = this.contentService.move(params);
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(3)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    assertEquals(child1.getId().toString(), logResultSet.getStrings("movedContents").iterator().next());
}
Also used : MoveContentParams(com.enonic.xp.content.MoveContentParams) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) Content(com.enonic.xp.content.Content) MoveContentsResult(com.enonic.xp.content.MoveContentsResult) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Aggregations

LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)22 Test (org.junit.jupiter.api.Test)20 Content (com.enonic.xp.content.Content)12 PropertyTree (com.enonic.xp.data.PropertyTree)12 PropertySet (com.enonic.xp.data.PropertySet)10 Context (com.enonic.xp.context.Context)8 CreateContentParams (com.enonic.xp.content.CreateContentParams)7 PrincipalKey (com.enonic.xp.security.PrincipalKey)6 User (com.enonic.xp.security.User)5 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)5 AuditLog (com.enonic.xp.audit.AuditLog)3 FindAuditLogResult (com.enonic.xp.audit.FindAuditLogResult)3 ContextBuilder (com.enonic.xp.context.ContextBuilder)3 CronCalendarImpl (com.enonic.xp.impl.scheduler.distributed.CronCalendarImpl)3 DescriptorKey (com.enonic.xp.page.DescriptorKey)3 CreateScheduledJobParams (com.enonic.xp.scheduler.CreateScheduledJobParams)3 ScheduledJob (com.enonic.xp.scheduler.ScheduledJob)3 IdProviderKey (com.enonic.xp.security.IdProviderKey)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)3