mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
127534 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2) 125537 jvonka: RA-779 / RA-780: Sites API - additional tests, also add skipConfiguration (pending open question) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127644 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -72,4 +72,5 @@ public interface Sites
|
|||||||
|
|
||||||
String PARAM_PERMANENT = "permanent";
|
String PARAM_PERMANENT = "permanent";
|
||||||
String PARAM_SKIP_ADDTOFAVORITES = "skipAddToFavorites";
|
String PARAM_SKIP_ADDTOFAVORITES = "skipAddToFavorites";
|
||||||
|
String PARAM_SKIP_SURF_CONFIGURATION = "skipConfiguration";
|
||||||
}
|
}
|
||||||
|
@@ -871,7 +871,7 @@ public class SitesImpl implements Sites
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create default/preset (Share) site - with DocLib container/component
|
* Create default/fixed preset (Share) site - with DocLib container/component
|
||||||
*
|
*
|
||||||
* @param site
|
* @param site
|
||||||
* @return
|
* @return
|
||||||
@@ -900,8 +900,13 @@ public class SitesImpl implements Sites
|
|||||||
|
|
||||||
String siteId = siteInfo.getShortName();
|
String siteId = siteInfo.getShortName();
|
||||||
|
|
||||||
// import default surf config
|
// default false (if not provided)
|
||||||
|
boolean skipShareSurfConfig = Boolean.valueOf(parameters.getParameter(PARAM_SKIP_SURF_CONFIGURATION));
|
||||||
|
if (skipShareSurfConfig == false)
|
||||||
|
{
|
||||||
|
// import default/fixed preset Share surf config
|
||||||
importSite(siteId);
|
importSite(siteId);
|
||||||
|
}
|
||||||
|
|
||||||
// pre-create doclib
|
// pre-create doclib
|
||||||
siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
|
siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
|
||||||
|
@@ -42,7 +42,6 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
|||||||
import org.alfresco.rest.api.tests.client.PublicApiClient.Sites;
|
import org.alfresco.rest.api.tests.client.PublicApiClient.Sites;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiException;
|
import org.alfresco.rest.api.tests.client.PublicApiException;
|
||||||
import org.alfresco.rest.api.tests.client.RequestContext;
|
import org.alfresco.rest.api.tests.client.RequestContext;
|
||||||
import org.alfresco.rest.api.tests.client.data.Comment;
|
|
||||||
import org.alfresco.rest.api.tests.client.data.Site;
|
import org.alfresco.rest.api.tests.client.data.Site;
|
||||||
import org.alfresco.rest.api.tests.client.data.SiteImpl;
|
import org.alfresco.rest.api.tests.client.data.SiteImpl;
|
||||||
import org.alfresco.rest.api.tests.client.data.SiteRole;
|
import org.alfresco.rest.api.tests.client.data.SiteRole;
|
||||||
@@ -52,34 +51,33 @@ import org.apache.commons.httpclient.HttpStatus;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author sglover
|
||||||
|
* @author janv
|
||||||
|
*/
|
||||||
public class TestSites extends EnterpriseTestApi
|
public class TestSites extends EnterpriseTestApi
|
||||||
{
|
{
|
||||||
private TestNetwork network1;
|
private TestNetwork network1;
|
||||||
private String personId;
|
|
||||||
private String person1Id;
|
private String person1Id;
|
||||||
private TestSite site1;
|
private String person2Id;
|
||||||
|
|
||||||
|
private Site site1;
|
||||||
|
private Site site2;
|
||||||
|
private Site site3;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception
|
public void setup() throws Exception
|
||||||
{
|
{
|
||||||
// Test: user is member of an account
|
// Test: user is member of an account
|
||||||
this.network1 = getTestFixture().getRandomNetwork();
|
this.network1 = getTestFixture().getRandomNetwork();
|
||||||
|
|
||||||
Iterator<String> personIt = network1.getPersonIds().iterator();
|
Iterator<String> personIt = network1.getPersonIds().iterator();
|
||||||
this.personId = personIt.next();
|
|
||||||
assertNotNull(personId);
|
|
||||||
this.person1Id = personIt.next();
|
this.person1Id = personIt.next();
|
||||||
assertNotNull(person1Id);
|
assertNotNull(person1Id);
|
||||||
|
|
||||||
this.site1 = TenantUtil.runAsUserTenant(new TenantRunAsWork<TestSite>()
|
this.person2Id = personIt.next();
|
||||||
{
|
assertNotNull(person2Id);
|
||||||
@Override
|
|
||||||
public TestSite doWork() throws Exception
|
|
||||||
{
|
|
||||||
String siteName = "site" + System.currentTimeMillis();
|
|
||||||
SiteInformation site = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PRIVATE);
|
|
||||||
return network1.createSite(site);
|
|
||||||
}
|
|
||||||
}, person1Id, network1.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -87,11 +85,30 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
Sites sitesProxy = publicApiClient.sites();
|
Sites sitesProxy = publicApiClient.sites();
|
||||||
|
|
||||||
// get a site
|
// create & get sites (as person 2)
|
||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2Id));
|
||||||
|
|
||||||
|
String siteTitle = "site 1 " + System.currentTimeMillis();
|
||||||
|
Site site = new SiteImpl(siteTitle, SiteVisibility.PRIVATE.toString());
|
||||||
|
site1 = sitesProxy.createSite(site);
|
||||||
|
|
||||||
Site ret = sitesProxy.getSite(site1.getSiteId());
|
Site ret = sitesProxy.getSite(site1.getSiteId());
|
||||||
site1.expected(ret);
|
site1.expected(ret);
|
||||||
|
|
||||||
|
siteTitle = "site 2 " + System.currentTimeMillis();
|
||||||
|
site = new SiteImpl(siteTitle, SiteVisibility.PUBLIC.toString());
|
||||||
|
site2 = sitesProxy.createSite(site);
|
||||||
|
|
||||||
|
ret = sitesProxy.getSite(site2.getSiteId());
|
||||||
|
site2.expected(ret);
|
||||||
|
|
||||||
|
siteTitle = "site 3 " + System.currentTimeMillis();
|
||||||
|
site = new SiteImpl(siteTitle, SiteVisibility.MODERATED.toString());
|
||||||
|
site3 = sitesProxy.createSite(site);
|
||||||
|
|
||||||
|
ret = sitesProxy.getSite(site3.getSiteId());
|
||||||
|
site3.expected(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TestSite> expectedSites = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<TestSite>>()
|
List<TestSite> expectedSites = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<TestSite>>()
|
||||||
@@ -99,21 +116,24 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
@Override
|
@Override
|
||||||
public List<TestSite> doWork() throws Exception
|
public List<TestSite> doWork() throws Exception
|
||||||
{
|
{
|
||||||
List<TestSite> sites = network1.getSites(personId);
|
List<TestSite> sites = network1.getSites(person1Id);
|
||||||
return sites;
|
return sites;
|
||||||
}
|
}
|
||||||
}, personId, network1.getId());
|
}, person1Id, network1.getId());
|
||||||
|
|
||||||
{
|
{
|
||||||
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
||||||
|
|
||||||
int skipCount = 0;
|
int skipCount = 0;
|
||||||
int maxItems = 2;
|
int maxItems = 2;
|
||||||
Paging paging = getPaging(skipCount, maxItems, expectedSites.size(), expectedSites.size());
|
Paging paging = getPaging(skipCount, maxItems, expectedSites.size(), expectedSites.size());
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
|
|
||||||
ListResponse<Site> resp = sitesProxy.getSites(createParams(paging, null));
|
ListResponse<Site> resp = sitesProxy.getSites(createParams(paging, null));
|
||||||
checkList(expectedSites.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
|
checkList(expectedSites.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
||||||
|
|
||||||
int skipCount = 2;
|
int skipCount = 2;
|
||||||
int maxItems = Integer.MAX_VALUE;
|
int maxItems = Integer.MAX_VALUE;
|
||||||
Paging paging = getPaging(skipCount, maxItems, expectedSites.size(), expectedSites.size());
|
Paging paging = getPaging(skipCount, maxItems, expectedSites.size(), expectedSites.size());
|
||||||
@@ -123,10 +143,11 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
|
|
||||||
// test create and delete site
|
// test create and delete site
|
||||||
{
|
{
|
||||||
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
||||||
|
|
||||||
String siteTitle = "my site !*#$ 123";
|
String siteTitle = "my site !*#$ 123";
|
||||||
|
|
||||||
Site site = new SiteImpl(siteTitle, SiteVisibility.PRIVATE.toString());
|
Site site = new SiteImpl(siteTitle, SiteVisibility.PRIVATE.toString());
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
|
|
||||||
Site ret = sitesProxy.createSite(site);
|
Site ret = sitesProxy.createSite(site);
|
||||||
String siteId = ret.getSiteId();
|
String siteId = ret.getSiteId();
|
||||||
|
|
||||||
@@ -134,22 +155,12 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
Site siteExp = new SiteImpl(null, expectedSiteId, ret.getGuid(), siteTitle, null, SiteVisibility.PRIVATE.toString(), null, SiteRole.SiteManager);
|
Site siteExp = new SiteImpl(null, expectedSiteId, ret.getGuid(), siteTitle, null, SiteVisibility.PRIVATE.toString(), null, SiteRole.SiteManager);
|
||||||
siteExp.expected(ret);
|
siteExp.expected(ret);
|
||||||
|
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
|
|
||||||
ret = sitesProxy.getSite(siteId);
|
ret = sitesProxy.getSite(siteId);
|
||||||
siteExp.expected(ret);
|
siteExp.expected(ret);
|
||||||
|
|
||||||
sitesProxy.removeSite(siteId);
|
sitesProxy.removeSite(siteId);
|
||||||
|
|
||||||
try
|
sitesProxy.getSite(siteId, 404);
|
||||||
{
|
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
|
|
||||||
sitesProxy.getSite(siteId);
|
|
||||||
fail("");
|
|
||||||
}
|
|
||||||
catch(PublicApiException e)
|
|
||||||
{
|
|
||||||
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -ve tests
|
// -ve tests
|
||||||
@@ -158,11 +169,15 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), GUID.generate(), "password"));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), GUID.generate(), "password"));
|
||||||
sitesProxy.getSite(site1.getSiteId(), 401);
|
sitesProxy.getSite(site1.getSiteId(), 401);
|
||||||
|
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
||||||
|
|
||||||
// -ve - permission test
|
// -ve - cannot view or delete a private site
|
||||||
// make sure that a user can't see PRIVATE sites of which they are not a member by creating one and checking it's not in the results
|
|
||||||
sitesProxy.getSite(site1.getSiteId(), 404);
|
sitesProxy.getSite(site1.getSiteId(), 404);
|
||||||
|
sitesProxy.removeSite(site1.getSiteId(), 404);
|
||||||
|
|
||||||
|
// -ve - test cannot delete a public site (but can view it)
|
||||||
|
sitesProxy.getSite(site2.getSiteId(), 200);
|
||||||
|
sitesProxy.removeSite(site2.getSiteId(), 403);
|
||||||
|
|
||||||
// -ve - try to get unknown site
|
// -ve - try to get unknown site
|
||||||
sitesProxy.getSite(GUID.generate(), 404);
|
sitesProxy.getSite(GUID.generate(), 404);
|
||||||
@@ -186,13 +201,15 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
sitesProxy.removeSite(GUID.generate(), 404);
|
sitesProxy.removeSite(GUID.generate(), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
||||||
|
|
||||||
// -ve - cannot call POST method on /sites/siteId
|
// -ve - cannot call POST method on /sites/siteId
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sitesProxy.create("sites", "site", null, null, null, "Unable to POST to a site");
|
sitesProxy.create("sites", "site", null, null, null, "Unable to POST to a site");
|
||||||
fail();
|
fail();
|
||||||
}
|
} catch (PublicApiException e)
|
||||||
catch(PublicApiException e)
|
|
||||||
{
|
{
|
||||||
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
|
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
|
||||||
}
|
}
|
||||||
@@ -202,16 +219,15 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
{
|
{
|
||||||
sitesProxy.remove("sites", null, null, null, "Unable to DELETE sites");
|
sitesProxy.remove("sites", null, null, null, "Unable to DELETE sites");
|
||||||
fail();
|
fail();
|
||||||
}
|
} catch (PublicApiException e)
|
||||||
catch(PublicApiException e)
|
|
||||||
{
|
{
|
||||||
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
|
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test Case cloud-1478
|
// Test Case cloud-1478
|
||||||
// Test Case cloud-1479
|
// Test Case cloud-1479
|
||||||
// user invited to network and user invited to site
|
// user invited to network and user invited to site
|
||||||
// user invited to network and user not invited to site
|
// user invited to network and user not invited to site
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user