Merge branch 'TAS-2599' into 'master'

Tas 2599

See merge request !362
This commit is contained in:
Valentin Popa
2017-01-13 11:47:55 +00:00
3 changed files with 149 additions and 17 deletions
@@ -0,0 +1,41 @@
package org.alfresco.rest.networks;
import org.alfresco.rest.RestTest;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
*
* @author Cristina Axinte
*
*/
public class RestGetNetworkCoreTests extends RestTest
{
UserModel adminTenantUser;
UserModel tenantUser;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
UserModel adminuser = dataUser.getAdminUser();
adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminuser);
restClient.usingTenant().createTenant(adminTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE })
public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception
{
restClient.authenticateUser(adminTenantUser);
restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser());
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
}
}
@@ -0,0 +1,101 @@
package org.alfresco.rest.networks;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestNetworkModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
*
* @author Cristina Axinte
*
*/
public class RestGetNetworkFullTests extends RestTest
{
UserModel adminTenantUser, adminuser;
UserModel adminAnotherTenantUser;
SiteModel site;
UserModel tenantUser;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminuser = dataUser.getAdminUser();
adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminuser);
restClient.usingTenant().createTenant(adminTenantUser);
adminAnotherTenantUser = UserModel.getAdminTenantUser();
restClient.usingTenant().createTenant(adminAnotherTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("userTenant1");
site = dataSite.usingUser(adminTenantUser).createPublicRandomSite();
}
@Bug(id = "ACE-5738")
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
description = "Verify tenant admin user gets an invalid network with Rest API and checks the not found status")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL })
public void adminTenantGetsInvalidNetwork() throws Exception
{
restClient.authenticateUser(adminAnotherTenantUser);
adminAnotherTenantUser.setDomain("tenant.@%");
restClient.withCoreAPI().usingNetworks().getNetwork(adminAnotherTenantUser);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
.containsSummary(String.format(RestErrorModel.UNEXPECTED_TENANT, adminTenantUser.getDomain(), "@"))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@Bug(id = "ACE-5745")
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
description = "Verify admin user gets an existing network successfully with Rest API")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL })
public void adminUserGetsExistingNetwork() throws Exception
{
RestNetworkModel restNetworkModel = restClient.authenticateUser(adminuser).withCoreAPI().usingNetworks().getNetwork(adminTenantUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
restNetworkModel.assertThat().fieldsCount().is("1");
restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain())
.and().field("homeNetwork").isNull()
.and().field("isEnabled").is("true");
}
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
description = "Verify tenant admin user gets network using properties parameter successfully with Rest API")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL })
public void adminTenantGetsNetworkUsingPropertiesParameter() throws Exception
{
JSONObject entryResponse= restClient.authenticateUser(tenantUser).withCoreAPI().usingNetworks().usingParams("properties=id").getNetworkWithParams(adminTenantUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
Assert.assertTrue(entryResponse.get("id").equals(adminTenantUser.getDomain().toLowerCase()));
assertJsonResponseDoesnotContainField(entryResponse, "homeNetwork");
assertJsonResponseDoesnotContainField(entryResponse, "isEnabled");
}
private void assertJsonResponseDoesnotContainField(JSONObject entryResponse, String field)
{
try{
entryResponse.get(field);
}
catch(JSONException ex)
{
Assert.assertTrue(ex.getMessage().equals(String.format("JSONObject[\"%s\"] not found.", field)));
}
}
}
@@ -39,7 +39,7 @@ public class RestGetNetworkSanityTests extends RestTest
@Bug(id = "MNT-16904")
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY})
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY})
public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception
{
UserModel tenantUser = new UserModel("nonexisting", "password");
@@ -51,7 +51,7 @@ public class RestGetNetworkSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify tenant admin user gets specific network with Rest API and response is not empty")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
public void adminTenantChecksIfNetworkIsPresent() throws Exception
{
restClient.authenticateUser(adminTenantUser);
@@ -68,16 +68,6 @@ public class RestGetNetworkSanityTests extends RestTest
restClient.withCoreAPI().usingNetworks().getNetwork().assertNetworkHasName(adminTenantUser).assertNetworkIsEnabled();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify tenant admin user gets non existing network with Rest API and checks the not found status")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception
{
restClient.authenticateUser(adminTenantUser);
restClient.withCoreAPI().usingNetworks().getNetwork(UserModel.getRandomTenantUser());
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify tenant admin user gets another existing network with Rest API and checks the forbidden status")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
@@ -119,7 +109,7 @@ public class RestGetNetworkSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify any tenant user gets another existing network with Rest API and checks the forbidden status")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception
{
restClient.authenticateUser(tenantUser);
@@ -129,7 +119,7 @@ public class RestGetNetworkSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify manager tenant user gets its network with Rest API and response is not empty")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception
{
UserModel managerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("manTenant");
@@ -142,7 +132,7 @@ public class RestGetNetworkSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify collaborator tenant user gets its network with Rest API and response is not empty")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception
{
UserModel collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("colTenant");
@@ -155,7 +145,7 @@ public class RestGetNetworkSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify consumer tenant user gets its network with Rest API and response is not empty")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception
{
UserModel consumerTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("consTenant");
@@ -168,7 +158,7 @@ public class RestGetNetworkSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
description = "Verify contributor tenant user gets its network with Rest API and response is not empty")
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
public void tenantContributorUserChecksIfItsNetworkIsPresent() throws Exception
{
UserModel contributorTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("contTenant");