Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Space Public Site - Meeds-io/MIPs#151 - dev meed #1151

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.PageType;
import org.exoplatform.portal.mop.page.PageContext;
import org.exoplatform.portal.mop.page.PageKey;
import org.exoplatform.portal.mop.page.PageState;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.services.rest.impl.ContainerResponse;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.services.security.IdentityRegistry;
import org.exoplatform.services.security.MembershipEntry;
import org.exoplatform.social.rest.api.RestUtils;
Expand Down Expand Up @@ -112,14 +112,18 @@ public void testGetNotePageWithAnonim() throws ObjectAlreadyExistsException {
Page notePage = getNotePage(pageNoteName, null);
assertNull(notePage);

assertEquals(403, saveNotePage(pageNoteName, pageContent, null).getStatus());

resetRestUtils();
registerInternalUser(USERNAME);
assertEquals(401, saveNotePage(pageNoteName, pageContent, null).getStatus());
assertEquals(404, saveNotePage(pageNoteName + "22", pageContent, null).getStatus());

registerAdministratorUser(USERNAME);
saveNotePage(pageNoteName, pageContent, null);
assertEquals(204, saveNotePage(pageNoteName, pageContent, null).getStatus());
restartTransaction();

resetRestUtils();
registerInternalUser(USERNAME);
notePage = getNotePage(pageNoteName, null);
assertNotNull(notePage);
assertEquals(pageContent, notePage.getContent());
Expand Down Expand Up @@ -186,14 +190,9 @@ private String createPage(String pageName, String accessPermission, String editP
PageState pageState = new PageState(pageName,
null,
false,
false,
null,
Collections.singletonList(accessPermission),
editPermission,
Collections.singletonList(editPermission),
Collections.singletonList(editPermission),
PageType.PAGE.name(),
null);
editPermission);
layoutService.save(new PageContext(pageKey, pageState));
return pageKey.format();
}
Expand Down Expand Up @@ -254,8 +253,9 @@ private ContainerResponse saveNotePage(String name, String content, String lang)
private org.exoplatform.services.security.Identity registerAdministratorUser(String user) {
org.exoplatform.services.security.Identity identity =
new org.exoplatform.services.security.Identity(user,
Arrays.asList(MembershipEntry.parse(ADMINISTRATORS_GROUP)));
Arrays.asList(MembershipEntry.parse(ADMINISTRATORS_GROUP), MembershipEntry.parse(USERS_GROUP)));
identityRegistry.register(identity);
ConversationState.setCurrent(new ConversationState(identity));
resetRestUtils();
REST_UTILS.when(RestUtils::getCurrentUser).thenReturn(USERNAME);
REST_UTILS.when(RestUtils::getCurrentUserAclIdentity).thenReturn(identity);
Expand All @@ -267,6 +267,7 @@ private org.exoplatform.services.security.Identity registerInternalUser(String u
new org.exoplatform.services.security.Identity(username,
Arrays.asList(MembershipEntry.parse(USERS_GROUP)));
identityRegistry.register(identity);
ConversationState.setCurrent(new ConversationState(identity));
resetRestUtils();
REST_UTILS.when(RestUtils::getCurrentUser).thenReturn(USERNAME);
REST_UTILS.when(RestUtils::getCurrentUserAclIdentity).thenReturn(identity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.exoplatform.commons.exception.ObjectNotFoundException;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.PageType;
import org.exoplatform.portal.mop.page.PageContext;
import org.exoplatform.portal.mop.page.PageKey;
import org.exoplatform.portal.mop.page.PageState;
Expand Down Expand Up @@ -161,14 +160,9 @@ private String createPage(String pageName, String accessPermission, String editP
PageState pageState = new PageState(pageName,
null,
false,
false,
null,
Collections.singletonList(accessPermission),
editPermission,
Collections.singletonList(editPermission),
Collections.singletonList(editPermission),
PageType.PAGE.name(),
null);
editPermission);
layoutService.save(new PageContext(pageKey, pageState));
return pageKey.format();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
import org.exoplatform.wiki.service.WikiPageParams;
import org.exoplatform.wiki.utils.NoteConstants;

import static org.exoplatform.social.core.jpa.test.AbstractCoreTest.persist;

/**
* Created by The eXo Platform SAS Author : eXoPlatform [email protected]
* 9/8/15
Expand Down Expand Up @@ -1161,7 +1159,7 @@ public void testDeleteOrphanDraftPagesByParentPage() throws Exception {
draft = draftPageDAO.create(draft);
assertNotNull(draft);
storage.deleteOrphanDraftPagesByParentPage(Long.parseLong(wiki.getWikiHome().getId()));
persist();
restartTransaction();
assertNull(draftPageDAO.find(draft.getId()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.exoplatform.wiki.jpa.entity.PageEntity;
import org.exoplatform.wiki.jpa.entity.WikiEntity;

import static org.exoplatform.social.core.jpa.test.AbstractCoreTest.persist;

/**
* Created by The eXo Platform SAS Author : eXoPlatform [email protected] Jun
* 26, 2015
Expand Down Expand Up @@ -348,7 +346,7 @@ public void testFindLatestDraftPageByTargetPage() throws InterruptedException {
dp1.setCreatedDate(new Date());
dp1.setUpdatedDate(new Date());
draftPageDAO.create(dp1);
persist();
restartTransaction();

// Added to fix random fail when draft pages
// are added at the same time
Expand All @@ -361,7 +359,7 @@ public void testFindLatestDraftPageByTargetPage() throws InterruptedException {
dp2.setCreatedDate(new Date());
dp2.setUpdatedDate(new Date());
draftPageDAO.create(dp2);
persist();
restartTransaction();

// When
DraftPageEntity latestDraft = draftPageDAO.findLatestDraftPageByTargetPage(page.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,9 @@

import org.exoplatform.container.xml.InitParams;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.Page;

public class MockUserACL extends UserACL {

/* (non-Javadoc)
* @see org.exoplatform.portal.config.UserACL#hasPermission(org.exoplatform.portal.config.model.Page)
*/
@Override
public boolean hasPermission(Page page) {
return true;
}

/**
* @param params
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package org.exoplatform.wiki.service;


import static org.exoplatform.social.core.jpa.test.AbstractCoreTest.persist;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -720,7 +719,7 @@ public void testRemoveOrphanDraftPagesByParentPage() throws Exception {
draft = noteService.createDraftForNewPage(draft, new Date().getTime(), 1L);
assertNotNull(draft);
noteService.removeOrphanDraftPagesByParentPage(Long.parseLong(homePage.getId()));
persist();
restartTransaction();
assertNull(noteService.getDraftNoteById(draft.getId(), "root"));
}

Expand Down