use of com.enonic.xp.core.impl.security.SecurityConfig 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 = mock(MixinService.class);
when(mixinService.inlineFormItems(Mockito.isA(Form.class))).then(AdditionalAnswers.returnsFirstArg());
xDataService = 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 = mock(BinaryExtractor.class);
when(extractor.extract(Mockito.isA(ByteSource.class))).thenReturn(extractedData);
mediaInfoService = new MediaInfoServiceImpl();
mediaInfoService.setBinaryExtractor(extractor);
final ResourceService resourceService = mock(ResourceService.class);
final SiteServiceImpl siteService = new SiteServiceImpl();
siteService.setResourceService(resourceService);
siteService.setMixinService(mixinService);
contentTypeService = new ContentTypeServiceImpl(null, null, mixinService);
PageDescriptorService pageDescriptorService = mock(PageDescriptorService.class);
PartDescriptorService partDescriptorService = mock(PartDescriptorService.class);
LayoutDescriptorService layoutDescriptorService = mock(LayoutDescriptorService.class);
auditLogService = mock(AuditLogService.class);
final ContentConfig contentConfig = mock(ContentConfig.class);
when(contentConfig.auditlog_enabled()).thenReturn(Boolean.TRUE);
final ContentAuditLogSupportImpl contentAuditLogSupport = new ContentAuditLogSupportImpl(contentConfig, new ContentAuditLogExecutorImpl(), auditLogService);
final SecurityConfig securityConfig = mock(SecurityConfig.class);
when(securityConfig.auditlog_enabled()).thenReturn(Boolean.TRUE);
final SecurityAuditLogSupportImpl securityAuditLogSupport = new SecurityAuditLogSupportImpl(auditLogService);
securityAuditLogSupport.activate(securityConfig);
final SecurityServiceImpl securityService = new SecurityServiceImpl(nodeService, indexService, securityAuditLogSupport);
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()));
}
use of com.enonic.xp.core.impl.security.SecurityConfig in project xp by enonic.
the class AbstractContentSynchronizerTest method setUpProjectService.
private void setUpProjectService() {
adminContext().runWith(() -> {
SecurityConfig securityConfig = mock(SecurityConfig.class);
when(securityConfig.auditlog_enabled()).thenReturn(true);
AuditLogService auditLogService = mock(AuditLogService.class);
final SecurityAuditLogSupportImpl securityAuditLogSupport = new SecurityAuditLogSupportImpl(auditLogService);
securityAuditLogSupport.activate(securityConfig);
SecurityServiceImpl securityService = new SecurityServiceImpl(this.nodeService, indexService, securityAuditLogSupport);
securityService.initialize();
projectService = new ProjectServiceImpl(repositoryService, indexService, nodeService, securityService, new ProjectPermissionsContextManagerImpl(), eventPublisher);
sourceProject = projectService.create(CreateProjectParams.create().name(ProjectName.from("source_project")).displayName("Source Project").build());
targetProject = projectService.create(CreateProjectParams.create().name(ProjectName.from("target_project")).displayName("Target Project").parent(sourceProject.getName()).build());
this.targetContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(targetProject.getName().getRepoId()).branch(ContentConstants.BRANCH_DRAFT).authInfo(REPO_TEST_ADMIN_USER_AUTHINFO).build();
this.sourceContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(sourceProject.getName().getRepoId()).branch(ContentConstants.BRANCH_DRAFT).authInfo(REPO_TEST_ADMIN_USER_AUTHINFO).build();
this.targetArchiveContext = ContextBuilder.from(this.targetContext).attribute(CONTENT_ROOT_PATH_ATTRIBUTE, NodePath.create("archive").build()).build();
this.sourceArchiveContext = ContextBuilder.from(this.sourceContext).attribute(CONTENT_ROOT_PATH_ATTRIBUTE, NodePath.create("archive").build()).build();
projectService.initialize();
});
}
use of com.enonic.xp.core.impl.security.SecurityConfig in project xp by enonic.
the class ProjectServiceImplTest method setUpNode.
@BeforeEach
protected void setUpNode() throws Exception {
super.setUpNode();
SecurityConfig securityConfig = mock(SecurityConfig.class);
when(securityConfig.auditlog_enabled()).thenReturn(true);
AuditLogService auditLogService = mock(AuditLogService.class);
SecurityAuditLogSupportImpl securityAuditLogSupport = new SecurityAuditLogSupportImpl(auditLogService);
securityAuditLogSupport.activate(securityConfig);
securityService = new SecurityServiceImpl(this.nodeService, indexService, securityAuditLogSupport);
adminContext().runWith(() -> {
securityService.initialize();
final ProjectPermissionsContextManagerImpl projectAccessContextManager = new ProjectPermissionsContextManagerImpl();
projectService = new ProjectServiceImpl(repositoryService, indexService, nodeService, securityService, projectAccessContextManager, eventPublisher);
projectService.initialize();
});
}
Aggregations