use of com.enonic.xp.context.Context in project xp by enonic.
the class ProjectAccessSiteProcessorTest method testProcessUpdateByContentAdmin.
@Test
public void testProcessUpdateByContentAdmin() {
final Context context = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(TEST_USER).principals(RoleKeys.CONTENT_MANAGER_ADMIN).build()).build();
context.runWith(() -> {
final ProcessUpdateParams params = createProcessUpdateParams("white", "blue");
final ProcessUpdateResult result = this.projectAccessSiteProcessor.processUpdate(params);
assertNull(result);
});
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class ProjectAccessSiteProcessorTest method testProcessUpdateByAdmin.
@Test
public void testProcessUpdateByAdmin() {
final Context context = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(TEST_USER).principals(RoleKeys.ADMIN).build()).build();
context.runWith(() -> {
final ProcessUpdateParams params = createProcessUpdateParams("white", "blue");
final ProcessUpdateResult result = this.projectAccessSiteProcessor.processUpdate(params);
assertNull(result);
});
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class GetBranchDataCommand method doExecute.
private SearchResult doExecute() {
final CompareExpr compareExpr = CompareExpr.create(FieldExpr.from(BranchIndexPath.BRANCH_NAME.getPath()), CompareExpr.Operator.EQ, ValueExpr.string(branch.getValue()));
final Context reindexContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(this.repositoryId).branch(branch).build();
return this.nodeSearchService.query(NodeBranchQuery.create().query(QueryExpr.from(compareExpr)).size(NodeSearchService.GET_ALL_SIZE_FLAG).build(), SingleRepoStorageSource.create(reindexContext.getRepositoryId(), SingleRepoStorageSource.Type.BRANCH));
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class DumpServiceImplTest method root_node_gets_correct_properties.
@Test
public void root_node_gets_correct_properties() throws Exception {
final AccessControlList newRepoACL = AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build();
final Repository newRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("my-new-repo"), newRepoACL, ChildOrder.manualOrder()));
final Context newContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(newRepo.getId()).branch(RepositoryConstants.MASTER_BRANCH).build();
newContext.runWith(() -> createNode(NodePath.ROOT, "myNode"));
NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
final Node loadedRootNode = newContext.callWith(() -> this.nodeService.getRoot());
assertEquals(newRepoACL, loadedRootNode.getPermissions());
}
use of com.enonic.xp.context.Context in project xp by enonic.
the class NodeServiceImplTest method createRootNode.
@Test
public void createRootNode() {
final User user = User.create().key(PrincipalKey.ofUser(IdProviderKey.system(), "user1")).displayName("User 1").modifiedTime(Instant.now()).email("user1@enonic.com").login("user1").build();
this.nodeService.createRootNode(CreateRootNodeParams.create().childOrder(ChildOrder.from("_name ASC")).permissions(AccessControlList.of(AccessControlEntry.create().allowAll().principal(user.getKey()).build())).build());
printContentRepoIndex();
final Context context = ContextBuilder.create().authInfo(AuthenticationInfo.create().user(user).principals(RoleKeys.CONTENT_MANAGER_ADMIN).build()).branch(WS_DEFAULT).repositoryId(TEST_REPO_ID).build();
context.runWith(() -> assertNotNull(this.nodeService.getByPath(NodePath.ROOT)));
context.runWith(() -> assertNotNull(this.nodeService.getRoot()));
}
Aggregations