Search in sources :

Example 1 with AuditLogService

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

the class ScheduleAuditLogSupportImplTest method testUpdateContent.

@Test
public void testUpdateContent() throws Exception {
    final PropertyTree config = new PropertyTree();
    config.addString("property", "value");
    final CronCalendarImpl calendar = CronCalendarImpl.create().value("* * * * *").timeZone(TimeZone.getTimeZone("GMT+5:30")).build();
    final DescriptorKey descriptor = DescriptorKey.from("appKey:descriptorName");
    final String jobDescription = "Job description";
    final PrincipalKey userKey = PrincipalKey.from("user:system:user");
    final OneTimeCalendarImpl oneTimeCalendar = OneTimeCalendarImpl.create().value(Instant.parse("2021-04-25T10:44:33.170079900Z")).build();
    final ModifyScheduledJobParams params = ModifyScheduledJobParams.create().name(name).editor(edit -> edit.calendar = oneTimeCalendar).build();
    final ScheduledJob job = ScheduledJob.create().name(name).calendar(oneTimeCalendar).descriptor(descriptor).description(jobDescription).config(config).enabled(true).user(userKey).creator(PrincipalKey.from("user:system:creator")).modifier(PrincipalKey.from("user:system:creator")).createdTime(Instant.parse("2021-02-25T10:44:33.170079900Z")).modifiedTime(Instant.parse("2021-02-25T10:44:33.170079900Z")).build();
    context.runWith(() -> support.modify(params, job));
    executor.shutdown();
    executor.awaitTermination(1, TimeUnit.MINUTES);
    final ArgumentCaptor<LogAuditLogParams> argumentCaptor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    verify(auditLogService, times(1)).log(argumentCaptor.capture());
    assertEquals(user.getKey().toString(), argumentCaptor.getValue().getData().getSet("params").getString("modifier"));
    assertEquals("2021-04-25T10:44:33.170079900Z", argumentCaptor.getValue().getData().getSet("result").getSet("calendar").getString("value"));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ModifyScheduledJobParams(com.enonic.xp.scheduler.ModifyScheduledJobParams) IdProviderKey(com.enonic.xp.security.IdProviderKey) Mock(org.mockito.Mock) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ArgumentCaptor(org.mockito.ArgumentCaptor) ScheduledJob(com.enonic.xp.scheduler.ScheduledJob) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) OneTimeCalendarImpl(com.enonic.xp.impl.scheduler.distributed.OneTimeCalendarImpl) AuditLogService(com.enonic.xp.audit.AuditLogService) ContextBuilder(com.enonic.xp.context.ContextBuilder) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ExecutorService(java.util.concurrent.ExecutorService) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) PropertyTree(com.enonic.xp.data.PropertyTree) CronCalendarImpl(com.enonic.xp.impl.scheduler.distributed.CronCalendarImpl) User(com.enonic.xp.security.User) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) TimeZone(java.util.TimeZone) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) Mockito.times(org.mockito.Mockito.times) Instant(java.time.Instant) Executors(java.util.concurrent.Executors) TaskId(com.enonic.xp.task.TaskId) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) Mockito.never(org.mockito.Mockito.never) PrincipalKey(com.enonic.xp.security.PrincipalKey) DescriptorKey(com.enonic.xp.page.DescriptorKey) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ScheduledJobName(com.enonic.xp.scheduler.ScheduledJobName) Context(com.enonic.xp.context.Context) CreateScheduledJobParams(com.enonic.xp.scheduler.CreateScheduledJobParams) OneTimeCalendarImpl(com.enonic.xp.impl.scheduler.distributed.OneTimeCalendarImpl) ModifyScheduledJobParams(com.enonic.xp.scheduler.ModifyScheduledJobParams) CronCalendarImpl(com.enonic.xp.impl.scheduler.distributed.CronCalendarImpl) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) PropertyTree(com.enonic.xp.data.PropertyTree) ScheduledJob(com.enonic.xp.scheduler.ScheduledJob) DescriptorKey(com.enonic.xp.page.DescriptorKey) PrincipalKey(com.enonic.xp.security.PrincipalKey) Test(org.junit.jupiter.api.Test)

Example 2 with AuditLogService

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

the class ScheduleAuditLogSupportImplTest method testUpdateWithoutCreator.

