Search in sources :

Example 6 with Projects

use of com.enonic.xp.project.Projects in project xp by enonic.

the class ProjectServiceImplTest method initialize.

@Test
void initialize() {
    ContextBuilder.from(adminContext()).repositoryId(ContentConstants.CONTENT_REPO_ID).branch(ContentConstants.BRANCH_DRAFT).build().runWith(() -> {
        final Projects projects = projectService.list();
        assertEquals(1, projects.getSize());
        assertTrue(nodeService.nodeExists(NodePath.create().addElement("content").build()));
        assertTrue(nodeService.nodeExists(NodePath.create().addElement("issues").build()));
        assertTrue(nodeService.nodeExists(NodePath.create().addElement("archive").build()));
    });
}
Also used : Projects(com.enonic.xp.project.Projects) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 7 with Projects

use of com.enonic.xp.project.Projects in project xp by enonic.

the class ProjectServiceImplTest method list_with_custom_permissions.

@Test
void list_with_custom_permissions() {
    doCreateProjectAsAdmin(ProjectName.from("test-project1"), ProjectPermissions.create().build());
    doCreateProjectAsAdmin(ProjectName.from("test-project2"), ProjectPermissions.create().addOwner(REPO_TEST_OWNER.getKey()).build());
    doCreateProjectAsAdmin(ProjectName.from("test-project3"), ProjectPermissions.create().addEditor(REPO_TEST_OWNER.getKey()).build());
    doCreateProjectAsAdmin(ProjectName.from("test-project4"), ProjectPermissions.create().addAuthor(REPO_TEST_OWNER.getKey()).build());
    doCreateProjectAsAdmin(ProjectName.from("test-project5"), ProjectPermissions.create().addContributor(REPO_TEST_OWNER.getKey()).build());
    final AuthenticationInfo authenticationInfo = AuthenticationInfo.copyOf(REPO_TEST_CUSTOM_MANAGER_AUTHINFO).principals(ProjectAccessHelper.createRoleKey(ProjectName.from("test-project2"), ProjectRole.OWNER), ProjectAccessHelper.createRoleKey(ProjectName.from("test-project3"), ProjectRole.EDITOR), ProjectAccessHelper.createRoleKey(ProjectName.from("test-project4"), ProjectRole.AUTHOR), ProjectAccessHelper.createRoleKey(ProjectName.from("test-project5"), ProjectRole.CONTRIBUTOR)).build();
    ContextBuilder.from(contentCustomManagerContext()).authInfo(authenticationInfo).build().runWith(() -> {
        final Projects projects = projectService.list();
        assertEquals(5, projectService.list().getSize());
        assertFalse(projects.stream().anyMatch(project -> project.getName().toString().equals("test-project1")));
        assertTrue(projects.stream().anyMatch(project -> project.getName().equals(ProjectName.from(ContentConstants.CONTENT_REPO_ID))));
    });
}
Also used : NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) BeforeEach(org.junit.jupiter.api.BeforeEach) IdProviderKey(com.enonic.xp.security.IdProviderKey) PrincipalRelationships(com.enonic.xp.security.PrincipalRelationships) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Permission(com.enonic.xp.security.acl.Permission) RepositoryId(com.enonic.xp.repository.RepositoryId) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ContextBuilder(com.enonic.xp.context.ContextBuilder) Assertions.assertAll(org.junit.jupiter.api.Assertions.assertAll) SystemConstants(com.enonic.xp.security.SystemConstants) ProjectPermissionsContextManagerImpl(com.enonic.xp.core.impl.project.ProjectPermissionsContextManagerImpl) CreateUserParams(com.enonic.xp.security.CreateUserParams) User(com.enonic.xp.security.User) Projects(com.enonic.xp.project.Projects) PrincipalRelationship(com.enonic.xp.security.PrincipalRelationship) Set(java.util.Set) Project(com.enonic.xp.project.Project) AccessControlList(com.enonic.xp.security.acl.AccessControlList) Collectors(java.util.stream.Collectors) CreateProjectParams(com.enonic.xp.project.CreateProjectParams) UncheckedIOException(java.io.UncheckedIOException) Test(org.junit.jupiter.api.Test) List(java.util.List) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest) IndexServiceInternal(com.enonic.xp.repo.impl.index.IndexServiceInternal) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) ProjectServiceImpl(com.enonic.xp.core.impl.project.ProjectServiceImpl) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) Repository(com.enonic.xp.repository.Repository) SecurityServiceImpl(com.enonic.xp.core.impl.security.SecurityServiceImpl) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ContentConstants(com.enonic.xp.content.ContentConstants) Node(com.enonic.xp.node.Node) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ProjectConstants(com.enonic.xp.project.ProjectConstants) ProjectRole(com.enonic.xp.project.ProjectRole) ProjectName(com.enonic.xp.project.ProjectName) ModifyProjectIconParams(com.enonic.xp.project.ModifyProjectIconParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) PropertyTree(com.enonic.xp.data.PropertyTree) ProjectGraph(com.enonic.xp.project.ProjectGraph) ProjectPermissions(com.enonic.xp.project.ProjectPermissions) InternalContext(com.enonic.xp.repo.impl.InternalContext) PropertySet(com.enonic.xp.data.PropertySet) NodePath(com.enonic.xp.node.NodePath) IOException(java.io.IOException) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) Mockito.when(org.mockito.Mockito.when) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) Mockito(org.mockito.Mockito) PrincipalKey(com.enonic.xp.security.PrincipalKey) Assertions(org.junit.jupiter.api.Assertions) ProjectAccessException(com.enonic.xp.core.impl.project.ProjectAccessException) ProjectAccessHelper(com.enonic.xp.core.impl.project.ProjectAccessHelper) Tuple.tuple(org.assertj.core.groups.Tuple.tuple) ModifyProjectParams(com.enonic.xp.project.ModifyProjectParams) PrincipalKeys(com.enonic.xp.security.PrincipalKeys) Projects(com.enonic.xp.project.Projects) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

Projects (com.enonic.xp.project.Projects)7 ProjectName (com.enonic.xp.project.ProjectName)5 Test (org.junit.jupiter.api.Test)5 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)4 Context (com.enonic.xp.context.Context)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4 PropertySet (com.enonic.xp.data.PropertySet)4 PropertyTree (com.enonic.xp.data.PropertyTree)4 CreateProjectParams (com.enonic.xp.project.CreateProjectParams)4 ModifyProjectIconParams (com.enonic.xp.project.ModifyProjectIconParams)4 ModifyProjectParams (com.enonic.xp.project.ModifyProjectParams)4 Project (com.enonic.xp.project.Project)4 ProjectConstants (com.enonic.xp.project.ProjectConstants)4 ProjectGraph (com.enonic.xp.project.ProjectGraph)4 ProjectPermissions (com.enonic.xp.project.ProjectPermissions)4 ProjectRole (com.enonic.xp.project.ProjectRole)4 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)4 Repository (com.enonic.xp.repository.Repository)4 RepositoryId (com.enonic.xp.repository.RepositoryId)4 RoleKeys (com.enonic.xp.security.RoleKeys)4