mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
129179 mmuller: Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1) 128640 jvonka: V1 REST API: cleanup and rationalise new api tests (re: remotable helpers & runAs user / admin) - round 5 REPO-113 (also relates to REPO-28, REPO-114, REPO-825) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129353 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,27 +27,35 @@
|
||||
package org.alfresco.rest;
|
||||
|
||||
import org.alfresco.rest.api.tests.AbstractBaseApiTest;
|
||||
import org.alfresco.rest.api.tests.util.JacksonUtil;
|
||||
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
/**
|
||||
* Overrides AbstractBaseApiTest so that only a single network & site is created per test
|
||||
* (instead of pre-creating multiple networks & sites)
|
||||
*
|
||||
* Can also be optionally tweaked locally to:
|
||||
*
|
||||
* - use the default network (ie. super tenant) => instead of creating a new tenant
|
||||
*
|
||||
* - re-use a single setup across test methods => although this does mean that each individual test method must either rely on uniquely created test data and/or cleanup
|
||||
*
|
||||
* Note: For now, these can be explicitly tweaked by a dev (do not commit)
|
||||
* but in the future we could consider making these runtime options.
|
||||
*
|
||||
* @author Gethin James
|
||||
* @author janv
|
||||
*/
|
||||
public class AbstractSingleNetworkSiteTest extends AbstractBaseApiTest
|
||||
{
|
||||
protected String tSiteId;
|
||||
protected String tDocLibNodeId;
|
||||
// note: experimental - for local/dev-use only (YMMV) ;-)
|
||||
// - setting both to true should make the related tests run faster
|
||||
// - if singleSetupNoTearDown=true then each individual test method should create unique data (or cleanup) to avoid interdependent test/run failures
|
||||
// - if useDefaultNetwork=true then no tenant will be created (ie. will use default/super tenant)
|
||||
protected static boolean singleSetupNoTearDown = false;
|
||||
protected static boolean useDefaultNetwork = false;
|
||||
|
||||
protected JacksonUtil jacksonUtil;
|
||||
|
||||
// TODO make this a runtime option to allow creation of non-default network
|
||||
protected final static boolean useDefaultNetwork = true;
|
||||
private static boolean isSetup = false;
|
||||
|
||||
@Override
|
||||
public String getScope()
|
||||
@@ -59,11 +67,8 @@ public class AbstractSingleNetworkSiteTest extends AbstractBaseApiTest
|
||||
@Before
|
||||
public void setup() throws Exception
|
||||
{
|
||||
jacksonUtil = new JacksonUtil(applicationContext.getBean("jsonHelper", JacksonHelper.class));
|
||||
|
||||
// createTestData=false
|
||||
getTestFixture(false);
|
||||
|
||||
if ((! isSetup) || (! singleSetupNoTearDown))
|
||||
{
|
||||
if (! useDefaultNetwork)
|
||||
{
|
||||
networkOne = getRepoService().createNetwork(this.getClass().getName().toLowerCase(), true);
|
||||
@@ -74,34 +79,18 @@ public class AbstractSingleNetworkSiteTest extends AbstractBaseApiTest
|
||||
networkOne = getRepoService().getSystemNetwork();
|
||||
}
|
||||
|
||||
user1 = createUser("user1-" + RUNID, "user1Password", networkOne);
|
||||
user2 = createUser("user2-" + RUNID, "user2Password", networkOne);
|
||||
|
||||
// to enable admin access via test calls - eg. via PublicApiClient -> AbstractTestApi -> findUserByUserName
|
||||
getOrCreateUser("admin", "admin");
|
||||
|
||||
// used-by teardown to cleanup
|
||||
authenticationService = applicationContext.getBean("authenticationService", MutableAuthenticationService.class);
|
||||
personService = applicationContext.getBean("personService", PersonService.class);
|
||||
|
||||
users.add(user1);
|
||||
users.add(user2);
|
||||
|
||||
setRequestContext(networkOne.getId(), user1, null);
|
||||
|
||||
tSiteId = createSite("Test Site - " + System.currentTimeMillis(), SiteVisibility.PRIVATE).getId();
|
||||
tDocLibNodeId = getSiteContainerNodeId(tSiteId, "documentLibrary");
|
||||
|
||||
setRequestContext(null);
|
||||
super.setup();
|
||||
isSetup = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
setRequestContext(networkOne.getId(), user1, null);
|
||||
deleteSite(tSiteId, 204); // TODO permanent=true
|
||||
|
||||
if (! singleSetupNoTearDown)
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -83,7 +83,7 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
||||
setRequestContext(user1);
|
||||
|
||||
Date now = new Date();
|
||||
String folder1 = "folder" + now.getTime() + "_1";
|
||||
String folder1 = "folder-testCreateAndDelete-" + now.getTime() + "_1";
|
||||
Folder createdFolder = createFolder(tDocLibNodeId, folder1, null);
|
||||
assertNotNull(createdFolder);
|
||||
|
||||
@@ -153,7 +153,7 @@ public class DeletedNodesTest extends AbstractSingleNetworkSiteTest
|
||||
getSingle(URL_DELETED_NODES, "iddontexist", 404);
|
||||
|
||||
//Now as admin
|
||||
setRequestContext("admin");
|
||||
setRequestContext(networkAdmin);
|
||||
response = publicApiClient.get(getScope(), URL_DELETED_NODES, null, null, null, createParams(paging, null));
|
||||
checkStatus(200, response.getStatusCode());
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
|
@@ -34,12 +34,12 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.tenant.TenantUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.Site;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
||||
import org.alfresco.rest.api.tests.RepoService.TestPerson;
|
||||
import org.alfresco.rest.api.tests.client.HttpResponse;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiHttpClient.BinaryPayload;
|
||||
@@ -52,8 +52,10 @@ import org.alfresco.rest.api.tests.client.data.Node;
|
||||
import org.alfresco.rest.api.tests.client.data.Rendition;
|
||||
import org.alfresco.rest.api.tests.client.data.SiteMember;
|
||||
import org.alfresco.rest.api.tests.client.data.SiteRole;
|
||||
import org.alfresco.rest.api.tests.util.JacksonUtil;
|
||||
import org.alfresco.rest.api.tests.util.MultiPartBuilder;
|
||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
@@ -106,26 +108,24 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
protected static final String DEFAULT_ADMIN = "admin";
|
||||
private static final String DEFAULT_ADMIN_PWD = "admin";
|
||||
|
||||
protected TestNetwork networkOne;
|
||||
// network1 with user1, user2 and a testsite1
|
||||
protected static TestNetwork networkOne;
|
||||
|
||||
/**
|
||||
* User one from network one
|
||||
*/
|
||||
protected TestPerson userOneN1;
|
||||
protected static String user1; // user1 from network1
|
||||
protected static String user2; // user2 from network1
|
||||
|
||||
/**
|
||||
* User two from network one
|
||||
*/
|
||||
protected TestPerson userTwoN1;
|
||||
protected String userOneN1SiteId;
|
||||
// network admin (or default super admin, if not running within a tenant/network)
|
||||
protected static String networkAdmin = DEFAULT_ADMIN;
|
||||
|
||||
protected String user1;
|
||||
protected String user2;
|
||||
protected static String tSiteId;
|
||||
protected static String tDocLibNodeId;
|
||||
|
||||
protected List<String> users = new ArrayList<>();
|
||||
|
||||
protected MutableAuthenticationService authenticationService;
|
||||
protected PersonService personService;
|
||||
protected static List<String> users = new ArrayList<>();
|
||||
|
||||
protected static JacksonUtil jacksonUtil;
|
||||
protected static MutableAuthenticationService authenticationService;
|
||||
protected static PersonService personService;
|
||||
|
||||
protected final String RUNID = System.currentTimeMillis()+"";
|
||||
|
||||
@@ -133,12 +133,32 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
@Before
|
||||
public void setup() throws Exception
|
||||
{
|
||||
// note: createUser currently relies on repoService
|
||||
user1 = createUser("user1-" + RUNID, "user1Password", null);
|
||||
user2 = createUser("user2-" + RUNID, "user2Password", null);
|
||||
jacksonUtil = new JacksonUtil(applicationContext.getBean("jsonHelper", JacksonHelper.class));
|
||||
|
||||
if (networkOne == null)
|
||||
{
|
||||
// note: populateTestData/createTestData will be called (which currently creates 2 tenants, 9 users per tenant, 10 sites per tenant, ...)
|
||||
networkOne = getTestFixture().getRandomNetwork();
|
||||
}
|
||||
|
||||
//userOneN1 = networkOne.createUser();
|
||||
//userTwoN1 = networkOne.createUser();
|
||||
|
||||
String tenantDomain = networkOne.getId();
|
||||
|
||||
if (! TenantService.DEFAULT_DOMAIN.equals(tenantDomain))
|
||||
{
|
||||
networkAdmin = DEFAULT_ADMIN+"@"+tenantDomain;
|
||||
}
|
||||
|
||||
// to enable admin access via test calls - eg. via PublicApiClient -> AbstractTestApi -> findUserByUserName
|
||||
getOrCreateUser("admin", "admin");
|
||||
getOrCreateUser(networkAdmin, "admin", networkOne);
|
||||
|
||||
setRequestContext(networkAdmin);
|
||||
|
||||
// note: createUser currently relies on repoService
|
||||
user1 = createUser("user1-" + RUNID, "user1Password", networkOne);
|
||||
user2 = createUser("user2-" + RUNID, "user2Password", networkOne);
|
||||
|
||||
// used-by teardown to cleanup
|
||||
authenticationService = applicationContext.getBean("authenticationService", MutableAuthenticationService.class);
|
||||
@@ -146,14 +166,10 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
users.add(user1);
|
||||
users.add(user2);
|
||||
|
||||
// TODO this causes createTestData to be called
|
||||
networkOne = getTestFixture().getRandomNetwork();
|
||||
userOneN1 = networkOne.createUser();
|
||||
userTwoN1 = networkOne.createUser();
|
||||
setRequestContext(networkOne.getId(), user1, null);
|
||||
|
||||
setRequestContext(networkOne.getId(), userOneN1.getId(), null);
|
||||
|
||||
userOneN1SiteId = createSite("TestSite A - " + System.currentTimeMillis(), SiteVisibility.PRIVATE).getId();
|
||||
tSiteId = createSite("TestSite A - " + RUNID, SiteVisibility.PRIVATE).getId();
|
||||
tDocLibNodeId = getSiteContainerNodeId(tSiteId, "documentLibrary");
|
||||
|
||||
setRequestContext(null);
|
||||
}
|
||||
@@ -161,10 +177,10 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
@After
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
if ((networkOne != null) && (userOneN1 != null) && (userOneN1SiteId != null))
|
||||
if ((networkOne != null) && (user1 != null) && (tSiteId != null))
|
||||
{
|
||||
setRequestContext(networkOne.getId(), userOneN1.getId(), null);
|
||||
deleteSite(userOneN1SiteId, 204);
|
||||
setRequestContext(networkOne.getId(), user1, null);
|
||||
deleteSite(tSiteId, true, 204);
|
||||
}
|
||||
|
||||
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
|
||||
@@ -440,22 +456,55 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
/**
|
||||
* TODO implement as remote api call
|
||||
*/
|
||||
protected String createUser(String username, String password, TestNetwork network)
|
||||
protected String createUser(final String usernameIn, final String password, final TestNetwork network)
|
||||
{
|
||||
final String tenantDomain = (network != null ? network.getId() : TenantService.DEFAULT_DOMAIN);
|
||||
|
||||
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String>()
|
||||
{
|
||||
@Override
|
||||
public String doWork() throws Exception
|
||||
{
|
||||
return TenantUtil.runAsTenant(new TenantUtil.TenantRunAsWork<String>()
|
||||
{
|
||||
public String doWork() throws Exception
|
||||
{
|
||||
String username = repoService.getPublicApiContext().createUserName(usernameIn, tenantDomain);
|
||||
PersonInfo personInfo = new PersonInfo(username, username, username, password, null, null, null, null, null, null, null);
|
||||
RepoService.TestPerson person = repoService.createUser(personInfo, username, network);
|
||||
return person.getId();
|
||||
|
||||
}
|
||||
}, tenantDomain);
|
||||
}
|
||||
}, networkAdmin);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO implement as remote api call
|
||||
*/
|
||||
protected String getOrCreateUser(String username, String password)
|
||||
protected String getOrCreateUser(String usernameIn, String password, TestNetwork network)
|
||||
{
|
||||
final String tenantDomain = (network != null ? network.getId() : TenantService.DEFAULT_DOMAIN);
|
||||
|
||||
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String>()
|
||||
{
|
||||
@Override
|
||||
public String doWork() throws Exception
|
||||
{
|
||||
return TenantUtil.runAsTenant(new TenantUtil.TenantRunAsWork<String>()
|
||||
{
|
||||
public String doWork() throws Exception
|
||||
{
|
||||
String username = repoService.getPublicApiContext().createUserName(usernameIn, tenantDomain);
|
||||
PersonInfo personInfo = new PersonInfo(username, username, username, password, null, null, null, null, null, null, null);
|
||||
RepoService.TestPerson person = repoService.getOrCreateUser(personInfo, username, null);
|
||||
RepoService.TestPerson person = repoService.getOrCreateUser(personInfo, username, network);
|
||||
return person.getId();
|
||||
}
|
||||
}, tenantDomain);
|
||||
}
|
||||
}, networkAdmin);
|
||||
}
|
||||
|
||||
protected SiteMember addSiteMember(String siteId, String userId, final SiteRole siteRole) throws Exception
|
||||
{
|
||||
@@ -481,9 +530,15 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Site.class);
|
||||
}
|
||||
|
||||
protected HttpResponse deleteSite(String siteId, int expectedStatus) throws Exception
|
||||
protected HttpResponse deleteSite(String siteId, boolean permanent, int expectedStatus) throws Exception
|
||||
{
|
||||
HttpResponse response = publicApiClient.delete(getScope(), "sites", siteId, null, null);
|
||||
Map params = null;
|
||||
if (permanent == true)
|
||||
{
|
||||
params = Collections.singletonMap("permanent", "true");
|
||||
}
|
||||
|
||||
HttpResponse response = publicApiClient.delete(getScope(), 1, "sites", siteId, null, null, params);
|
||||
checkStatus(expectedStatus, response.getStatusCode());
|
||||
return response;
|
||||
}
|
||||
@@ -525,7 +580,10 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
password = DEFAULT_ADMIN_PWD;
|
||||
}
|
||||
|
||||
setRequestContext(null, runAsUser, password);
|
||||
// Assume "networkOne" if set !
|
||||
String runAsNetwork = (networkOne != null ? networkOne.getId() : null);
|
||||
|
||||
setRequestContext(runAsNetwork, runAsUser, password);
|
||||
}
|
||||
|
||||
protected void setRequestContext(String runAsNetwork, String runAsUser, String password)
|
||||
@@ -534,7 +592,7 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
|
||||
{
|
||||
runAsNetwork = "-default-";
|
||||
}
|
||||
else if (runAsUser.equals(DEFAULT_ADMIN))
|
||||
else if ((runAsUser != null) && runAsUser.equals(DEFAULT_ADMIN))
|
||||
{
|
||||
runAsUser = runAsUser+"@"+runAsNetwork;
|
||||
}
|
||||
|
@@ -63,6 +63,9 @@ public class ActivitiesPostingTest extends AbstractSingleNetworkSiteTest
|
||||
{
|
||||
setRequestContext(user1);
|
||||
|
||||
List<Activity> activities = getMyActivities();
|
||||
int beforeCount = activities.size();
|
||||
|
||||
String folder1 = "folder" + System.currentTimeMillis() + "_1";
|
||||
Folder createdFolder = createFolder(tDocLibNodeId, folder1, null);
|
||||
assertNotNull(createdFolder);
|
||||
@@ -83,8 +86,9 @@ public class ActivitiesPostingTest extends AbstractSingleNetworkSiteTest
|
||||
deleteNode(documentResp.getId());
|
||||
deleteNode(createdFolder.getId());
|
||||
|
||||
List<Activity> activities = getMyActivities();
|
||||
assertEquals(activities.size(),6);
|
||||
activities = getMyActivities();
|
||||
assertEquals(beforeCount+6, activities.size());
|
||||
|
||||
Activity act = matchActivity(activities, ActivityType.FOLDER_ADDED, user1, tSiteId, tDocLibNodeId, folder1);
|
||||
assertNotNull(act);
|
||||
|
||||
|
@@ -27,6 +27,8 @@ package org.alfresco.rest.api.tests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.alfresco.rest.AbstractSingleNetworkSiteTest;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.People;
|
||||
import org.alfresco.rest.api.model.LoginTicket;
|
||||
@@ -49,7 +51,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*/
|
||||
public class AuthenticationsTest extends AbstractBaseApiTest
|
||||
public class AuthenticationsTest extends AbstractSingleNetworkSiteTest
|
||||
{
|
||||
private static final String TICKETS_URL = "tickets";
|
||||
private static final String TICKETS_API_NAME = "authentication";
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -562,7 +562,7 @@ public class NodeAssociationsApiTest extends AbstractSingleNetworkSiteTest
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(user1);
|
||||
permissionService.setPermission(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, sf1Id), user2, PermissionService.EDITOR, true);
|
||||
|
||||
setRequestContext(DEFAULT_ADMIN);
|
||||
setRequestContext(networkAdmin);
|
||||
|
||||
response = publicApiClient.get(getScope(), "nodes/"+sf1Id+"/targets", null, null, null, createParams(paging, null));
|
||||
checkStatus(200, response.getStatusCode());
|
||||
@@ -579,7 +579,7 @@ public class NodeAssociationsApiTest extends AbstractSingleNetworkSiteTest
|
||||
tgt = new AssocTarget(u2o1Id, ASSOC_TYPE_CM_REFERENCES);
|
||||
post(getNodeTargetsUrl(sf1Id), toJsonAsStringNonNull(tgt), 201);
|
||||
|
||||
setRequestContext(DEFAULT_ADMIN);
|
||||
setRequestContext(networkAdmin);
|
||||
|
||||
response = publicApiClient.get(getScope(), "nodes/"+sf1Id+"/targets", null, null, null, createParams(paging, null));
|
||||
checkStatus(200, response.getStatusCode());
|
||||
@@ -606,7 +606,7 @@ public class NodeAssociationsApiTest extends AbstractSingleNetworkSiteTest
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(user1);
|
||||
permissionService.setPermission(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, sf1Id), user2, PermissionService.EDITOR, true);
|
||||
|
||||
setRequestContext(DEFAULT_ADMIN);
|
||||
setRequestContext(networkAdmin);
|
||||
|
||||
response = publicApiClient.get(getScope(), "nodes/"+so1Id+"/sources", null, null, null, createParams(paging, null));
|
||||
checkStatus(200, response.getStatusCode());
|
||||
@@ -623,7 +623,7 @@ public class NodeAssociationsApiTest extends AbstractSingleNetworkSiteTest
|
||||
tgt = new AssocTarget(so1Id, ASSOC_TYPE_CM_REFERENCES);
|
||||
post(getNodeTargetsUrl(u2f1Id), toJsonAsStringNonNull(tgt), 201);
|
||||
|
||||
setRequestContext(DEFAULT_ADMIN);
|
||||
setRequestContext(networkAdmin);
|
||||
|
||||
response = publicApiClient.get(getScope(), "nodes/"+so1Id+"/sources", null, null, null, createParams(paging, null));
|
||||
checkStatus(200, response.getStatusCode());
|
||||
|
@@ -90,9 +90,9 @@ public class PublicApiTestContext
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(alias);
|
||||
if(tenant != null && !tenant.equals(TenantService.DEFAULT_DOMAIN))
|
||||
if ((tenant != null) && (! tenant.equals(TenantService.DEFAULT_DOMAIN)) && (! alias.contains(TenantService.SEPARATOR)))
|
||||
{
|
||||
sb.append("@");
|
||||
sb.append(TenantService.SEPARATOR);
|
||||
sb.append(tenant);
|
||||
}
|
||||
return sb.toString();
|
||||
|
@@ -107,7 +107,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
setRequestContext(networkOne.getId(), userOneN1.getId(), null);
|
||||
deleteSite(userOneN1Site.getId(), 204);
|
||||
deleteSite(userOneN1Site.getId(), true, 204);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -408,6 +408,22 @@ public class RepoService
|
||||
return getOrCreateUser(personInfo, username, network, false);
|
||||
}
|
||||
|
||||
public final static String DEFAULT_ADMIN = "admin";
|
||||
public final static String DEFAULT_ADMIN_PWD = "admin";
|
||||
|
||||
// TODO improve admin-related API tests (including ST vs MT)
|
||||
private boolean isDefaultAdmin(String username, TestNetwork network)
|
||||
{
|
||||
if ((network == null) || (TenantService.DEFAULT_DOMAIN.equals(network.getId())))
|
||||
{
|
||||
return (DEFAULT_ADMIN.equalsIgnoreCase(username));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((DEFAULT_ADMIN+"@"+network.getId()).equalsIgnoreCase(username));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO review delete person
|
||||
public TestPerson getOrCreateUser(final PersonInfo personInfo, final String username, final TestNetwork network, final boolean deletePerson)
|
||||
{
|
||||
@@ -423,8 +439,8 @@ public class RepoService
|
||||
|
||||
final Map<QName, Serializable> props = testPerson.getProperties();
|
||||
|
||||
// short-circuit for default "admin"
|
||||
if (! username.equalsIgnoreCase("admin"))
|
||||
// short-circuit for default/tenant "admin"
|
||||
if (! isDefaultAdmin(username, network))
|
||||
{
|
||||
NodeRef personNodeRef = personService.getPersonOrNull(username);
|
||||
|
||||
@@ -1331,7 +1347,7 @@ public class RepoService
|
||||
{
|
||||
if(!getId().equals(TenantService.DEFAULT_DOMAIN) && !tenantAdminService.existsTenant(getId()))
|
||||
{
|
||||
tenantAdminService.createTenant(getId(), "admin".toCharArray());
|
||||
tenantAdminService.createTenant(getId(), DEFAULT_ADMIN_PWD.toCharArray());
|
||||
numNetworks++;
|
||||
log("Created network " + getId());
|
||||
}
|
||||
|
@@ -667,13 +667,14 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/shared-links/<sharedId>/renditions/<renditionId>/content}
|
||||
*
|
||||
*/
|
||||
// TODO now covered by testSharedLinkCreateGetDelete ? (since base class now uses tenant context by default)
|
||||
@Test
|
||||
public void testSharedLinkCreateGetDelete_MultiTenant() throws Exception
|
||||
{
|
||||
// As userOneN1
|
||||
setRequestContext(networkOne.getId(), userOneN1.getId(), null);
|
||||
// As user1
|
||||
setRequestContext(user1);
|
||||
|
||||
String docLibNodeId = getSiteContainerNodeId(userOneN1SiteId, "documentLibrary");
|
||||
String docLibNodeId = getSiteContainerNodeId(tSiteId, "documentLibrary");
|
||||
|
||||
String folderName = "folder" + System.currentTimeMillis() + "_1";
|
||||
String folderId = createFolder(docLibNodeId, folderName, null).getId();
|
||||
@@ -705,7 +706,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
assertEquals(d1Id, resp.getNodeId());
|
||||
assertEquals(fileName1, resp.getName());
|
||||
assertEquals(file1_MimeType, resp.getContent().getMimeType());
|
||||
assertEquals(userOneN1.getId(), resp.getSharedByUser().getId());
|
||||
assertEquals(user1, resp.getSharedByUser().getId());
|
||||
|
||||
// allowable operations not included - no params
|
||||
response = getSingle(QuickShareLinkEntityResource.class, shared1Id, null, 200);
|
||||
@@ -764,7 +765,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
assertEquals(0, renditions.size());
|
||||
|
||||
// create rendition of pdf doc - note: for some reason create rendition of txt doc fail on build m/c (TBC) ?
|
||||
setRequestContext(userOneN1.getId());
|
||||
setRequestContext(user1);
|
||||
|
||||
Rendition rendition = createAndGetRendition(d1Id, "doclib");
|
||||
assertNotNull(rendition);
|
||||
@@ -807,7 +808,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
getSingle(URL_SHARED_LINKS, shared1Id + "/renditions/doclib/content", null, headers, 304);
|
||||
|
||||
// -ve test - userTwoN1 cannot delete shared link
|
||||
setRequestContext(userTwoN1.getId());
|
||||
setRequestContext(user2);
|
||||
deleteSharedLink(shared1Id, 403);
|
||||
|
||||
// -ve test - unauthenticated
|
||||
@@ -815,7 +816,7 @@ public class SharedLinkApiTest extends AbstractBaseApiTest
|
||||
deleteSharedLink(shared1Id, 401);
|
||||
|
||||
// delete shared link
|
||||
setRequestContext(userOneN1.getId());
|
||||
setRequestContext(user1);
|
||||
deleteSharedLink(shared1Id);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user