@Test
public // jobs were produced with an empty `creator` and `createdTime` fields from 7.7.0 to 7.7.2
void testUpdateWithoutCreator() throws Exception {
    final PropertyTree config = new PropertyTree();
    config.addString("property", "value");
    final CronCalendarImpl calendar = CronCalendarImpl.create().value("* * * * *").timeZone(TimeZone.getTimeZone("GMT+5:30")).build();
    final DescriptorKey descriptor = DescriptorKey.from("appKey:descriptorName");
    final String jobDescription = "Job description";
    final PrincipalKey userKey = PrincipalKey.from("user:system:user");
    final OneTimeCalendarImpl oneTimeCalendar = OneTimeCalendarImpl.create().value(Instant.parse("2021-04-25T10:44:33.170079900Z")).build();
    final ModifyScheduledJobParams params = ModifyScheduledJobParams.create().name(name).editor(edit -> edit.calendar = oneTimeCalendar).build();
    final ScheduledJob job = ScheduledJob.create().name(name).calendar(oneTimeCalendar).descriptor(descriptor).description(jobDescription).config(config).enabled(true).user(userKey).modifier(PrincipalKey.from("user:system:creator")).createdTime(Instant.parse("2021-02-25T10:44:33.170079900Z")).modifiedTime(Instant.parse("2021-02-25T10:44:33.170079900Z")).build();
    context.runWith(() -> support.modify(params, job));
    executor.shutdown();
    executor.awaitTermination(1, TimeUnit.MINUTES);
    final ArgumentCaptor<LogAuditLogParams> argumentCaptor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    verify(auditLogService, times(1)).log(argumentCaptor.capture());
    assertNull(argumentCaptor.getValue().getData().getSet("params").getString("creator"));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ModifyScheduledJobParams(com.enonic.xp.scheduler.ModifyScheduledJobParams) IdProviderKey(com.enonic.xp.security.IdProviderKey) Mock(org.mockito.Mock) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ArgumentCaptor(org.mockito.ArgumentCaptor) ScheduledJob(com.enonic.xp.scheduler.ScheduledJob) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) OneTimeCalendarImpl(com.enonic.xp.impl.scheduler.distributed.OneTimeCalendarImpl) AuditLogService(com.enonic.xp.audit.AuditLogService) ContextBuilder(com.enonic.xp.context.ContextBuilder) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ExecutorService(java.util.concurrent.ExecutorService) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) PropertyTree(com.enonic.xp.data.PropertyTree) CronCalendarImpl(com.enonic.xp.impl.scheduler.distributed.CronCalendarImpl) User(com.enonic.xp.security.User) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) TimeZone(java.util.TimeZone) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) Mockito.times(org.mockito.Mockito.times) Instant(java.time.Instant) Executors(java.util.concurrent.Executors) TaskId(com.enonic.xp.task.TaskId) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) Mockito.never(org.mockito.Mockito.never) PrincipalKey(com.enonic.xp.security.PrincipalKey) DescriptorKey(com.enonic.xp.page.DescriptorKey) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ScheduledJobName(com.enonic.xp.scheduler.ScheduledJobName) Context(com.enonic.xp.context.Context) CreateScheduledJobParams(com.enonic.xp.scheduler.CreateScheduledJobParams) OneTimeCalendarImpl(com.enonic.xp.impl.scheduler.distributed.OneTimeCalendarImpl) ModifyScheduledJobParams(com.enonic.xp.scheduler.ModifyScheduledJobParams) CronCalendarImpl(com.enonic.xp.impl.scheduler.distributed.CronCalendarImpl) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) PropertyTree(com.enonic.xp.data.PropertyTree) ScheduledJob(com.enonic.xp.scheduler.ScheduledJob) DescriptorKey(com.enonic.xp.page.DescriptorKey) PrincipalKey(com.enonic.xp.security.PrincipalKey) Test(org.junit.jupiter.api.Test)

Example 3 with AuditLogService

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

the class SchedulerServiceImplTest method setUpNode.

