-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfd8122
commit c4eae1e
Showing
7 changed files
with
187 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
import com.dotmarketing.portlets.structure.model.Field; | ||
import com.dotmarketing.portlets.structure.model.Structure; | ||
import com.dotmarketing.portlets.templates.model.Template; | ||
import com.dotmarketing.util.Config; | ||
import com.dotmarketing.util.Logger; | ||
import com.google.common.collect.Lists; | ||
import com.liferay.portal.model.User; | ||
|
@@ -61,6 +62,7 @@ public class PermissionAPIIntegrationTest extends IntegrationTestBase { | |
private static Host host; | ||
private static User systemUser; | ||
private static Template template; | ||
private static int permissionCacheSize = 0; | ||
|
||
@BeforeClass | ||
public static void createTestHost() throws Exception { | ||
|
@@ -75,7 +77,7 @@ public static void createTestHost() throws Exception { | |
userAPI = APILocator.getUserAPI(); | ||
|
||
host = new Host(); | ||
host.setHostname("testhost.demo.dotcms.com"); | ||
host.setHostname(System.currentTimeMillis() + "testhost.demo.dotcms.com"); | ||
try{ | ||
HibernateUtil.startTransaction(); | ||
host=hostAPI.save(host, systemUser, false); | ||
|
@@ -94,6 +96,9 @@ public static void createTestHost() throws Exception { | |
APILocator.getTemplateAPI().saveTemplate(template, host, systemUser, false); | ||
Map<String, Object> sessionAttrs = new HashMap<>(); | ||
sessionAttrs.put("USER_ID", "dotcms.org.1"); | ||
permissionCacheSize = Config.getIntProperty("cache.permissionshortlived.size", 0); | ||
Config.setProperty("cache.permissionshortlived.size", 0); | ||
CacheLocator.getPermissionCache().flushShortTermCache(); | ||
} | ||
|
||
@AfterClass | ||
|
@@ -107,6 +112,8 @@ public static void deleteTestHost() throws DotDataException { | |
HibernateUtil.rollbackTransaction(); | ||
Logger.error(PermissionAPIIntegrationTest.class, e.getMessage()); | ||
} | ||
Config.setProperty("cache.permissionshortlived.size", 0); | ||
CacheLocator.getPermissionCache().flushShortTermCache(); | ||
} | ||
|
||
@Test | ||
|
@@ -277,7 +284,7 @@ public void test_permissionIndividuallyByRole() { | |
|
||
try { | ||
// Create test Host. | ||
host.setHostname("permission.dotcms.com"); | ||
host.setHostname( System.currentTimeMillis() + "-permission.dotcms.com"); | ||
host = hostAPI.save(host, systemUser, false); | ||
|
||
// Create the Folders needed. | ||
|
@@ -289,30 +296,30 @@ public void test_permissionIndividuallyByRole() { | |
// Child: Product Publisher | ||
// Grandchild: Product Contributor | ||
// Create Parent Role. | ||
parentRole.setName("Webmaster-Test"); | ||
parentRole.setName(System.currentTimeMillis() + "-Webmaster-Test"); | ||
parentRole.setEditUsers(true); | ||
parentRole.setEditPermissions(true); | ||
parentRole.setEditLayouts(true); | ||
parentRole = roleAPI.save(parentRole); | ||
|
||
// Create Child Role Role. | ||
childRole.setName("Product Contributor-Test"); | ||
childRole.setName(System.currentTimeMillis() + "-Product Contributor-Test"); | ||
childRole.setEditUsers(true); | ||
childRole.setEditPermissions(true); | ||
childRole.setEditLayouts(true); | ||
childRole.setParent(parentRole.getId()); | ||
childRole = roleAPI.save(childRole); | ||
|
||
// Create Grandchild Role Role. | ||
grandChildRole.setName("Product Contributor-Test"); | ||
grandChildRole.setName(System.currentTimeMillis() + "-Product Contributor-Test"); | ||
grandChildRole.setEditUsers(true); | ||
grandChildRole.setEditPermissions(true); | ||
grandChildRole.setEditLayouts(true); | ||
grandChildRole.setParent(childRole.getId()); | ||
grandChildRole = roleAPI.save(grandChildRole); | ||
|
||
// Now lets create a user, assign the role and test basic permissions. | ||
newUser = userAPI.createUser("[email protected]", "[email protected]"); | ||
newUser = userAPI.createUser("[email protected]", System.currentTimeMillis() + "-[email protected]"); | ||
newUser.setFirstName("Test-11962"); | ||
newUser.setLastName("User-11962"); | ||
userAPI.save(newUser, systemUser, false); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.