diff --git a/e2e-test/java/org/alfresco/rest/auth/AuthTests.java b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java new file mode 100644 index 000000000..255ad3b39 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/auth/AuthTests.java @@ -0,0 +1,29 @@ +package org.alfresco.rest.auth; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTicketBodyModel; +import org.alfresco.rest.model.RestTicketModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +public class AuthTests extends RestTest +{ + @TestRail(section = { TestGroup.REST_API }, executionType = ExecutionType.SANITY, description = "Verify TICKET is returned on admin user") + @Test + public void adminShouldGetTicketBody() throws JsonToModelConversionException, Exception + { + RestTicketBodyModel ticketBody = new RestTicketBodyModel(); + ticketBody.setUserId("admin"); + ticketBody.setPassword("admin"); + + RestTicketModel ticketReturned = restClient.withAuthAPI().createTicket(ticketBody); + + restClient.assertStatusCodeIs(HttpStatus.CREATED); + ticketReturned.assertThat().field("id").contains("TICKET_"); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java index 6265d073c..260811444 100644 --- a/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/comments/GetCommentsSanityTests.java @@ -4,10 +4,10 @@ import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; 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; @@ -90,14 +90,13 @@ public class GetCommentsSanityTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, description= "Verify Manager user gets status code 401 if authentication call fails") - @Bug(id="MNT-16904") public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception { UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword"); restClient.authenticateUser(nonexistentModel).withCoreAPI() .usingResource(document).getNodeComments(); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED) - .assertLastException().hasName(StatusModel.UNAUTHORIZED); + .assertLastError().containsSummary(RestErrorModel.AUTHENTICATION_FAILED); } @TestRail(section={TestGroup.REST_API, TestGroup.SANITY}, executionType= ExecutionType.SANITY, diff --git a/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java b/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java deleted file mode 100644 index 9369ac754..000000000 --- a/e2e-test/java/org/alfresco/rest/demo/RMDemoTest.java +++ /dev/null @@ -1,80 +0,0 @@ -//package org.alfresco.rest.demo; -// -//import org.alfresco.rest.RestTest; -//import org.alfresco.rest.exception.JsonToModelConversionException; -//import org.alfresco.rest.requests.RestSitesApi; -//import org.alfresco.utility.exception.DataPreparationException; -//import org.alfresco.utility.exception.TestConfigurationException; -//import org.alfresco.utility.model.SiteModel; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.social.alfresco.api.entities.Site.Visibility; -//import org.testng.annotations.BeforeClass; -//import org.testng.annotations.Test; -// -//@Test(groups = { "demo" }) -//public class RMDemoTest extends RestTest { -// @Autowired -// RestSitesApi sitesApi; -// -// private SiteModel siteModel; -// -// @BeforeClass(alwaysRun = true) -// public void dataPreparation() throws DataPreparationException { -// siteModel = dataSite.usingAdmin().createPublicRandomSite(); -// restClient.authenticateUser(dataUser.getAdminUser()); -// -// sitesApi.useRestClient(restClient); -// } -// -// @Test -// public void adminCanSeeDetailsOfARandomSiteCreated() throws JsonToModelConversionException, Exception -// { -// restClient.usingSite(siteModel).getSite() -// .assertThat().field("id").isNotNull() -// .and().field("description").is(siteModel.getDescription()) -// .and().field("title").is(siteModel.getTitle()); -// } -// -// @Test -// public void adminCanSeeSiteDetailsOfCustomSite() throws JsonToModelConversionException, Exception -// { -// siteModel = dataSite.usingAdmin().createPublicRandomSite(); -// siteModel.setDescription("my description"); -// siteModel.setVisibility(Visibility.PUBLIC); -// -// // here we create the custom siteModel defined above -// dataSite.usingAdmin().createSite(siteModel); -// -// siteModel -// .assertThat().field("id").isNotNull() -// .and().field("description").is("my description") -// .and().field("title").is("MyTitle") -// .and().field("visibility").is(Visibility.PUBLIC); -// } -// -// /** -// * This will throw this error message: -// * "You missed some configuration settings in your tests: You try to assert field [fieldA] that -// * doesn't exist in class: [org.alfresco.rest.model.RestSiteModel]. Please check your code!" -// */ -// @Test(expectedExceptions = TestConfigurationException.class) -// public void assertingWithFieldsThatDoesNotExist() throws JsonToModelConversionException, Exception { -// siteModel = dataSite.createPublicRandomSite(); -// -// sitesApi.getSite(siteModel).assertThat().field("fieldA").isNotNull(); -// } -// -// @Test -// public void assertingPaginationAndUsingParameters() throws Exception -// { -// /* -// * ~ each API has the possibility to pass parameters to httpMethod call -// * you can use withParams(String... parameters) method before calling the http method. -// */ -// sitesApi.withParams("maxItems=2", "orderyBy=name").getSites() -// .assertThat().paginationExist(); -//// .and().paginationField("maxItems").is("2"); -// -// } -// -//} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java index dc743c453..9ffa5aa39 100644 --- a/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/AddSiteMemberCoreTests.java @@ -7,6 +7,7 @@ import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestSiteMemberModel; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; import org.alfresco.utility.model.UserModel; @@ -15,18 +16,21 @@ import org.alfresco.utility.testrail.annotation.TestRail; import org.springframework.http.HttpMethod; 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.SITES, TestGroup.CORE }) public class AddSiteMemberCoreTests extends RestTest { private UserModel adminUserModel; + private UserModel testUser; private SiteModel publicSiteModel; private SiteModel moderatedSiteModel; private SiteModel privateSiteModel; - private ListUserWithRoles usersWithRolesToMoedratedSite; + private ListUserWithRoles usersWithRolesToModeratedSite; private ListUserWithRoles usersWithRolesToPrivateSite; private String addMembersJson; + private RestSiteMemberModel memberModel; @BeforeClass(alwaysRun=true) public void dataPreparation() throws Exception @@ -35,57 +39,57 @@ public class AddSiteMemberCoreTests extends RestTest publicSiteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); moderatedSiteModel = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); privateSiteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite(); - usersWithRolesToMoedratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, + usersWithRolesToModeratedSite = dataUser.addUsersWithRolesToSite(moderatedSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,UserRole.SiteContributor); usersWithRolesToPrivateSite = dataUser.addUsersWithRolesToSite(privateSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,UserRole.SiteContributor); addMembersJson = "{\"role\":\"%s\",\"id\":\"%s\"}, {\"role\":\"%s\",\"id\":\"%s\"}"; - + } + + @BeforeMethod + public void setUp() throws DataPreparationException { + testUser = dataUser.createRandomTestUser("testUser"); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a public site and gets status code CREATED (201)") public void addManagerToPublicSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a moderated site and gets status code CREATED (201)") public void addManagerToModeratedSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that manager can add another user as manager to a private site and gets status code CREATED (201)") public void addManagerToPrivateSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser) - .assertThat().field("id").is(testUser.getUsername()) + memberModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + memberModel.assertThat().field("id").is(testUser.getUsername()) .and().field("role").is(testUser.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.CREATED); } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that consumer role is not able to add another user to a moderated site and gets status code 403") public void addUserByConsumerToModeratedSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @@ -93,7 +97,6 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that consumer role is not able to add another user to a private site and gets status code 403") public void addUserByConsumerToPrivateSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -103,9 +106,8 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that collaborator role is not able to add another user to a moderated site and gets status code 403") public void addUserByCollaboratorToModeratedSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @@ -113,7 +115,6 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that collaborator role is not able to add another user to a private site and gets status code 403") public void addUserByCollaboratorToPrivateSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteCollaborator)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -123,9 +124,8 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that contributor role is not able to add another user to a moderated site and gets status code 403") public void addUserByContributorToModeratedSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); - restClient.authenticateUser(usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); + restClient.authenticateUser(usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); } @@ -133,7 +133,6 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that contributor role is not able to add another user to a private site and gets status code 403") public void addUserByContributorToPrivateSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteConsumer); restClient.authenticateUser(usersWithRolesToPrivateSite.getOneUserWithRole(UserRole.SiteContributor)).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -143,9 +142,8 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that a user without specified role can not be added to a site and gets status code 400") public void canNotAddUserWithoutSpecifyingRoleToSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); restClient.authenticateUser(adminUserModel).withCoreAPI(); - String json = JsonBodyGenerator.keyValueJson("id",testUser.getUsername()); + String json = JsonBodyGenerator.keyValueJson("id", testUser.getUsername()); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); restClient.processModel(RestSiteMemberModel.class, request); restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.MUST_PROVIDE_ROLE); @@ -155,7 +153,6 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that a user with inexistent role can not be added to a site and gets status code 400") public void canNotAddUserWithInexistentRoleToSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); restClient.authenticateUser(adminUserModel).withCoreAPI(); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, String.format("{\"role\":\"inexistentRole\",\"id\":\"%s\"}", testUser.getUsername()), "sites/{siteId}/members?{parameters}", publicSiteModel.getId(), restClient.getParameters()); restClient.processModel(RestSiteMemberModel.class, request); @@ -164,9 +161,8 @@ public class AddSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not add himself as a manager to a public site and gets status code 403") - public void userAddHimselfToPublicSite() throws Exception + public void userAddHimselfAsManagerToPublicSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(testUser).withCoreAPI().usingSite(publicSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -174,9 +170,8 @@ public class AddSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not add himself as a manager to a moderated site and gets status code 403") - public void userAddHimselfToModeratedSite() throws Exception + public void userAddHimselfAsManagerToModeratedSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(testUser).withCoreAPI().usingSite(moderatedSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); @@ -184,9 +179,8 @@ public class AddSiteMemberCoreTests extends RestTest @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that user can not add himself as a manager to a private site and gets status code 404") - public void userAddHimselfToPrivateSite() throws Exception + public void userAddHimselfAsManagerToPrivateSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); restClient.authenticateUser(testUser).withCoreAPI().usingSite(privateSiteModel).addPerson(testUser); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSiteModel.getId())); @@ -196,7 +190,6 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that user can not be added to an inexistent site and gets status code 404") public void userIsNotAbleToAddUserToAnInexistentSite() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); SiteModel inexistentSite = new SiteModel("inexistentSite"); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); @@ -204,10 +197,9 @@ public class AddSiteMemberCoreTests extends RestTest } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to an empty site id and gets status code 404") - public void userIsNotAbleToAddUserToEmptySiteId() throws Exception + description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") + public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception { - UserModel testUser = dataUser.createRandomTestUser("testUser"); testUser.setUserRole(UserRole.SiteManager); SiteModel inexistentSite = new SiteModel(""); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); @@ -225,7 +217,7 @@ public class AddSiteMemberCoreTests extends RestTest } @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that inexistet user can not be added to site and gets status code 400") + description = "Verify that empty username can not be added to site and gets status code 400") public void userIsNotAbleToAddEmptyUserIdToSite() throws Exception { UserModel testUser = new UserModel("", "password"); @@ -238,7 +230,7 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that user can not add another user that is already a memeber and gets status code 409") public void userIsNotAbleToAddUserThatIsAlreadyAMember() throws Exception { - UserModel collaborator = usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteCollaborator); + UserModel collaborator = usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator); restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(moderatedSiteModel).addPerson(collaborator); restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); } @@ -277,8 +269,8 @@ public class AddSiteMemberCoreTests extends RestTest description = "Verify that several users that are already added to the site can not be added once in a row and gets status code 400") public void addSeveralUsersThatAreAlreadyAddedToASite() throws Exception { - UserModel collaborator = usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteCollaborator); - UserModel consumer = usersWithRolesToMoedratedSite.getOneUserWithRole(UserRole.SiteConsumer); + UserModel collaborator = usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteCollaborator); + UserModel consumer = usersWithRolesToModeratedSite.getOneUserWithRole(UserRole.SiteConsumer); restClient.authenticateUser(adminUserModel).withCoreAPI(); String json = String.format(addMembersJson, collaborator.getUserRole(), collaborator.getUsername(), consumer.getUserRole(), consumer.getUsername()); RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/members?{parameters}", moderatedSiteModel.getId(), restClient.getParameters()); @@ -286,4 +278,4 @@ public class AddSiteMemberCoreTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.CONFLICT).assertLastError().containsSummary(String.format(RestErrorModel.ALREADY_Site_MEMBER, collaborator.getUsername(), moderatedSiteModel.getId())); } -} +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java new file mode 100644 index 000000000..fcffac5d4 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainerCoreTests.java @@ -0,0 +1,105 @@ +package org.alfresco.rest.sites; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.ContainerName; +import org.alfresco.utility.model.SiteModel; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.CORE }) +public class GetSiteContainerCoreTests extends RestTest{ + + private UserModel adminUserModel, testUserModel; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + testUserModel = dataUser.createRandomTestUser(); + publicSiteModel = dataSite.usingAdmin().createPublicRandomSite(); + moderatedSiteModel = dataSite.usingAdmin().createModeratedRandomSite(); + privateSiteModel = dataSite.usingAdmin().createPrivateRandomSite(); + + dataLink.usingAdmin().usingSite(publicSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(publicSiteModel).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(moderatedSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(moderatedSiteModel).createRandomDiscussion(); + + dataLink.usingAdmin().usingSite(privateSiteModel).createRandomLink(); + dataDiscussion.usingAdmin().usingSite(privateSiteModel).createRandomDiscussion(); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when site doesn't exist") + public void getContainerWithNonExistentSite() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainer(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "NonExistentSiteId", ContainerName.discussions.toString())); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get container request returns status code 400 when container item doesn't exist") + public void getContainerWithNonExistentItem() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer("NonExistentFolder"); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, publicSiteModel.getId(), "NonExistentFolder")); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get container request returns status 200 for public site") + public void getContainerForPublicSite() throws Exception + { + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.authenticateUser(testUserModel) + .withCoreAPI().usingSite(publicSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get container request returns status 200 for private site") + public void getContainerForPrivateSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withCoreAPI().usingSite(privateSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get container request returns status 200 for moderated site") + public void getContainerForModeratedSite() throws Exception + { + restClient.authenticateUser(adminUserModel) + .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.discussions.toString()) + .assertThat().field("folderId").is(ContainerName.discussions.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(ContainerName.links.toString()) + .assertThat().field("folderId").is(ContainerName.links.toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java index 00ceb0d2d..aeac1f680 100644 --- a/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java +++ b/e2e-test/java/org/alfresco/rest/sites/GetSiteContainersCoreTests.java @@ -108,8 +108,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 when valid skipCount parameter is used") - public void getSitesWithValidSkipCount() throws Exception + description= "Verify if get site containers request returns status code 200 when valid skipCount parameter is used") + public void getSiteContainersWithValidSkipCount() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteManager)).withParams("skipCount=1") .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() @@ -133,8 +133,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") - public void getSitesWithSkipCountCharacter() throws Exception + description= "Verify if get site containers request returns status code 400 when invalid skipCount parameter is used") + public void getSiteContainersWithSkipCountCharacter() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=abc") .withCoreAPI().usingSite(publicSiteModel).getSiteContainers(); @@ -143,8 +143,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 200 when skipCount parameter starts with multiple zero") - public void getSitesWithSkipCountMultipleZero() throws Exception + description= "Verify if get site containers request returns status code 200 when skipCount parameter starts with multiple zero") + public void getSiteContainersWithSkipCountMultipleZero() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)).withParams("skipCount=00002") .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() @@ -154,8 +154,8 @@ public class GetSiteContainersCoreTests extends RestTest @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site container request returns status code 400 when invalid skipCount parameter is used") - public void getSiteContainerWithNonExistentSite() throws Exception + description= "Verify if get site containers request returns status code 400 when site doesn't exist") + public void getSiteContainersWithNonExistentSite() throws Exception { restClient.authenticateUser(publicSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator)) .withCoreAPI().usingSite("NonExistentSiteId").getSiteContainers(); @@ -164,8 +164,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for private site") - public void getSiteContainerForPrivateSite() throws Exception + description= "Verify get site containers request returns status 200 for private site") + public void getSiteContainersForPrivateSite() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(privateSiteModel).getSiteContainers() @@ -174,8 +174,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for moderated site") - public void getSiteContainerForModeratedSite() throws Exception + description= "Verify get site containers request returns status 200 for moderated site") + public void getSiteContainersForModeratedSite() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainers() @@ -184,8 +184,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for several containers") - public void getSiteContainerForSeveralItems() throws Exception + description= "Verify get site containers request returns status 200 for several containers") + public void getSiteContainersForSeveralItems() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(publicSiteWithContainers).getSiteContainers() @@ -197,8 +197,8 @@ public class GetSiteContainersCoreTests extends RestTest } @TestRail(section={TestGroup.REST_API, TestGroup.CORE, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site container request returns status 200 for one container") - public void getSiteContainerWithOneItem() throws Exception + description= "Verify get site containers request returns status 200 for one container") + public void getSiteContainersWithOneItem() throws Exception { restClient.authenticateUser(adminUserModel) .withCoreAPI().usingSite(publicSiteModel).getSiteContainers() diff --git a/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java new file mode 100644 index 000000000..3e494e552 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/tags/GetNodeTagsCoreTests.java @@ -0,0 +1,130 @@ +package org.alfresco.rest.tags; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +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.apache.commons.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE }) +public class GetNodeTagsCoreTests extends RestTest +{ + private UserModel adminUserModel, userModel; + private SiteModel siteModel; + private FileModel document; + private String tagValue; + private String tagValue2; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + userModel = dataUser.createRandomTestUser(); + adminUserModel = dataUser.getAdminUser(); + restClient.authenticateUser(adminUserModel); + siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite(); + + document = dataContent.usingSite(siteModel).usingUser(adminUserModel).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); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for skipCount parameter returns status code 400") + public void invalidSkipCountTest() throws JsonToModelConversionException, Exception + { + restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc")); + + restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid value for maxItems parameter returns status code 400") + public void invalidMaxItemsTest() throws JsonToModelConversionException, Exception + { + restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc")); + + restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that user without permissions returns status code 403") + public void userWithoutPermissionsTest() throws JsonToModelConversionException, Exception + { + SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite(); + FileModel document = dataContent.usingSite(site).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String tagValue = RandomData.getRandomName("tag"); + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(tagValue); + + restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node does not exist returns status code 403") + public void inexistentNodeTest() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + String nodeRef = RandomStringUtils.randomAlphanumeric(10); + document.setNodeRef(nodeRef); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify that if node id is empty returns status code 403") + public void emptyNodeIdTest() throws JsonToModelConversionException, Exception + { + FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + document.setNodeRef(""); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify file tags") + public void fileTagsTest() throws JsonToModelConversionException, Exception + { + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags() + .assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, + description = "Verify folder tags") + public void folderTagsTest() throws JsonToModelConversionException, Exception + { + FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder(); + + tagValue = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(folder).addTag(tagValue); + tagValue2 = RandomData.getRandomName("tag"); + restClient.withCoreAPI().usingResource(folder).addTag(tagValue2); + + restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags() + .assertThat() + .entriesListContains("tag", tagValue.toLowerCase()) + .and().entriesListContains("tag", tagValue2.toLowerCase()); + } +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java new file mode 100644 index 000000000..782030919 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageCoreTests.java @@ -0,0 +1,82 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessDefinitionModel; +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; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Created by Claudia Agache on 12/6/2016. + */ +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) +public class GetProcessDefinitionImageCoreTests extends RestTest +{ + private UserModel adminUser, adminTenantUser; + private RestProcessDefinitionModel randomProcessDefinition; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify if get process definition image returns status code 404 when invalid processDefinitionId is used") + public void getProcessDefinitionImageUsingInvalidProcessDefinitionId() throws Exception + { + restClient.authenticateUser(adminUser); + randomProcessDefinition = restClient.withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + randomProcessDefinition.onModel().setId("invalidID"); + + restClient.withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidID")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network admin is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + @Bug(id = "MNT-17243") + public void networkAdminGetProcessDefinitionImage() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getAllProcessDefinitions().getOneRandomEntry(); + restClient.withWorkflowAPI().usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, + executionType = ExecutionType.REGRESSION, + description = "Verify network user is able to get a process definition image using REST API and status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + @Bug(id = "MNT-17243") + public void networkUserGetProcessDefinitionImage() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + + UserModel tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + randomProcessDefinition = restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .getAllProcessDefinitions().getOneRandomEntry(); + restClient.authenticateUser(tenantUser).withWorkflowAPI() + .usingProcessDefinitions(randomProcessDefinition).getProcessDefinitionImage() + .assertResponseContainsImage(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java index bd531a421..ce1ab2d56 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionImageSanityTests.java @@ -2,12 +2,10 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.utility.data.DataUser; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -18,9 +16,6 @@ import org.testng.annotations.Test; @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.SANITY }) public class GetProcessDefinitionImageSanityTests extends RestTest { - @Autowired - private DataUser dataUser; - private UserModel testUser; private RestProcessDefinitionModel randomProcessDefinition; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java index 229a5c8e0..bef2437df 100644 --- a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionStartFormModelSanityTests.java @@ -2,12 +2,10 @@ package org.alfresco.rest.workflow.processDefinitions; import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestProcessDefinitionModel; -import org.alfresco.utility.data.DataUser; 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.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java new file mode 100644 index 000000000..072bf0c55 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processDefinitions/GetProcessDefinitionsCoreTests.java @@ -0,0 +1,79 @@ +package org.alfresco.rest.workflow.processDefinitions; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +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; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESS_DEFINITION, TestGroup.CORE }) +public class GetProcessDefinitionsCoreTests extends RestTest +{ + private UserModel adminUserModel; + private UserModel userModel; + private UserModel adminTenantUser; + private UserModel tenantUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUserModel = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + adminTenantUser = UserModel.getAdminTenantUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify any user gets process definitions for non-network deployments using REST API and status code is OK (200)") + public void nonNetworkUserGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(userModel) + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify get process definitions using any network user for network enabled deployments with REST API status code is OK (200)") + @Test(groups = { TestGroup.NETWORKS }) + public void networkUserGetsProcessDefinitions() throws Exception + { + restClient.authenticateUser(adminUserModel).usingTenant().createTenant(adminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + restClient.authenticateUser(tenantUser) + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsNotEmpty(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify call to get process definitions with invalid orderBy parameter with REST API and status code is BAD_REQUEST (400)") + public void userGetProcessDefinitionsWithInvalidOrderBy() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("orderBy=test") + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_ORDERBY, "test")); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESS_DEFINITION }, executionType = ExecutionType.REGRESSION, + description = "Verify call to get process definitions with invalid where parameter with REST API and status code is BAD_REQUEST (400)") + public void userGetProcessDefinitionsWithInvalidWhere() throws Exception + { + restClient.authenticateUser(userModel) + .withParams("where=test") + .withWorkflowAPI() + .getAllProcessDefinitions() + .assertThat().entriesListIsEmpty(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_DEFINITIONS_INVALID_WHERE, "test")); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java new file mode 100644 index 000000000..e1f7ff536 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/AddProcessVariableCoreTests.java @@ -0,0 +1,101 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessVariableModel; +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.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) +public class AddProcessVariableCoreTests extends RestTest +{ + private FileModel document; + private SiteModel siteModel; + private UserModel userWhoStartsTask, assignee, adminUser, adminTenantUser, secondAdminTenantUser, tenantUser; + private RestProcessModel processModel; + private RestProcessVariableModel variableModel, processVariable; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userWhoStartsTask).createPublicRandomSite(); + document = dataContent.usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN); + dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by admin in other network with REST API and status code is FORBIDDEN (403)") + @Test(groups = { TestGroup.NETWORKS }) + public void addProcessVariableByAdminInOtherNetworkIsForbidden() throws Exception + { + adminTenantUser = UserModel.getAdminTenantUser(); + secondAdminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser); + restClient.authenticateUser(adminUser).usingTenant().createTenant(secondAdminTenantUser); + tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant"); + + restClient.authenticateUser(adminTenantUser).withWorkflowAPI() + .addProcess("activitiAdhoc", tenantUser, false, CMISUtil.Priority.Normal); + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(adminTenantUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + restClient.authenticateUser(secondAdminTenantUser).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN) + .assertLastError().containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user with REST API and status code is CREATED (201)") + public void addProcessVariableByAnyUser() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + + processVariable = restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + processVariable.assertThat().field("name").is(variableModel.getName()) + .and().field("type").is(variableModel.getType()) + .and().field("value").is(variableModel.getValue()); + + restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables() + .assertThat().entriesListContains("name", processVariable.getName()); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for invalid processID with REST API and status code is NOT_FOUND (404)") + public void addProcessVariableForInvalidProcessIdIsNotFound() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId("invalidProcessID"); + + processVariable = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") + public void addProcessVariableForInvalidProcessIdIsEmpty() throws Exception + { + variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); + processModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); + processModel.setId(""); + + processVariable = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); + } +} diff --git a/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java new file mode 100644 index 000000000..1a35cd25b --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/processes/GetProcessCoreTests.java @@ -0,0 +1,96 @@ +package org.alfresco.rest.workflow.processes; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestProcessModel; +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.lang.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetProcessCoreTests extends RestTest +{ + private UserModel userWhoStartsProcess, assignee, adminUser; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsProcess = dataUser.createRandomTestUser(); + assignee = dataUser.createRandomTestUser(); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that using invalid process ID returns status code 404") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE}) + public void invalidProcessIdTest() throws Exception + { + RestProcessModel newProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); + String processId = RandomStringUtils.randomAlphanumeric(10); + newProcess.setId(processId); + restClient.authenticateUser(dataUser.getAdminUser()) + .withWorkflowAPI().usingProcess(newProcess).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processId)); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user cannot get process from another network") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Bug(id = "MNT-17238") + public void tenantUserCannotGetProcessFromAnotherNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + + UserModel adminTenantUser2 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser2); + + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + UserModel tenantUser2 = dataUser.usingUser(adminTenantUser2).createUserWithTenant("uTenant2"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + + restClient.authenticateUser(tenantUser2).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, + description = "Verify that tenant user can get process from the same network") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + public void tenantUserCanGetProcessFromTheSameNetwork() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + + restClient.authenticateUser(tenantUser1).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.OK); + networkProcess1.assertThat().field("id").is(networkProcess1.getId()) + .and().field("startUserId").is(networkProcess1.getStartUserId());; + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES, TestGroup.NETWORKS}, executionType = ExecutionType.REGRESSION, + description = "Verify that non network user cannot get process from a network") + @Test(groups = { TestGroup.WORKFLOW, TestGroup.CORE, TestGroup.NETWORKS }) + @Bug(id = "MNT-17238") + public void nonNetworkUserCannotAccessNetworkprocess() throws Exception + { + UserModel adminTenantUser1 = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser1); + UserModel tenantUser1 = dataUser.usingUser(adminTenantUser1).createUserWithTenant("uTenant1"); + + RestProcessModel networkProcess1 = restClient.authenticateUser(adminTenantUser1).withWorkflowAPI().addProcess("activitiReview", tenantUser1, false, CMISUtil.Priority.High); + + restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(networkProcess1).getProcess(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + +} \ No newline at end of file diff --git a/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java new file mode 100644 index 000000000..93f4e8c5d --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/workflow/tasks/AddTaskVariablesCoreTests.java @@ -0,0 +1,146 @@ +package org.alfresco.rest.workflow.tasks; + +import org.alfresco.dataprep.CMISUtil.DocumentType; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TaskModel; +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.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.CORE }) +public class AddTaskVariablesCoreTests extends RestTest +{ + private UserModel userWhoStartsTask, adminUser; + private SiteModel siteModel; + private FileModel fileModel; + private UserModel assigneeUser; + private TaskModel taskModel; + + private String taskId; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userWhoStartsTask = dataUser.createRandomTestUser(); + assigneeUser = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); + taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); + + taskId = taskModel.getId(); + restClient.authenticateUser(adminUser); + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid variableBody is provided") + public void failedAddingTaskVariableIfInvalidBodyIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:char"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case empty body type is provided") + public void failedAddingTaskVariableIfEmptyBodyIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("", ""); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body type is provided") + public void failedAddingTaskVariableIfIncompleteBodyIsProvided() throws Exception + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"name\": \"missingVariableScope\",\"value\": \"test\",\"type\": \"d:text\"}", + "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError() + .containsSummary("Variable scope is required and can only be 'local' or 'global'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case incomplete body - missing required: name type is provided") + public void failedAddingTaskVariableIfIncompleteRequiredBodyIsProvided() throws Exception + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "{\"scope\": \"local\",\"value\": \"missingVariableName\",\"type\": \"d:text\"}", + "tasks/{taskId}/variables", taskId); + restClient.processModel(RestVariableModel.class, request); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Variable name is required."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type is provided") + public void failedAddingTaskVariableIfInvalidTypeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:char"); + taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Unsupported type of variable: 'd:char'."); + + } + + @Bug(id = "ACE-5674") + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid type prefix is provided") + public void failedAddingTaskVariableIfInvalidTypePrefixIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("local", "ddm:text"); + taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Namespace prefix ddm is not mapped to a namespace URI"); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid scope is provided") + public void failedAddingTaskVariableIfInvalidScopeIsProvided() throws Exception + { + RestVariableModel invalidVariableModel = RestVariableModel.getRandomTaskVariableModel("instance", "d:text"); + taskModel.setId(taskId); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(invalidVariableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("Illegal value for variable scope: 'instance'."); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") + public void failedAddingTaskVariableIfInvalidTaskIdIsProvided() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text"); + taskModel.setId(taskModel.getId() + "TEST"); + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, taskModel.getId())); + + } + + @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Adding task variable is falling in case invalid task id is provided") + public void failedAddingTaskVariableIfInvalidValueIsProvided() throws Exception + { + RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:int"); + variableModel.setValue("invalidValue"); + + restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel); + + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary("For input string: \"invalidValue\""); + } +} diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index ca02e1224..beeaddbc1 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -1,17 +1,12 @@ # dataprep related alfresco.scheme=http -alfresco.server=172.29.100.215 -alfresco.port=8080 +alfresco.server=vsphered3.qa.internal.alfresco.com +alfresco.port=8070 # credentials admin.user=admin admin.password=admin -# rest related -rest.basePath=alfresco/api/-default-/public/alfresco/versions/1 -rest.workflowPath=alfresco/api/-default-/public/workflow/versions/1 - - # TEST MANAGEMENT SECTION - Test Rail # # (currently supporting Test Rail v5.2.1.3472 integration)