use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class RepositoryServiceImplTest method update_data.
@Test
void update_data() {
final String repoId = "repo-with-data";
doCreateRepo(repoId);
Context mockCurrentContext = ContextBuilder.create().branch("master").repositoryId(repoId).authInfo(REPO_TEST_DEFAULT_USER_AUTHINFO).build();
PropertyTree data = new PropertyTree();
data.setString("myProp", "b");
mockCurrentContext.callWith(() -> repositoryService.updateRepository(UpdateRepositoryParams.create().repositoryId(RepositoryId.from(repoId)).editor(edit -> edit.data = data).build()));
final Repository persistedRepo = getPersistedRepoWithoutCache(repoId);
assertEquals("b", persistedRepo.getData().getString("myProp"));
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class ProjectServiceImplTest method create.
@Test
void create() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final Project project = doCreateProjectAsAdmin(ProjectName.from(projectRepoId));
assertNotNull(project);
assertEquals("test-project", project.getName().toString());
final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
assertNotNull(nodeBranchEntry);
adminContext().runWith(() -> {
final Repository pro = repositoryService.get(projectRepoId);
assertNotNull(pro);
});
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class ProjectServiceImplTest method create_project_with_public_readAccess.
@Test
void create_project_with_public_readAccess() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final ProjectName projectName = ProjectName.from(projectRepoId);
adminContext().callWith(() -> doCreateProject(projectName, null, false, null, AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()).build()));
ContextBuilder.from(adminContext()).branch(ContentConstants.BRANCH_DRAFT).repositoryId(projectRepoId).build().runWith(() -> {
final Node rootContentNode = nodeService.getByPath(ContentConstants.CONTENT_ROOT_PATH);
final AccessControlList rootContentPermissions = rootContentNode.getPermissions();
assertTrue(rootContentPermissions.getEntry(RoleKeys.EVERYONE).isAllowed(Permission.READ));
});
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class ProjectServiceImplTest method delete_with_roles.
@Test
void delete_with_roles() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
doCreateProjectAsAdmin(ProjectName.from(projectRepoId));
adminContext().runWith(() -> {
this.projectService.delete(ProjectName.from(projectRepoId));
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.owner")).isEmpty());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.author")).isEmpty());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.contributor")).isEmpty());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.editor")).isEmpty());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.viewer")).isEmpty());
});
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class ProjectServiceImplTest method create_with_roles.
@Test
void create_with_roles() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
doCreateProjectAsAdmin(ProjectName.from(projectRepoId));
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.owner")).isPresent());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.author")).isPresent());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.contributor")).isPresent());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.editor")).isPresent());
assertTrue(securityService.getRole(PrincipalKey.ofRole("cms.project.test-project.viewer")).isPresent());
}
Aggregations