Merge branch '5.2.N' into 'master'

5.2.n

See merge request !242
This commit is contained in:
Paul Brodner
2016-11-25 08:53:19 +00:00
17 changed files with 280 additions and 81 deletions
@@ -6,10 +6,8 @@ import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.model.RestCommentModel;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.model.*;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.springframework.http.HttpStatus;
@@ -76,14 +74,16 @@ public class DeleteCommentsSanityTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
}
@Bug(id="MNT-16904")
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails")
public void managerIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify User gets status code 401 if authentication call fails")
public void userIsNotAbleToDeleteCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by admin");
UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword");
restClient.authenticateUser(nonexistentModel);
comment = restClient.withCoreAPI().usingResource(document).addComment("New comment addded by Manager");
restClient.withCoreAPI().usingResource(document).deleteComment(comment);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED);
}
}
@@ -17,7 +17,7 @@ import org.testng.annotations.Test;
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.CORE })
public class GetCommentsCoreTests extends RestTest
{
private UserModel adminUserModel, userModel;
private UserModel adminUserModel, userModel, networkUserModel;
private FileModel document;
private SiteModel siteModel;
private String comment = "This is a new comment";
@@ -30,6 +30,7 @@ public class GetCommentsCoreTests extends RestTest
{
adminUserModel = dataUser.getAdminUser();
userModel = dataUser.createRandomTestUser();
networkUserModel = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
restClient.authenticateUser(adminUserModel).withCoreAPI()
@@ -48,7 +49,7 @@ public class GetCommentsCoreTests extends RestTest
restClient.authenticateUser(adminUserModel).withParams("maxItems=0")
.withCoreAPI().usingResource(document).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument"));
.assertLastError().containsSummary("Only positive values supported for maxItems");
}
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.COMMENTS}, executionType= ExecutionType.REGRESSION,
@@ -105,7 +106,7 @@ public class GetCommentsCoreTests extends RestTest
@Bug(id = "MNT-16904")
public void getCommentsWithInvalidNetwork() throws Exception
{
userModel.setDomain("invalidNetwork");
networkUserModel.setDomain("invalidNetwork");
restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@@ -115,7 +116,7 @@ public class GetCommentsCoreTests extends RestTest
@Bug(id = "MNT-16904")
public void getCommentsWithEmptyNetwork() throws Exception
{
userModel.setDomain("");
networkUserModel.setDomain("");
restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@@ -7,12 +7,7 @@ import org.alfresco.rest.model.RestCommentModel;
import org.alfresco.rest.model.RestCommentModelsCollection;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.LinkModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.model.*;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
@@ -43,7 +38,7 @@ public class UpdateCommentsCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.SANITY }, executionType = ExecutionType.SANITY, description = "Verify can not update comment if NodeId is neither document or folder and returns status code 405")
@Bug(id="MNT-16904")
public void canNotUpdateCommentIfNodeIdIsNeitherDoumentOrFolder() throws JsonToModelConversionException, Exception
public void canNotUpdateCommentIfNodeIdIsNeitherDocumentOrFolder() throws JsonToModelConversionException, Exception
{
FileModel content = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
content = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
@@ -61,7 +56,7 @@ public class UpdateCommentsCoreTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user is not able to update with empty comment body and status code is 400")
public void adminIsNotAbleToUpdateWithEptyCommentBody() throws JsonToModelConversionException, Exception
public void adminIsNotAbleToUpdateWithEmptyCommentBody() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
@@ -82,16 +77,16 @@ public class UpdateCommentsCoreTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.OK);
comments.assertThat().entriesListContains("content", "This is the updated comment with Collaborator user");
}
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update comments of another user and status code is 200")
public void collaboratorIsAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can not update comments of another user and status code is 200")
public void collaboratorIsNotAbleToUpdateCommentOfAnotherUser() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user");
restClient.assertStatusCodeIs(HttpStatus.OK);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
}
@TestRail(section = { TestGroup.REST_API,
@@ -41,7 +41,7 @@ public class UpdateCommentsSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates comments and status code is 200")
public void adminIsAbleToUpdateComments() throws JsonToModelConversionException, Exception
public void adminIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by admin");
@@ -54,7 +54,7 @@ public class UpdateCommentsSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Manager user updates comments created by admin user and status code is 200")
public void managerIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
public void managerIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by manager");
@@ -67,7 +67,7 @@ public class UpdateCommentsSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can update his own comment and status code is 200")
public void contributorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
public void contributorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by contributor");
@@ -91,7 +91,7 @@ public class UpdateCommentsSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API,
TestGroup.COMMENTS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can update his own comment and status code is 200")
@Bug(id="REPO-1011")
public void collaboratorIsAbleToUpdateComment() throws JsonToModelConversionException, Exception
public void collaboratorIsAbleToUpdateHisComment() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment added by collaborator");
@@ -104,9 +104,11 @@ public class UpdateCommentsSanityTests extends RestTest
@Bug(id="MNT-16904")
public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
commentModel = restClient.withCoreAPI().usingResource(document).addComment("To be updated by unauthenticated user.");
UserModel incorrectUserModel = new UserModel("userName", "password");
restClient.authenticateUser(incorrectUserModel)
.withCoreAPI().usingResource(document).getNodeComments();
.withCoreAPI().usingResource(document).updateComment(commentModel, "try to update");
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@@ -229,7 +229,6 @@ public class GetFavoritesCoreTests extends RestTest
.and().paginationField("totalItems").is("2");
}
@Bug(id="MNT-17146")
@TestRail(section = { TestGroup.REST_API,
TestGroup.FAVORITES }, executionType = ExecutionType.REGRESSION, description = "Verify request using personId that does not exist returns status 404")
public void checkFavoritesWhenPersonIdDoesNotExist() throws Exception
@@ -10,6 +10,7 @@ import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS })
public class RestGetNetworkForPersonSanityTests extends RestTest
{
private UserModel adminUserModel;
@@ -28,7 +28,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest
}
@Bug(id = "MNT-16904")
@Test(groups = TestGroup.COMMENTS)
@Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS})
@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")
@@ -41,7 +41,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@Test(groups = TestGroup.COMMENTS)
@Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS})
@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")
@@ -52,7 +52,7 @@ public class RestGetNetworksForPersonSanityTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.OK);
}
@Test(groups = TestGroup.COMMENTS)
@Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS})
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS },
executionType = ExecutionType.SANITY,
description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status")
@@ -63,8 +63,8 @@ public class RestGetNetworksForPersonSanityTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
}
@Test(groups = TestGroup.COMMENTS)
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS },
@Test(groups = {TestGroup.COMMENTS, TestGroup.NETWORKS})
@TestRail(section = { TestGroup.REST_API, TestGroup.NETWORKS },
executionType = ExecutionType.SANITY,
description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status")
public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception
@@ -68,7 +68,6 @@ public class DeleteSiteMemberSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
executionType = ExecutionType.SANITY,
description = "Verify site collaborator does not have permission to delete another member of the site")
@Bug(id="ACE-5444")
public void siteCollaboratorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception
{
UserModel newUser = dataUser.createRandomTestUser("testUser");
@@ -78,14 +77,12 @@ public class DeleteSiteMemberSanityTests extends RestTest
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId()));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
executionType = ExecutionType.SANITY,
description = "Verify site contributor does not have permission to delete another member of the site")
@Bug(id="ACE-5444")
public void siteContributorIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception
{
UserModel newUser = dataUser.createRandomTestUser("testUser");
@@ -95,14 +92,12 @@ public class DeleteSiteMemberSanityTests extends RestTest
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId()));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
executionType = ExecutionType.SANITY,
description = "Verify site consumer does not have permission to delete another member of the site")
@Bug(id="ACE-5444")
public void siteConsumerIsNotAbleToDeleteSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception
{
UserModel newUser = dataUser.createRandomTestUser("testUser");
@@ -112,10 +107,10 @@ public class DeleteSiteMemberSanityTests extends RestTest
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
restClient.withCoreAPI().usingUser(newUser).deleteSiteMember(siteModel);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
restClient.assertStatusCodeIs(HttpStatus.UNPROCESSABLE_ENTITY).assertLastError().containsSummary(String.format(ErrorModel.NOT_SUFFICIENT_PERMISSIONS, siteModel.getId()));
}
@Bug(id="MNT-16904")
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
executionType = ExecutionType.SANITY,
description = "Verify unauthenticated user is not able to delete another member of the site")
@@ -42,7 +42,6 @@ public class GetFavoriteSiteCoreTests extends RestTest
.assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, "someUser"));
}
@Bug(id="MNT-17146")
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
executionType = ExecutionType.REGRESSION,
description = "Verify invalid request returns status 404 when siteId does not exist")
@@ -0,0 +1,217 @@
package org.alfresco.rest.ratings;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestCommentModel;
import org.alfresco.rest.model.RestRatingModel;
import org.alfresco.rest.model.RestTagModel;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.exception.DataPreparationException;
import org.alfresco.utility.model.ErrorModel;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.LinkModel;
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.apache.commons.lang3.RandomStringUtils;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test(groups = { TestGroup.REST_API, TestGroup.RATINGS, TestGroup.CORE })
public class AddRatingCoreTests extends RestTest
{
private UserModel userModel;
private SiteModel siteModel;
private UserModel adminUser;
private FolderModel folderModel;
private FileModel document;
private ListUserWithRoles usersWithRoles;
private RestRatingModel returnedRatingModel; //placeholder for returned model
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws DataPreparationException
{
userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20));
adminUser = dataUser.getAdminUser();
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
UserRole.SiteContributor);
}
@BeforeMethod
public void setUp() throws Exception
{
folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that if unknown rating scheme is provided status code is 400")
public void unknownRatingSchemeReturnsBadRequest() throws Exception
{
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"invalidRate\"}");
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.INVALID_RATING, "invalidRate"));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that if nodeId does not exist status code 404 is returned")
public void invalidNodeIdReturnsNotFound() throws Exception
{
document.setNodeRef(RandomStringUtils.randomAlphanumeric(10));
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(ErrorModel.ENTITY_NOT_FOUND, document.getNodeRef()));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that if nodeId provided cannot be rated 405 status code is returned")
@Bug(id = "MNT-16904")
public void likeResourceThatCannotBeRated() throws Exception
{
LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
document.setNodeRef(link.getNodeRef());
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager is able to like a file")
public void managerIsAbleToLikeAFile() throws Exception
{
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("true")
.and().field("id").is("likes")
.and().field("aggregate").isNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager is able to like a folder")
public void managerIsAbleToLikeAFolder() throws Exception
{
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("true")
.and().field("id").is("likes")
.and().field("aggregate").isNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager is able to rate a folder")
public void managerIsAbleToRateAFolder() throws Exception
{
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(folderModel).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("5")
.and().field("id").is("fiveStar")
.and().field("aggregate").isNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager is able to rate a file")
public void managerIsAbleToRateAFile() throws Exception
{
returnedRatingModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(document).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("5")
.and().field("id").is("fiveStar")
.and().field("aggregate").isNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that adding like again has no effect on a file")
public void fileCanBeLikedTwice() throws Exception
{
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("true")
.and().field("id").is("likes")
.and().field("aggregate").isNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that adding rate again has no effect on a file")
public void fileCanBeRatedTwice() throws Exception
{
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
returnedRatingModel.assertThat().field("myRating").is("5")
.and().field("id").is("fiveStar")
.and().field("aggregate").isNotEmpty();
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that rate is not added if empty rating object is provided")
public void addRateUsingEmptyRatingObject() throws Exception
{
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("");
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT,
"No content to map to Object due to end of input"));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that if empty rate id is provided status code is 400")
public void addRateUsingEmptyValueForId() throws Exception
{
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"\"}");
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NO_CONTENT,
"N/A (through reference chain: org.alfresco.rest.api.model.NodeRating[\"id\"])"));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that if empty rating is provided status code is 400")
public void addRateUsingEmptyValueForMyRating() throws Exception
{
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"likes\", \"myRating\":\"\"}");
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_LIKE_RATING));
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addInvalidRating("{\"id\":\"fiveStar\", \"myRating\":\"\"}");
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(ErrorModel.NULL_FIVESTAR_RATING));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that user is not able to rate a comment")
public void addRatingToAComment() throws Exception
{
RestCommentModel comment = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment("This is a comment");
document.setNodeRef(comment.getId());
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE));
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE));
}
@TestRail(section = { TestGroup.REST_API, TestGroup.RATINGS }, executionType = ExecutionType.REGRESSION,
description = "Verify that user is not able to rate a tag")
public void addRatingToATag() throws Exception
{
RestTagModel tag = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addTag("randomTag");
document.setNodeRef(tag.getId());
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).likeDocument();
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE));
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).rateStarsToDocument(5);
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(String.format(ErrorModel.CANNOT_RATE));
}
}
@@ -44,7 +44,7 @@ public class GetRatingsCoreTests extends RestTest {
restClient.authenticateUser(adminUserModel).withParams("maxItems=0").withCoreAPI().usingResource(document)
.getLikeRating();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument"));
.containsSummary("Only positive values supported for maxItems");
}
@TestRail(section = { TestGroup.REST_API,
@@ -54,7 +54,7 @@ public class GetRatingsCoreTests extends RestTest {
restClient.authenticateUser(adminUserModel).withParams("skipCount=AB").withCoreAPI().usingResource(document)
.getLikeRating();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument"));
.containsSummary("Invalid paging parameter skipCount:AB");
}
@TestRail(section = { TestGroup.REST_API,
@@ -8,6 +8,7 @@ import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.exception.DataPreparationException;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.StatusModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
@@ -108,6 +109,6 @@ public class GetSiteMembersSanityTests extends RestTest
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
restClient.authenticateUser(userModel)
.withCoreAPI().usingSite(siteModel).getSiteMembers();
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastException().hasName(StatusModel.UNAUTHORIZED);
}
}
@@ -54,7 +54,7 @@ public class GetSitesCoreTests extends RestTest
restClient.authenticateUser(userModel).withParams("maxItems=0")
.withCoreAPI().getSites();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument"));
.assertLastError().containsSummary("Only positive values supported for maxItems");
}
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
@@ -64,14 +64,14 @@ public class GetSitesCoreTests extends RestTest
restClient.authenticateUser(userModel).withParams("skipCount=A")
.withCoreAPI().getSites();
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
.assertLastError().containsSummary(String.format(ErrorModel.INVALID_ARGUMENT, "argument"));
.assertLastError().containsSummary("Invalid paging parameter skipCount:A");
}
@TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION,
description= "Verify User gets sites ordered by name ascendant and status code is 200")
public void getSitesOrderedByNameASC() throws Exception
{
sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=name ASC")
sites = restClient.authenticateUser(privateSiteManager).withParams("orderBy=title ASC")
.withCoreAPI().getSites();
restClient.assertStatusCodeIs(HttpStatus.OK);
sites.assertThat().entriesListIsNotEmpty();
@@ -23,12 +23,6 @@ import org.testng.annotations.Test;
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY })
public class GetSitesSanityTests extends RestTest
{
@Autowired
DataUser dataUser;
@Autowired
DataSite dataSite;
private UserModel adminUserModel;
private UserModel userModel;
private ListUserWithRoles usersWithRoles;
@@ -38,7 +32,6 @@ public class GetSitesSanityTests extends RestTest
public void dataPreparation() throws Exception
{
adminUserModel = dataUser.getAdminUser();
restClient.authenticateUser(adminUserModel);
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
}
@@ -46,8 +39,7 @@ public class GetSitesSanityTests extends RestTest
@TestRail(section = { TestGroup.REST_API, TestGroup.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.getOneUserWithRole(UserRole.SiteManager))
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withParams("maxItems=1000")
.withCoreAPI().getSites()
.assertThat().entriesListIsNotEmpty()
.assertThat().entriesListContains("id", siteModel.getId())
@@ -59,7 +51,7 @@ public class GetSitesSanityTests extends RestTest
description = "Verify user with Collaborator role gets sites information and gets status code OK (200)")
public void collaboratorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("maxItems=1000")
.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty()
.assertThat().entriesListContains("id", siteModel.getId())
.and().paginationExist();
@@ -72,7 +64,7 @@ public class GetSitesSanityTests extends RestTest
public void contributorIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).withParams("maxItems=1000")
.withCoreAPI().getSites()
.assertThat().entriesListIsNotEmpty()
.assertThat().entriesListContains("id", siteModel.getId())
@@ -85,7 +77,7 @@ public class GetSitesSanityTests extends RestTest
public void consumerIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withParams("maxItems=1000")
.withCoreAPI().getSites()
.assertThat().entriesListIsNotEmpty()
.assertThat().entriesListContains("id", siteModel.getId())
@@ -97,7 +89,7 @@ public class GetSitesSanityTests extends RestTest
description = "Verify user with Admin user gets sites information and gets status code OK (200)")
public void adminUserIsAbleToRetrieveSites() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel)
restClient.authenticateUser(adminUserModel).withParams("maxItems=1000")
.withCoreAPI().getSites()
.assertThat().entriesListIsNotEmpty()
.assertThat().entriesListContains("id", siteModel.getId())
@@ -114,7 +106,7 @@ public class GetSitesSanityTests extends RestTest
userModel = dataUser.createRandomTestUser();
userModel.setPassword("user wrong password");
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
restClient.authenticateUser(userModel)
restClient.authenticateUser(userModel).withParams("maxItems=1000")
.withCoreAPI().getSites();
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@@ -13,6 +13,7 @@ import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.StatusModel;
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.springframework.http.HttpStatus;
@@ -112,6 +113,7 @@ public class DeleteTagSanityTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(ErrorModel.PERMISSION_WAS_DENIED);
}
@Bug(id="MNT-16904")
@TestRail(section = { TestGroup.REST_API,
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception
@@ -8,11 +8,7 @@ import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.StatusModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.model.*;
import org.alfresco.utility.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
@@ -42,12 +38,10 @@ public class GetTagsSanityTests extends RestTest
document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
tagValue = RandomData.getRandomName("tag");
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
tagValue2 = RandomData.getRandomName("tag");
restClient.withCoreAPI().usingResource(document).addTag(tagValue2);
restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2);
Utility.waitToLoopTime(5);
Utility.waitToLoopTime(60);
}
@@ -55,7 +49,7 @@ public class GetTagsSanityTests extends RestTest
public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags();
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("tag", tagValue.toLowerCase())
@@ -66,7 +60,7 @@ public class GetTagsSanityTests extends RestTest
public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags();
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("tag", tagValue.toLowerCase())
@@ -77,7 +71,7 @@ public class GetTagsSanityTests extends RestTest
public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags();
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("tag", tagValue.toLowerCase())
@@ -88,7 +82,7 @@ public class GetTagsSanityTests extends RestTest
public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags();
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("tag", tagValue.toLowerCase())
@@ -99,7 +93,7 @@ public class GetTagsSanityTests extends RestTest
public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(adminUserModel);
RestTagModelsCollection returnedCollection = restClient.withCoreAPI().getTags();
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=500").withCoreAPI().getTags();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("tag", tagValue.toLowerCase())
+2 -1
View File
@@ -29,9 +29,10 @@ rest.workflowPath=alfresco/api/-default-/public/workflow/versions/1
testManagement.endPoint=https://alfresco.testrail.com/
testManagement.username=tas.alfresco@gmail.com
testManagement.apiKey=EYpY7.fV0AoMGWbmyuVC-k5u.nzwHy6a.QWzJq8.S
testManagement.project=7
testManagement.project=1
testManagement.testRun=Automation
testManagement.justUploadTest=false
testManagement.suiteId=1
# The location of the reports path
reports.path=./target/reports