@BeforeEach
protected void setUpNode() throws Exception {
    super.setUpNode();
    final AuditLogService auditLogService = Mockito.mock(AuditLogService.class);
    final SchedulerConfig schedulerConfig = Mockito.mock(SchedulerConfig.class);
    Mockito.when(schedulerConfig.auditlogEnabled()).thenReturn(Boolean.TRUE);
    final ScheduleAuditLogSupportImpl auditLogSupport = new ScheduleAuditLogSupportImpl(schedulerConfig, new ScheduleAuditLogExecutorImpl(), auditLogService);
    schedulerService = new SchedulerServiceImpl(indexService, repositoryService, nodeService, schedulerExecutorService, auditLogSupport);
    adminContext().runWith(() -> schedulerService.initialize());
    calendarService = new CalendarServiceImpl();
}
Also used : ScheduleAuditLogExecutorImpl(com.enonic.xp.impl.scheduler.ScheduleAuditLogExecutorImpl) AuditLogService(com.enonic.xp.audit.AuditLogService) SchedulerServiceImpl(com.enonic.xp.impl.scheduler.SchedulerServiceImpl) CalendarServiceImpl(com.enonic.xp.impl.scheduler.CalendarServiceImpl) ScheduleAuditLogSupportImpl(com.enonic.xp.impl.scheduler.ScheduleAuditLogSupportImpl) SchedulerConfig(com.enonic.xp.impl.scheduler.SchedulerConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with AuditLogService

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

the class AbstractContentServiceTest method setUpAbstractContentServiceTest.

@BeforeEach
public void setUpAbstractContentServiceTest() {
    executorService = Executors.newSingleThreadExecutor();
    deleteAllIndices();
    ContextAccessor.INSTANCE.set(ctxDefault());
    final MemoryBlobStore blobStore = new MemoryBlobStore();
    binaryService = new BinaryServiceImpl();
    binaryService.setBlobStore(blobStore);
    final StorageDaoImpl storageDao = new StorageDaoImpl();
    storageDao.setClient(client);
    final EventPublisherImpl eventPublisher = new EventPublisherImpl(executorService);
    SearchDaoImpl searchDao = new SearchDaoImpl();
    searchDao.setClient(client);
    BranchServiceImpl branchService = new BranchServiceImpl();
    branchService.setStorageDao(storageDao);
    branchService.setSearchDao(searchDao);
    VersionServiceImpl versionService = new VersionServiceImpl();
    versionService.setStorageDao(storageDao);
    CommitServiceImpl commitService = new CommitServiceImpl();
    commitService.setStorageDao(storageDao);
    IndexServiceInternalImpl indexServiceInternal = new IndexServiceInternalImpl();
    indexServiceInternal.setClient(client);
    indexService = new IndexServiceImpl();
    indexService.setIndexServiceInternal(indexServiceInternal);
    NodeVersionServiceImpl nodeDao = new NodeVersionServiceImpl();
    nodeDao.setBlobStore(blobStore);
    IndexDataServiceImpl indexedDataService = new IndexDataServiceImpl();
    indexedDataService.setStorageDao(storageDao);
    NodeStorageServiceImpl storageService = new NodeStorageServiceImpl();
    storageService.setBranchService(branchService);
    storageService.setVersionService(versionService);
    storageService.setCommitService(commitService);
    storageService.setNodeVersionService(nodeDao);
    storageService.setIndexDataService(indexedDataService);
    NodeSearchServiceImpl searchService = new NodeSearchServiceImpl();
    searchService.setSearchDao(searchDao);
    final NodeRepositoryServiceImpl nodeRepositoryService = new NodeRepositoryServiceImpl();
    nodeRepositoryService.setIndexServiceInternal(indexServiceInternal);
    final IndexServiceInternalImpl elasticsearchIndexService = new IndexServiceInternalImpl();
    elasticsearchIndexService.setClient(client);
    final RepositoryEntryServiceImpl repositoryEntryService = new RepositoryEntryServiceImpl();
    repositoryEntryService.setIndexServiceInternal(elasticsearchIndexService);
    repositoryEntryService.setNodeStorageService(storageService);
    repositoryEntryService.setNodeSearchService(searchService);
    repositoryEntryService.setEventPublisher(eventPublisher);
    repositoryEntryService.setBinaryService(binaryService);
    repositoryService = new RepositoryServiceImpl(repositoryEntryService, elasticsearchIndexService, nodeRepositoryService, storageService, searchService);
    repositoryService.initialize();
    nodeService = new NodeServiceImpl();
    nodeService.setIndexServiceInternal(indexServiceInternal);
    nodeService.setNodeStorageService(storageService);
    nodeService.setNodeSearchService(searchService);
    nodeService.setEventPublisher(eventPublisher);
    nodeService.setBinaryService(binaryService);
    nodeService.setRepositoryService(repositoryService);
    nodeService.initialize();
    mixinService = Mockito.mock(MixinService.class);
    Mockito.when(mixinService.inlineFormItems(Mockito.isA(Form.class))).then(AdditionalAnswers.returnsFirstArg());
    xDataService = Mockito.mock(XDataService.class);
    Map<String, List<String>> metadata = new HashMap<>();
    metadata.put(HttpHeaders.CONTENT_TYPE, List.of("image/jpg"));
    final ExtractedData extractedData = ExtractedData.create().metadata(metadata).build();
    final BinaryExtractor extractor = Mockito.mock(BinaryExtractor.class);
    Mockito.when(extractor.extract(Mockito.isA(ByteSource.class))).thenReturn(extractedData);
    mediaInfoService = new MediaInfoServiceImpl();
    mediaInfoService.setBinaryExtractor(extractor);
    final ResourceService resourceService = Mockito.mock(ResourceService.class);
    final SiteServiceImpl siteService = new SiteServiceImpl();
    siteService.setResourceService(resourceService);
    siteService.setMixinService(mixinService);
    contentTypeService = new ContentTypeServiceImpl(null, null, mixinService);
    PageDescriptorService pageDescriptorService = Mockito.mock(PageDescriptorService.class);
    PartDescriptorService partDescriptorService = Mockito.mock(PartDescriptorService.class);
    LayoutDescriptorService layoutDescriptorService = Mockito.mock(LayoutDescriptorService.class);
    auditLogService = Mockito.mock(AuditLogService.class);
    final ContentConfig contentConfig = Mockito.mock(ContentConfig.class);
    Mockito.when(contentConfig.auditlog_enabled()).thenReturn(Boolean.TRUE);
    final ContentAuditLogSupportImpl contentAuditLogSupport = new ContentAuditLogSupportImpl(contentConfig, new ContentAuditLogExecutorImpl(), auditLogService);
    final SecurityServiceImpl securityService = new SecurityServiceImpl(nodeService, indexService);
    securityService.initialize();
    final ProjectPermissionsContextManagerImpl projectAccessContextManager = new ProjectPermissionsContextManagerImpl();
    final ProjectServiceImpl projectService = new ProjectServiceImpl(repositoryService, indexService, nodeService, securityService, projectAccessContextManager, eventPublisher);
    projectService.initialize();
    contentService = new ContentServiceImpl(nodeService, pageDescriptorService, partDescriptorService, layoutDescriptorService);
    contentService.setEventPublisher(eventPublisher);
    contentService.setMediaInfoService(mediaInfoService);
    contentService.setSiteService(siteService);
    contentService.setContentTypeService(contentTypeService);
    contentService.setxDataService(xDataService);
    contentService.setFormDefaultValuesProcessor((form, data) -> {
    });
    contentService.setContentAuditLogSupport(contentAuditLogSupport);
    contentService.addContentValidator(new ContentNameValidator());
    contentService.addContentValidator(new SiteConfigsValidator(siteService));
    contentService.addContentValidator(new OccurrenceValidator());
    contentService.addContentValidator(new ExtraDataValidator(xDataService));
    contentService.initialize(mock(ContentConfig.class, invocation -> invocation.getMethod().getDefaultValue()));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) IndexServiceInternalImpl(com.enonic.xp.repo.impl.elasticsearch.IndexServiceInternalImpl) AbstractElasticsearchIntegrationTest(com.enonic.xp.repo.impl.elasticsearch.AbstractElasticsearchIntegrationTest) NodeRepositoryServiceImpl(com.enonic.xp.repo.impl.repository.NodeRepositoryServiceImpl) RepositoryId(com.enonic.xp.repository.RepositoryId) HttpHeaders(com.google.common.net.HttpHeaders) ContextAccessor(com.enonic.xp.context.ContextAccessor) Map(java.util.Map) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) IndexServiceImpl(com.enonic.xp.repo.impl.index.IndexServiceImpl) ExtraDataValidator(com.enonic.xp.core.impl.content.validate.ExtraDataValidator) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) ExtraDatas(com.enonic.xp.content.ExtraDatas) Executors(java.util.concurrent.Executors) InputTypeName(com.enonic.xp.inputtype.InputTypeName) VersionServiceImpl(com.enonic.xp.repo.impl.version.VersionServiceImpl) NodeStorageServiceImpl(com.enonic.xp.repo.impl.storage.NodeStorageServiceImpl) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BinaryServiceImpl(com.enonic.xp.repo.impl.binary.BinaryServiceImpl) RoleKeys(com.enonic.xp.security.RoleKeys) ContentAuditLogSupportImpl(com.enonic.xp.core.impl.content.ContentAuditLogSupportImpl) Mockito.mock(org.mockito.Mockito.mock) SecurityServiceImpl(com.enonic.xp.core.impl.security.SecurityServiceImpl) ContentConstants(com.enonic.xp.content.ContentConstants) LocalDateTime(java.time.LocalDateTime) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) ContentNameValidator(com.enonic.xp.core.impl.content.validate.ContentNameValidator) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) FormItemSet(com.enonic.xp.form.FormItemSet) NodeServiceImpl(com.enonic.xp.repo.impl.node.NodeServiceImpl) InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty) MediaInfoServiceImpl(com.enonic.xp.core.impl.media.MediaInfoServiceImpl) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) GeoPoint(com.enonic.xp.util.GeoPoint) OccurrenceValidator(com.enonic.xp.core.impl.content.validate.OccurrenceValidator) ContentTypeServiceImpl(com.enonic.xp.core.impl.schema.content.ContentTypeServiceImpl) RelationshipTypeName(com.enonic.xp.schema.relationship.RelationshipTypeName) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) RepositoryEntryServiceImpl(com.enonic.xp.repo.impl.repository.RepositoryEntryServiceImpl) ResourceService(com.enonic.xp.resource.ResourceService) ContentPath(com.enonic.xp.content.ContentPath) PropertySet(com.enonic.xp.data.PropertySet) Content(com.enonic.xp.content.Content) IOException(java.io.IOException) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) AfterEach(org.junit.jupiter.api.AfterEach) ExtractedData(com.enonic.xp.extractor.ExtractedData) ContentIds(com.enonic.xp.content.ContentIds) ContentConfig(com.enonic.xp.core.impl.content.ContentConfig) MemoryBlobStore(com.enonic.xp.internal.blobstore.MemoryBlobStore) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) IdProviderKey(com.enonic.xp.security.IdProviderKey) Branch(com.enonic.xp.branch.Branch) IndexDataServiceImpl(com.enonic.xp.repo.impl.storage.IndexDataServiceImpl) CommitServiceImpl(com.enonic.xp.repo.impl.commit.CommitServiceImpl) ContentId(com.enonic.xp.content.ContentId) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) LocalTime(java.time.LocalTime) ContextBuilder(com.enonic.xp.context.ContextBuilder) StorageDaoImpl(com.enonic.xp.repo.impl.elasticsearch.storage.StorageDaoImpl) ProjectPermissionsContextManagerImpl(com.enonic.xp.core.impl.project.ProjectPermissionsContextManagerImpl) User(com.enonic.xp.security.User) ContentServiceImpl(com.enonic.xp.core.impl.content.ContentServiceImpl) UUID(java.util.UUID) Instant(java.time.Instant) ContentType(com.enonic.xp.schema.content.ContentType) AccessControlList(com.enonic.xp.security.acl.AccessControlList) AdditionalAnswers(org.mockito.AdditionalAnswers) BinaryExtractor(com.enonic.xp.extractor.BinaryExtractor) SearchDaoImpl(com.enonic.xp.repo.impl.elasticsearch.search.SearchDaoImpl) List(java.util.List) LocalDate(java.time.LocalDate) NodeSearchServiceImpl(com.enonic.xp.repo.impl.search.NodeSearchServiceImpl) FindContentByQueryResult(com.enonic.xp.content.FindContentByQueryResult) Context(com.enonic.xp.context.Context) ProjectServiceImpl(com.enonic.xp.core.impl.project.ProjectServiceImpl) MixinService(com.enonic.xp.schema.mixin.MixinService) ContentAuditLogExecutorImpl(com.enonic.xp.core.impl.content.ContentAuditLogExecutorImpl) SiteServiceImpl(com.enonic.xp.core.impl.site.SiteServiceImpl) CreateContentParams(com.enonic.xp.content.CreateContentParams) HashMap(java.util.HashMap) RepositoryServiceImpl(com.enonic.xp.repo.impl.repository.RepositoryServiceImpl) ContentVersion(com.enonic.xp.content.ContentVersion) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) FindContentVersionsParams(com.enonic.xp.content.FindContentVersionsParams) ContentInitializer(com.enonic.xp.core.impl.project.init.ContentInitializer) AuditLogService(com.enonic.xp.audit.AuditLogService) ExecutorService(java.util.concurrent.ExecutorService) XDataService(com.enonic.xp.schema.xdata.XDataService) PropertyTree(com.enonic.xp.data.PropertyTree) PartDescriptorService(com.enonic.xp.region.PartDescriptorService) Iterator(java.util.Iterator) EventPublisherImpl(com.enonic.xp.core.impl.event.EventPublisherImpl) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) Form(com.enonic.xp.form.Form) Mockito(org.mockito.Mockito) NodeVersionServiceImpl(com.enonic.xp.repo.impl.node.dao.NodeVersionServiceImpl) PrincipalKey(com.enonic.xp.security.PrincipalKey) Reference(com.enonic.xp.util.Reference) SiteConfigsValidator(com.enonic.xp.core.impl.content.validate.SiteConfigsValidator) Input(com.enonic.xp.form.Input) BranchServiceImpl(com.enonic.xp.repo.impl.branch.storage.BranchServiceImpl) InputStream(java.io.InputStream) VersionServiceImpl(com.enonic.xp.repo.impl.version.VersionServiceImpl) NodeVersionServiceImpl(com.enonic.xp.repo.impl.node.dao.NodeVersionServiceImpl) EventPublisherImpl(com.enonic.xp.core.impl.event.EventPublisherImpl) ContentAuditLogExecutorImpl(com.enonic.xp.core.impl.content.ContentAuditLogExecutorImpl) Form(com.enonic.xp.form.Form) HashMap(java.util.HashMap) XDataService(com.enonic.xp.schema.xdata.XDataService) ResourceService(com.enonic.xp.resource.ResourceService) NodeRepositoryServiceImpl(com.enonic.xp.repo.impl.repository.NodeRepositoryServiceImpl) RepositoryServiceImpl(com.enonic.xp.repo.impl.repository.RepositoryServiceImpl) SiteServiceImpl(com.enonic.xp.core.impl.site.SiteServiceImpl) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) IndexServiceImpl(com.enonic.xp.repo.impl.index.IndexServiceImpl) NodeServiceImpl(com.enonic.xp.repo.impl.node.NodeServiceImpl) ProjectServiceImpl(com.enonic.xp.core.impl.project.ProjectServiceImpl) BinaryExtractor(com.enonic.xp.extractor.BinaryExtractor) RepositoryEntryServiceImpl(com.enonic.xp.repo.impl.repository.RepositoryEntryServiceImpl) IndexServiceInternalImpl(com.enonic.xp.repo.impl.elasticsearch.IndexServiceInternalImpl) AccessControlList(com.enonic.xp.security.acl.AccessControlList) List(java.util.List) SiteConfigsValidator(com.enonic.xp.core.impl.content.validate.SiteConfigsValidator) NodeSearchServiceImpl(com.enonic.xp.repo.impl.search.NodeSearchServiceImpl) ExtraDataValidator(com.enonic.xp.core.impl.content.validate.ExtraDataValidator) BinaryServiceImpl(com.enonic.xp.repo.impl.binary.BinaryServiceImpl) PartDescriptorService(com.enonic.xp.region.PartDescriptorService) SearchDaoImpl(com.enonic.xp.repo.impl.elasticsearch.search.SearchDaoImpl) CommitServiceImpl(com.enonic.xp.repo.impl.commit.CommitServiceImpl) NodeVersionServiceImpl(com.enonic.xp.repo.impl.node.dao.NodeVersionServiceImpl) NodeRepositoryServiceImpl(com.enonic.xp.repo.impl.repository.NodeRepositoryServiceImpl) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) AuditLogService(com.enonic.xp.audit.AuditLogService) MediaInfoServiceImpl(com.enonic.xp.core.impl.media.MediaInfoServiceImpl) ContentTypeServiceImpl(com.enonic.xp.core.impl.schema.content.ContentTypeServiceImpl) IndexDataServiceImpl(com.enonic.xp.repo.impl.storage.IndexDataServiceImpl) BranchServiceImpl(com.enonic.xp.repo.impl.branch.storage.BranchServiceImpl) SecurityServiceImpl(com.enonic.xp.core.impl.security.SecurityServiceImpl) MixinService(com.enonic.xp.schema.mixin.MixinService) ContentConfig(com.enonic.xp.core.impl.content.ContentConfig) ExtractedData(com.enonic.xp.extractor.ExtractedData) OccurrenceValidator(com.enonic.xp.core.impl.content.validate.OccurrenceValidator) StorageDaoImpl(com.enonic.xp.repo.impl.elasticsearch.storage.StorageDaoImpl) ContentAuditLogSupportImpl(com.enonic.xp.core.impl.content.ContentAuditLogSupportImpl) ContentServiceImpl(com.enonic.xp.core.impl.content.ContentServiceImpl) ContentNameValidator(com.enonic.xp.core.impl.content.validate.ContentNameValidator) ProjectPermissionsContextManagerImpl(com.enonic.xp.core.impl.project.ProjectPermissionsContextManagerImpl) ByteSource(com.google.common.io.ByteSource) NodeStorageServiceImpl(com.enonic.xp.repo.impl.storage.NodeStorageServiceImpl) MemoryBlobStore(com.enonic.xp.internal.blobstore.MemoryBlobStore) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with AuditLogService

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

