mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-10-08 14:51:20 +00:00
Fix response handling in case of failure, add some small fixes
This commit is contained in:
@@ -1,107 +0,0 @@
|
||||
package org.alfresco.rest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.UserRole;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author iulia.cojocea
|
||||
*/
|
||||
@Test(groups = { "rest-api", "comments", "sanity" })
|
||||
public class GetSitesTests extends RestTest
|
||||
{
|
||||
@Autowired
|
||||
RestSitesApi siteAPI;
|
||||
|
||||
@Autowired
|
||||
DataUser dataUser;
|
||||
|
||||
@Autowired
|
||||
DataSite dataSite;
|
||||
|
||||
private UserModel adminUserModel;
|
||||
private UserModel userModel;
|
||||
private HashMap<UserRole, UserModel> usersWithRoles;
|
||||
private SiteModel siteModel;
|
||||
|
||||
@BeforeClass
|
||||
public void initTest() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.useRestClient(restClient);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor));
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Admin user gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Failed authentication get sites call returns status code 401 with Manager role")
|
||||
public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager));
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString());
|
||||
}
|
||||
}
|
@@ -45,7 +45,8 @@ public class GetCommentsSanityTest extends RestTest
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
commentsAPI.addComment(document.getNodeRef(), "This is a new comment");
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor));
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor));
|
||||
}
|
||||
|
||||
@TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY,
|
||||
|
@@ -9,7 +9,6 @@ import org.alfresco.rest.requests.RestCommentsApi;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -71,9 +70,8 @@ public class RestDemoTest extends RestTest
|
||||
@Test
|
||||
public void adminCanPostAndUpdateComments() throws Exception
|
||||
{
|
||||
FileModel fileModel = dataContent.usingResource(new FolderModel("Shared"))
|
||||
.usingUser(userModel)
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
FileModel fileModel = dataContent.usingUser(userModel).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
// add new comment
|
||||
RestCommentModel commentEntry = commentsAPI.addComment(fileModel.getNodeRef(), "This is a new comment");
|
||||
commentsAPI.getNodeComments(fileModel.getNodeRef())
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package org.alfresco.rest;
|
||||
package org.alfresco.rest.sites;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
@@ -21,7 +22,6 @@ import org.testng.annotations.Test;
|
||||
/**
|
||||
* @author iulia.cojocea
|
||||
*/
|
||||
|
||||
@Test(groups = { "rest-api", "sites", "sanity" })
|
||||
public class GetSiteSanityTests extends RestTest
|
||||
{
|
||||
@@ -44,7 +44,6 @@ public class GetSiteSanityTests extends RestTest
|
||||
public void initTest() throws DataPreparationException
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.useRestClient(restClient);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
@@ -88,7 +87,7 @@ public class GetSiteSanityTests extends RestTest
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with admin role gets site information and gets status code OK (200)")
|
||||
description = "Verify admin user gets site information and gets status code OK (200)")
|
||||
public void getSiteWithAdminRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
@@ -97,7 +96,7 @@ public class GetSiteSanityTests extends RestTest
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Failed authentication get site call returns status code 401 with Manager role")
|
||||
description = "Failed authentication get site call returns status code 401")
|
||||
public void getSiteWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
@@ -1,8 +1,9 @@
|
||||
package org.alfresco.rest;
|
||||
package org.alfresco.rest.sites;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.requests.RestSitesApi;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
@@ -48,10 +49,10 @@ public class GetSitesSanityTests extends RestTest
|
||||
Arrays.asList(UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor));
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithManagerRole() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Manager role gets sites information and gets status code OK (200)")
|
||||
public void managerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
@@ -59,9 +60,8 @@ public class GetSitesSanityTests extends RestTest
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Collaborator role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithCollaboratorRole() throws JsonToModelConversionException, Exception
|
||||
public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteCollaborator));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
@@ -69,9 +69,8 @@ public class GetSitesSanityTests extends RestTest
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Contributor role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithContributorRole() throws JsonToModelConversionException, Exception
|
||||
public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteContributor));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
@@ -79,17 +78,16 @@ public class GetSitesSanityTests extends RestTest
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Consumer role gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithConsumerRole() throws JsonToModelConversionException, Exception
|
||||
public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteConsumer));
|
||||
siteAPI.getAllSites();
|
||||
siteAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user with Admin user gets sites information and gets status code OK (200)")
|
||||
public void getSitesWithAdminUser() throws JsonToModelConversionException, Exception
|
||||
description = "Verify admin user gets sites information and gets status code OK (200)")
|
||||
public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteAPI.getAllSites();
|
||||
@@ -97,8 +95,8 @@ public class GetSitesSanityTests extends RestTest
|
||||
}
|
||||
|
||||
@TestRail(section = { "rest-api", "sites" }, executionType = ExecutionType.SANITY,
|
||||
description = "Failed authentication get sites call returns status code 401 with Manager role")
|
||||
public void getSitesWithManagerRoleFailedAuth() throws JsonToModelConversionException, Exception
|
||||
description = "Failed authentication on get sites call returns status code 401")
|
||||
public void unauthenticatedUserIsNotAuthorizedToRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.get(UserRole.SiteManager));
|
||||
userModel = dataUser.createRandomTestUser();
|
Reference in New Issue
Block a user