diff --git a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java index 6c25534c2..1e60b408a 100644 --- a/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java +++ b/e2e-test/java/org/alfresco/rest/people/AddSiteMembershipRequestFullTests.java @@ -16,6 +16,7 @@ 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.springframework.social.alfresco.api.entities.Site; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -49,7 +50,11 @@ public class AddSiteMembershipRequestFullTests extends RestTest restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingUser(newMember) .addSiteMembershipRequest(publicSite); restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())); + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, newMember.getUsername())) + .statusCodeIs(HttpStatus.NOT_FOUND) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE) + .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY); } @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) @@ -248,4 +253,36 @@ public class AddSiteMembershipRequestFullTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); siteMembershipRequests.assertThat().entriesListContains("id", anotherModeratedSite.getId()); } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL, TestGroup.NETWORKS }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify create site membership request returns status code 404 when personId is not member of the domain.") + public void addSiteMembershipRequestWhenPersonIdIsNotInTheDomain() throws Exception + { + UserModel adminTenantUser = UserModel.getAdminTenantUser(); + restClient.authenticateUser(adminUser) + .usingTenant().createTenant(adminTenantUser); + restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().addSiteMembershipRequest(publicSite); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, adminTenantUser.getUsername().toLowerCase(), publicSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify site membership request is automatically rejected when a site is switched from moderated to private") + public void siteMembershipRequestIsRejectedWhenSiteIsSwitchedFromModeratedToPrivate() throws Exception + { + regularUser = dataUser.createRandomTestUser(); + SiteModel moderatedThenPrivateSite = dataSite.usingUser(adminUser).createModeratedRandomSite(); + siteMembershipRequest = restClient.authenticateUser(regularUser).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedThenPrivateSite); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + siteMembershipRequest.assertThat().field("id").is(moderatedThenPrivateSite.getId()) + .assertThat().field("site").isNotEmpty(); + + dataSite.usingUser(adminUser).updateSiteVisibility(moderatedThenPrivateSite, Site.Visibility.PRIVATE); + + siteMembershipRequests = restClient.withCoreAPI().usingAuthUser().getSiteMembershipRequests(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembershipRequests.assertThat().entriesListIsEmpty(); + } } diff --git a/e2e-test/resources/default.properties b/e2e-test/resources/default.properties index f5733caf1..6d12861d7 100644 --- a/e2e-test/resources/default.properties +++ b/e2e-test/resources/default.properties @@ -3,6 +3,10 @@ alfresco.scheme=http alfresco.server=localhost alfresco.port=8080 +# in containers we cannot access directly JMX, so we will use http://jolokia.org agent +# disabling this we will use direct JMX calls to server +jmx.useJolokiaAgent=false + # credentials admin.user=admin admin.password=admin @@ -34,10 +38,6 @@ testManagement.suiteId=12 # The location of the reports path reports.path=./target/reports -# in containers we cannot access directly JMX, so we will use http://jolokia.org agent -# disabling this we will use direct JMX calls to server -jmx.useJolokiaAgent=true - # # Database Section # You should provide here the database URL, that can be a differed server as alfresco. diff --git a/e2e-test/resources/log4j.properties b/e2e-test/resources/log4j.properties index 63d3970dc..ede92a004 100644 --- a/e2e-test/resources/log4j.properties +++ b/e2e-test/resources/log4j.properties @@ -12,4 +12,15 @@ log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n \ No newline at end of file +log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +# TestRail particular log file +# Direct log messages to a log file +log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender +log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log +log4j.appender.testrailLog.MaxBackupIndex=10 +log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout +log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.category.testrail=INFO, testrailLog +log4j.additivity.testrail=false \ No newline at end of file