the class AbstractContentSynchronizerTest method setUpContentService.

private void setUpContentService() {
    final Map<String, List<String>> metadata = new HashMap<>();
    metadata.put(HttpHeaders.CONTENT_TYPE, List.of("image/jpg"));
    final ExtractedData extractedData = ExtractedData.create().metadata(metadata).build();
    final BinaryExtractor extractor = mock(BinaryExtractor.class);
    when(extractor.extract(isA(ByteSource.class))).thenReturn(extractedData);
    mediaInfoService = new MediaInfoServiceImpl();
    mediaInfoService.setBinaryExtractor(extractor);
    XDataService xDataService = mock(XDataService.class);
    MixinService mixinService = mock(MixinService.class);
    when(mixinService.inlineFormItems(isA(Form.class))).then(AdditionalAnswers.returnsFirstArg());
    pageDescriptorService = mock(PageDescriptorService.class);
    partDescriptorService = mock(PartDescriptorService.class);
    layoutDescriptorService = mock(LayoutDescriptorService.class);
    contentTypeService = new ContentTypeServiceImpl(null, null, mixinService);
    final ResourceService resourceService = mock(ResourceService.class);
    final SiteServiceImpl siteService = new SiteServiceImpl();
    siteService.setResourceService(resourceService);
    siteService.setMixinService(mixinService);
    final AuditLogService auditLogService = mock(AuditLogService.class);
    final ContentConfig contentConfig = mock(ContentConfig.class);
    final ContentAuditLogSupportImpl contentAuditLogSupport = new ContentAuditLogSupportImpl(contentConfig, new ContentAuditLogExecutorImpl(), auditLogService);
    contentService = new ContentServiceImpl(nodeService, pageDescriptorService, partDescriptorService, layoutDescriptorService);
    contentService.setEventPublisher(eventPublisher);
    contentService.setMediaInfoService(mediaInfoService);
    contentService.setSiteService(siteService);
    contentService.setContentTypeService(contentTypeService);
    contentService.setxDataService(xDataService);
    contentService.setFormDefaultValuesProcessor((form, data) -> {
    });
    contentService.setContentAuditLogSupport(contentAuditLogSupport);
    contentService.initialize(mock(ContentConfig.class, invocation -> invocation.getMethod().getDefaultValue()));
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) CONTENT_ROOT_PATH_ATTRIBUTE(com.enonic.xp.content.ContentConstants.CONTENT_ROOT_PATH_ATTRIBUTE) IdProviderKey(com.enonic.xp.security.IdProviderKey) TaskServiceImpl(com.enonic.xp.impl.task.TaskServiceImpl) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) HttpHeaders(com.google.common.net.HttpHeaders) ContextAccessor(com.enonic.xp.context.ContextAccessor) Map(java.util.Map) ContextBuilder(com.enonic.xp.context.ContextBuilder) Bundle(org.osgi.framework.Bundle) SystemConstants(com.enonic.xp.security.SystemConstants) EnumSet(java.util.EnumSet) ProjectPermissionsContextManagerImpl(com.enonic.xp.core.impl.project.ProjectPermissionsContextManagerImpl) Media(com.enonic.xp.content.Media) User(com.enonic.xp.security.User) ContentServiceImpl(com.enonic.xp.core.impl.content.ContentServiceImpl) TaskManagerCleanupScheduler(com.enonic.xp.impl.task.TaskManagerCleanupScheduler) Project(com.enonic.xp.project.Project) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) AdditionalAnswers(org.mockito.AdditionalAnswers) BinaryExtractor(com.enonic.xp.extractor.BinaryExtractor) CreateProjectParams(com.enonic.xp.project.CreateProjectParams) List(java.util.List) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ByteStreams(com.google.common.io.ByteStreams) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) ProjectServiceImpl(com.enonic.xp.core.impl.project.ProjectServiceImpl) MixinService(com.enonic.xp.schema.mixin.MixinService) ContentAuditLogExecutorImpl(com.enonic.xp.core.impl.content.ContentAuditLogExecutorImpl) ContentAuditLogSupportImpl(com.enonic.xp.core.impl.content.ContentAuditLogSupportImpl) SiteServiceImpl(com.enonic.xp.core.impl.site.SiteServiceImpl) Mockito.mock(org.mockito.Mockito.mock) CreateContentParams(com.enonic.xp.content.CreateContentParams) SecurityServiceImpl(com.enonic.xp.core.impl.security.SecurityServiceImpl) ContentConstants(com.enonic.xp.content.ContentConstants) RecurringJob(com.enonic.xp.core.internal.concurrent.RecurringJob) HashMap(java.util.HashMap) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) MediaInfoServiceImpl(com.enonic.xp.core.impl.media.MediaInfoServiceImpl) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) ContentTypeServiceImpl(com.enonic.xp.core.impl.schema.content.ContentTypeServiceImpl) ProjectName(com.enonic.xp.project.ProjectName) AuditLogService(com.enonic.xp.audit.AuditLogService) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) XDataService(com.enonic.xp.schema.xdata.XDataService) OsgiSupportMock(com.enonic.xp.core.internal.osgi.OsgiSupportMock) PropertyTree(com.enonic.xp.data.PropertyTree) ArgumentMatchers.isA(org.mockito.ArgumentMatchers.isA) PartDescriptorService(com.enonic.xp.region.PartDescriptorService) ResourceService(com.enonic.xp.resource.ResourceService) ContentPath(com.enonic.xp.content.ContentPath) ContentInheritType(com.enonic.xp.content.ContentInheritType) NodePath(com.enonic.xp.node.NodePath) Content(com.enonic.xp.content.Content) IOException(java.io.IOException) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) LocalTaskManagerImpl(com.enonic.xp.impl.task.LocalTaskManagerImpl) Mockito.when(org.mockito.Mockito.when) Form(com.enonic.xp.form.Form) ExtractedData(com.enonic.xp.extractor.ExtractedData) PrincipalKey(com.enonic.xp.security.PrincipalKey) ContentConfig(com.enonic.xp.core.impl.content.ContentConfig) CreateMediaParams(com.enonic.xp.content.CreateMediaParams) NamedTaskFactory(com.enonic.xp.impl.task.script.NamedTaskFactory) InputStream(java.io.InputStream) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) AuditLogService(com.enonic.xp.audit.AuditLogService) MediaInfoServiceImpl(com.enonic.xp.core.impl.media.MediaInfoServiceImpl) ContentAuditLogExecutorImpl(com.enonic.xp.core.impl.content.ContentAuditLogExecutorImpl) HashMap(java.util.HashMap) Form(com.enonic.xp.form.Form) ContentTypeServiceImpl(com.enonic.xp.core.impl.schema.content.ContentTypeServiceImpl) XDataService(com.enonic.xp.schema.xdata.XDataService) ResourceService(com.enonic.xp.resource.ResourceService) SiteServiceImpl(com.enonic.xp.core.impl.site.SiteServiceImpl) MixinService(com.enonic.xp.schema.mixin.MixinService) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) ContentConfig(com.enonic.xp.core.impl.content.ContentConfig) BinaryExtractor(com.enonic.xp.extractor.BinaryExtractor) ExtractedData(com.enonic.xp.extractor.ExtractedData) ContentAuditLogSupportImpl(com.enonic.xp.core.impl.content.ContentAuditLogSupportImpl) ContentServiceImpl(com.enonic.xp.core.impl.content.ContentServiceImpl) ByteSource(com.google.common.io.ByteSource) List(java.util.List)

Aggregations

AuditLogService (com.enonic.xp.audit.AuditLogService)5 Context (com.enonic.xp.context.Context)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4 PropertyTree (com.enonic.xp.data.PropertyTree)4 IdProviderKey (com.enonic.xp.security.IdProviderKey)4 PrincipalKey (com.enonic.xp.security.PrincipalKey)4 User (com.enonic.xp.security.User)4 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)2 Content (com.enonic.xp.content.Content)2 ContentConstants (com.enonic.xp.content.ContentConstants)2 ContentPath (com.enonic.xp.content.ContentPath)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 ContextAccessor (com.enonic.xp.context.ContextAccessor)2 ContentAuditLogExecutorImpl (com.enonic.xp.core.impl.content.ContentAuditLogExecutorImpl)2 ContentAuditLogSupportImpl (com.enonic.xp.core.impl.content.ContentAuditLogSupportImpl)2 ContentConfig (com.enonic.xp.core.impl.content.ContentConfig)2 ContentServiceImpl (com.enonic.xp.core.impl.content.ContentServiceImpl)2 MediaInfoServiceImpl (com.enonic.xp.core.impl.media.MediaInfoServiceImpl)2