diff --git a/source/java/org/alfresco/repo/web/scripts/LoginTest.java b/source/java/org/alfresco/repo/web/scripts/LoginTest.java index 6ac7a2616c..70c7fc02ee 100644 --- a/source/java/org/alfresco/repo/web/scripts/LoginTest.java +++ b/source/java/org/alfresco/repo/web/scripts/LoginTest.java @@ -26,6 +26,7 @@ package org.alfresco.repo.web.scripts; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; @@ -117,9 +118,9 @@ public class LoginTest extends BaseWebScriptTest String ticketURL = "/api/login/ticket/"+ticket; /** - * Negative test - validate as "admin" - should fail with a 404 + * Negative test - validate as AuthenticationUtil.getAdminUserName() - should fail with a 404 */ - setDefaultRunAs("admin"); + setDefaultRunAs(AuthenticationUtil.getAdminUserName()); sendRequest(new GetRequest(ticketURL), Status.STATUS_NOT_FOUND); /** diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java b/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java index 09a95480b8..1608780734 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryContainerTest.java @@ -87,7 +87,7 @@ public class RepositoryContainerTest extends BaseWebScriptTest public void testRunAs() throws Exception { - Response response = sendRequest(new GetRequest(URL_RUNAS), 200, "admin"); + Response response = sendRequest(new GetRequest(URL_RUNAS), 200, AuthenticationUtil.getAdminUserName()); assertEquals(USER_ONE, response.getContentAsString()); } } diff --git a/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java b/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java index e67e8d4968..ea707529d2 100644 --- a/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java +++ b/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java @@ -67,6 +67,14 @@ public class TestWebScriptRepoServer extends TestWebScriptServer } /** + * Get default user name + */ + protected String getDefaultUserName() + { + return AuthenticationUtil.getAdminUserName(); + } + + /** * Main entry point. */ public static void main(String[] args) @@ -91,12 +99,12 @@ public class TestWebScriptRepoServer extends TestWebScriptServer } private final static String[] CONFIG_LOCATIONS = new String[] - { - "classpath:alfresco/application-context.xml", - "classpath:alfresco/webscript-framework-application-context.xml", - "classpath:alfresco/web-scripts-application-context.xml", - "classpath:alfresco/web-scripts-application-context-test.xml" - }; + { + "classpath:alfresco/application-context.xml", + "classpath:alfresco/webscript-framework-application-context.xml", + "classpath:alfresco/web-scripts-application-context.xml", + "classpath:alfresco/web-scripts-application-context-test.xml" + }; /** * Retrieve an instance of the TestWebScriptServer @@ -155,7 +163,7 @@ public class TestWebScriptRepoServer extends TestWebScriptServer } catch(AuthenticationException e) { - executeCommand("user admin"); + executeCommand("user " + getDefaultUserName()); } // execute command in context of currently selected user diff --git a/source/java/org/alfresco/repo/web/scripts/activities/SiteActivitySystemTest.java b/source/java/org/alfresco/repo/web/scripts/activities/SiteActivitySystemTest.java index 1ea48f24b2..098c31105b 100644 --- a/source/java/org/alfresco/repo/web/scripts/activities/SiteActivitySystemTest.java +++ b/source/java/org/alfresco/repo/web/scripts/activities/SiteActivitySystemTest.java @@ -38,6 +38,7 @@ import java.util.Date; import junit.framework.TestCase; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.site.SiteModel; import org.alfresco.util.Base64; import org.alfresco.util.ISO8601DateFormat; diff --git a/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java b/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java index 38034d7881..4bbf007a2c 100644 --- a/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java +++ b/source/java/org/alfresco/repo/web/scripts/activities/feed/control/FeedControlTest.java @@ -26,6 +26,7 @@ package org.alfresco.repo.web.scripts.activities.feed.control; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; @@ -70,7 +71,7 @@ public class FeedControlTest extends BaseWebScriptTest this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent"); this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService"); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Create users createUser(TEST_USER); diff --git a/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java b/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java index e726564692..4795020b6f 100644 --- a/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/blog/BlogServiceTest.java @@ -30,12 +30,14 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.site.SiteModel; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.util.PropertyMap; import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest; import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; @@ -62,7 +64,6 @@ public class BlogServiceTest extends BaseWebScriptTest private PersonService personService; private SiteService siteService; - private static final String USER_ADMIN = "admin"; private static final String USER_ONE = "UserOneSecondToo"; private static final String USER_TWO = "UserTwoSecondToo"; private static final String SITE_SHORT_NAME_BLOG = "BlogSiteShortNameTest"; @@ -88,14 +89,14 @@ public class BlogServiceTest extends BaseWebScriptTest this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService"); // Authenticate as user - this.authenticationComponent.setCurrentUser(USER_ADMIN); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Create test site // - only create the site if it doesn't already exist SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_BLOG); if (siteInfo == null) { - this.siteService.createSite("BlogSitePreset", SITE_SHORT_NAME_BLOG, "BlogSiteTitle", "BlogSiteDescription", true); + this.siteService.createSite("BlogSitePreset", SITE_SHORT_NAME_BLOG, "BlogSiteTitle", "BlogSiteDescription", SiteVisibility.PUBLIC); } // Create users @@ -112,7 +113,7 @@ public class BlogServiceTest extends BaseWebScriptTest super.tearDown(); // admin user required to delete user - this.authenticationComponent.setCurrentUser(USER_ADMIN); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // TODO don't delete them as it seems they don't get cleaned up correctly // delete the inviter user diff --git a/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java b/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java index cd05c0b6e0..90e907e5ba 100644 --- a/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/discussion/DiscussionServiceTest.java @@ -29,6 +29,7 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.site.SiteModel; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; @@ -59,7 +60,6 @@ public class DiscussionServiceTest extends BaseWebScriptTest private PersonService personService; private SiteService siteService; - private static final String USER_ADMIN = "admin"; private static final String USER_ONE = "UserOneThird"; private static final String USER_TWO = "UserTwoThird"; private static final String SITE_SHORT_NAME_DISCUSSION = "DiscussionSiteShortNameThree"; @@ -84,7 +84,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService"); // Authenticate as user - this.authenticationComponent.setCurrentUser(USER_ADMIN); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Create test site // - only create the site if it doesn't already exist @@ -109,7 +109,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest super.tearDown(); // admin user required to delete user - this.authenticationComponent.setCurrentUser(USER_ADMIN); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // delete the inviter user //personService.deletePerson(USER_ONE); diff --git a/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java b/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java index 61744e34f1..54303d70ab 100644 --- a/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/preference/PreferenceServiceTest.java @@ -26,6 +26,7 @@ package org.alfresco.repo.web.scripts.preference; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; @@ -92,7 +93,7 @@ public class PreferenceServiceTest extends BaseWebScriptTest protected void tearDown() throws Exception { super.tearDown(); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); } diff --git a/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java b/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java index f29a3fb590..294a7103b2 100644 --- a/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java @@ -34,6 +34,7 @@ import java.util.Set; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.site.SiteModel; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.repository.NodeRef; @@ -52,7 +53,6 @@ import org.alfresco.web.scripts.TestWebScriptServer.GetRequest; import org.alfresco.web.scripts.TestWebScriptServer.PostRequest; import org.alfresco.web.scripts.TestWebScriptServer.PutRequest; import org.alfresco.web.scripts.TestWebScriptServer.Response; -import org.htmlparser.parserapplications.SiteCapturer; import org.json.JSONArray; import org.json.JSONObject; @@ -122,7 +122,7 @@ public class SiteServiceTest extends BaseWebScriptTest protected void tearDown() throws Exception { super.tearDown(); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Tidy-up any site's create during the execution of the test for (String shortName : this.createdSites) diff --git a/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java b/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java index 29f0268fc3..b11fa00084 100644 --- a/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/tagging/TaggingServiceTest.java @@ -27,6 +27,7 @@ package org.alfresco.repo.web.scripts.tagging; import org.alfresco.model.ContentModel; import org.alfresco.repo.model.Repository; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.repository.NodeRef; @@ -128,7 +129,7 @@ public class TaggingServiceTest extends BaseWebScriptTest protected void tearDown() throws Exception { super.tearDown(); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); this.taggingService.deleteTag(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"), TAG_1); this.taggingService.deleteTag(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"), TAG_2); diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java index 00519da081..8cccb8357e 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/WebProjectTest.java @@ -29,6 +29,7 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; @@ -112,7 +113,7 @@ public class WebProjectTest extends BaseWebScriptTest protected void tearDown() throws Exception { super.tearDown(); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Tidy-up any web projects created during the execution of the test for (String webProjectRef : this.createdWebProjects) @@ -133,7 +134,7 @@ public class WebProjectTest extends BaseWebScriptTest public void testBasicCRUDWebProject() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); sendRequest(new DeleteRequest(URL_WEB_PROJECTS + "/" + BASIC_DNSNAME),0 ); @@ -201,7 +202,7 @@ public class WebProjectTest extends BaseWebScriptTest { int LOOP_COUNT = 5; - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); for(int i = 0; i < LOOP_COUNT; i++) { @@ -262,7 +263,7 @@ public class WebProjectTest extends BaseWebScriptTest public void testUpdateWebProject() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); /** * Create a web site diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java index 291aec26d8..dd36a1d59d 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/membership/WebProjectMembershipTest.java @@ -29,6 +29,7 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; @@ -55,7 +56,6 @@ public class WebProjectMembershipTest extends BaseWebScriptTest private static final String USER_ONE = "WebProjectTestOne"; private static final String USER_TWO = "WebProjectTestTwo"; private static final String USER_THREE = "WebProjectTestThree"; - private static final String USER_ADMIN = "admin"; public static final String ROLE_CONTENT_MANAGER = "ContentManager"; public static final String ROLE_CONTENT_PUBLISHER = "ContentPublisher"; public static final String ROLE_CONTENT_REVIEWER = "ContentReviewer"; @@ -113,7 +113,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest protected void tearDown() throws Exception { super.tearDown(); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Tidy-up any web projects created during the execution of the test for (String webProjectRef : this.createdWebProjects) @@ -161,7 +161,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest public void testListMemberships() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Create a site String webProjectRef = createWebProject(); @@ -268,7 +268,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest public void testCreateMemberships() throws Exception { - this.authenticationComponent.setCurrentUser(USER_ADMIN); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webProjectRef = createWebProject(); @@ -356,7 +356,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest public void testGetMembership() throws Exception { - this.authenticationComponent.setCurrentUser(USER_ADMIN); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Create a site String webProjectRef = createWebProject(); @@ -371,13 +371,13 @@ public class WebProjectMembershipTest extends BaseWebScriptTest /** * Now lookup the admin user and check they are a content manager */ - Response response = sendRequest(new GetRequest(validURL + "/" + USER_ADMIN), Status.STATUS_OK); + Response response = sendRequest(new GetRequest(validURL + "/" + AuthenticationUtil.getAdminUserName()), Status.STATUS_OK); JSONObject result = new JSONObject(response.getContentAsString()); JSONObject data = result.getJSONObject("data"); // Check the result assertEquals(ROLE_CONTENT_MANAGER, data.get("role")); - assertEquals(USER_ADMIN, data.getJSONObject("person").get("userName")); + assertEquals(AuthenticationUtil.getAdminUserName(), data.getJSONObject("person").get("userName")); } // Update Not yet implemented @@ -468,7 +468,7 @@ public class WebProjectMembershipTest extends BaseWebScriptTest public void testDeleteMembership() throws Exception { - this.authenticationComponent.setCurrentUser(USER_ADMIN); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webProjectRef = createWebProject(); diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java index c91b0df1ca..5eb19b58d2 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/AssetTest.java @@ -31,6 +31,7 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; @@ -57,7 +58,6 @@ public class AssetTest extends BaseWebScriptTest { private static final String USER_TWO = "WebProjectTestTwo"; private static final String USER_THREE = "WebProjectTestThree"; private static final String USER_FOUR = "WebProjectTestFour"; - private static final String USER_ADMIN = "admin"; public static final String ROLE_CONTENT_MANAGER = "ContentManager"; public static final String ROLE_CONTENT_PUBLISHER = "ContentPublisher"; public static final String ROLE_CONTENT_REVIEWER = "ContentReviewer"; @@ -199,7 +199,7 @@ public class AssetTest extends BaseWebScriptTest { protected void tearDown() throws Exception { super.tearDown(); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Tidy-up any web projects created during the execution of the test for (String webProjectRef : this.createdWebProjects) @@ -224,7 +224,7 @@ public class AssetTest extends BaseWebScriptTest { */ public void testModifiedAssetsWebAppTest() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -268,7 +268,7 @@ public class AssetTest extends BaseWebScriptTest { assertNotNull("name is null", name); assertEquals("name is wrong", "yellowFile1", name); - assertEquals("creator is wrong", "admin", creator); + assertEquals("creator is wrong", AuthenticationUtil.getAdminUserName(), creator); assertTrue("not isFile", isFile); assertFalse("not isFolder", isFolder); assertFalse("not isDeleted", isDeleted); @@ -284,7 +284,7 @@ public class AssetTest extends BaseWebScriptTest { */ public void testModifiedAssetsTest() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -344,7 +344,7 @@ public class AssetTest extends BaseWebScriptTest { assertNotNull("name is null", name); assertEquals("name is wrong", "myFile1", name); - assertEquals("creator is wrong", "admin", creator); + assertEquals("creator is wrong", AuthenticationUtil.getAdminUserName(), creator); assertTrue("not isFile", isFile); assertFalse("not isDirectory", isFolder); assertFalse("not isDeleted", isDeleted); @@ -398,7 +398,7 @@ public class AssetTest extends BaseWebScriptTest { */ public void testSubmitAssetsTest() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -671,7 +671,7 @@ public class AssetTest extends BaseWebScriptTest { */ public void testSubmitAssetsWebAppTest() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -727,7 +727,7 @@ public class AssetTest extends BaseWebScriptTest { */ public void testRevertAssetsTest() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -961,7 +961,7 @@ public class AssetTest extends BaseWebScriptTest { */ public void testRevertAssetsWebAppTest() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -1017,7 +1017,7 @@ public class AssetTest extends BaseWebScriptTest { final String YELLOW_FILE = "YellowFile.xyz"; final String ROOT_FILE = "index.htm"; - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -1119,7 +1119,7 @@ public class AssetTest extends BaseWebScriptTest { final String YELLOW_FILE2 = "Buffy.jpg"; final String ROOT_FILE = "index.htm"; - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -1206,7 +1206,7 @@ public class AssetTest extends BaseWebScriptTest { final String YELLOW_FILE = "YellowFile.xyz"; final String ROOT_FILE = "index.htm"; - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -1311,7 +1311,7 @@ public class AssetTest extends BaseWebScriptTest { final String PURPLE_FILE2 = "willow.htm"; final String ROOT_MOVED_FILE = "smashing.htm"; - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); @@ -1391,7 +1391,7 @@ public class AssetTest extends BaseWebScriptTest { final String YELLOW_FILE = "buffy.jpg"; final String ROOT_FILE = "index.htm"; - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER); String sandboxref = createSandbox(webprojref, USER_ONE); diff --git a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java index 9248a0d7ba..979c21e1ba 100644 --- a/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java +++ b/source/java/org/alfresco/repo/web/scripts/wcm/sandbox/SandboxTest.java @@ -31,6 +31,7 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.PersonService; @@ -59,7 +60,6 @@ public class SandboxTest extends BaseWebScriptTest { private static final String USER_TWO = "WebProjectTestTwo"; private static final String USER_THREE = "WebProjectTestThree"; private static final String USER_FOUR = "WebProjectTestFour"; - private static final String USER_ADMIN = "admin"; public static final String ROLE_CONTENT_MANAGER = "ContentManager"; public static final String ROLE_CONTENT_PUBLISHER = "ContentPublisher"; public static final String ROLE_CONTENT_REVIEWER = "ContentReviewer"; @@ -133,7 +133,7 @@ public class SandboxTest extends BaseWebScriptTest { protected void tearDown() throws Exception { super.tearDown(); - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // Tidy-up any web projects created during the execution of the test for (String webProjectRef : this.createdWebProjects) @@ -187,7 +187,7 @@ public class SandboxTest extends BaseWebScriptTest { */ public void testCreateSandbox() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); @@ -259,7 +259,7 @@ public class SandboxTest extends BaseWebScriptTest { */ public void testListSandbox() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); /** @@ -363,7 +363,7 @@ public class SandboxTest extends BaseWebScriptTest { */ public void testGetSandbox() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); @@ -432,7 +432,7 @@ public class SandboxTest extends BaseWebScriptTest { */ public void testDeleteSandbox() throws Exception { - this.authenticationComponent.setCurrentUser("admin"); + this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); String webprojref = createWebProject(); createMembership(webprojref, USER_ONE, ROLE_CONTENT_MANAGER);