mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
REPO-2632: REST-API: Enable/Disable Application Auditing - add TAS level test
This commit is contained in:
@@ -6,10 +6,12 @@ import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.model.RestAuditAppModel;
|
||||
import org.alfresco.rest.model.RestAuditAppModelsCollection;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
||||
import com.jayway.restassured.RestAssured;
|
||||
@@ -22,6 +24,9 @@ public abstract class AuditTest extends RestTest
|
||||
|
||||
protected UserModel userModel;
|
||||
protected RestAuditAppModelsCollection restAuditCollection;
|
||||
protected RestAuditAppModel syncRestAuditAppModel;
|
||||
protected RestAuditAppModel taggingRestAuditAppModel;
|
||||
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
@@ -33,4 +38,23 @@ public abstract class AuditTest extends RestTest
|
||||
RestResponse response = restAPI.authenticateUser(dataUser.getAdminUser()).process(request);
|
||||
response.assertThat().body("enabled", is(true));
|
||||
}
|
||||
|
||||
protected RestAuditAppModel getSyncRestAuditAppModel(UserModel userModel) throws Exception
|
||||
{
|
||||
restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restAuditCollection.assertThat().entriesListIsNotEmpty();
|
||||
RestAuditAppModel syncRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel();
|
||||
return syncRestAuditAppModel;
|
||||
}
|
||||
|
||||
protected RestAuditAppModel getTaggingRestAuditAppModel(UserModel userModel) throws Exception
|
||||
{
|
||||
restAuditCollection = restClient.authenticateUser(userModel).withCoreAPI().usingAudit().getAuditApplications();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restAuditCollection.assertThat().entriesListIsNotEmpty();
|
||||
RestAuditAppModel taggingRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel();
|
||||
return taggingRestAuditAppModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.alfresco.rest.audit;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.alfresco.rest.model.RestAuditAppModel;
|
||||
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
@@ -25,40 +25,18 @@ public class GetAuditCoreTests extends AuditTest
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify if the admin user gets audit application info")
|
||||
TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can get audit application info")
|
||||
public void getAuditApplicationInfoWithAdminUser() throws Exception
|
||||
{
|
||||
restAuditCollection = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().getAuditApplications();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restAuditCollection.assertThat().entriesListIsNotEmpty();
|
||||
|
||||
RestAuditAppModel firstRestAuditAppModel = restAuditCollection.getEntries().get(0).onModel();
|
||||
firstRestAuditAppModel.assertThat().field("isEnabled").is(true);
|
||||
firstRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service");
|
||||
firstRestAuditAppModel.assertThat().field("id").is("sync");
|
||||
syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser());
|
||||
syncRestAuditAppModel.assertThat().field("isEnabled").is(true);
|
||||
syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service");
|
||||
syncRestAuditAppModel.assertThat().field("id").is("sync");
|
||||
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit()
|
||||
.getAuditApp(firstRestAuditAppModel).assertThat().field("isEnabled").is(true);
|
||||
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit()
|
||||
.getAuditApp(firstRestAuditAppModel).assertThat().field("name").is("Alfresco Sync Service");
|
||||
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit()
|
||||
.getAuditApp(firstRestAuditAppModel).assertThat().field("id").is("sync");
|
||||
|
||||
RestAuditAppModel secondRestAuditAppModel = restAuditCollection.getEntries().get(1).onModel();
|
||||
secondRestAuditAppModel.assertThat().field("isEnabled").is(true);
|
||||
secondRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service");
|
||||
secondRestAuditAppModel.assertThat().field("id").is("tagging");
|
||||
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit()
|
||||
.getAuditApp(secondRestAuditAppModel).assertThat().field("isEnabled").is(true);
|
||||
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit()
|
||||
.getAuditApp(secondRestAuditAppModel).assertThat().field("name").is("Alfresco Tagging Service");
|
||||
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit()
|
||||
.getAuditApp(secondRestAuditAppModel).assertThat().field("id").is("tagging");
|
||||
taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser());
|
||||
taggingRestAuditAppModel.assertThat().field("isEnabled").is(true);
|
||||
taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service");
|
||||
taggingRestAuditAppModel.assertThat().field("id").is("tagging");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,103 @@
|
||||
package org.alfresco.rest.audit;
|
||||
|
||||
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 PutAuditCoreTests extends AuditTest
|
||||
{
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable sync application auditing")
|
||||
public void enableDisableSyncApplicationAuditingAsAdminUser() throws Exception
|
||||
{
|
||||
//disable sync audit app
|
||||
syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser());
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false");
|
||||
|
||||
//check isEnabled=false
|
||||
syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser());
|
||||
syncRestAuditAppModel.assertThat().field("isEnabled").is(false);
|
||||
syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service");
|
||||
syncRestAuditAppModel.assertThat().field("id").is("sync");
|
||||
|
||||
//enable sync audit app
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true");
|
||||
|
||||
//check isEnabled=true
|
||||
syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser());
|
||||
syncRestAuditAppModel.assertThat().field("isEnabled").is(true);
|
||||
syncRestAuditAppModel.assertThat().field("name").is("Alfresco Sync Service");
|
||||
syncRestAuditAppModel.assertThat().field("id").is("sync");
|
||||
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the admin user can enable/disable tagging application auditing")
|
||||
public void enableDisableTaggingApplicationAuditingAsAdminUser() throws Exception
|
||||
{
|
||||
//disable tagging audit app
|
||||
taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser());
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false");
|
||||
|
||||
//check isEnabled=false
|
||||
taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser());
|
||||
taggingRestAuditAppModel.assertThat().field("isEnabled").is(false);
|
||||
taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service");
|
||||
taggingRestAuditAppModel.assertThat().field("id").is("tagging");
|
||||
|
||||
//enable tagging audit app
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true");
|
||||
|
||||
//check isEnabled=true
|
||||
taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser());
|
||||
taggingRestAuditAppModel.assertThat().field("isEnabled").is(true);
|
||||
taggingRestAuditAppModel.assertThat().field("name").is("Alfresco Tagging Service");
|
||||
taggingRestAuditAppModel.assertThat().field("id").is("tagging");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable sync application auditing")
|
||||
public void enableDisableSyncApplicationAuditingAsNormalUser() throws Exception
|
||||
{
|
||||
//disable sync audit app
|
||||
syncRestAuditAppModel = getSyncRestAuditAppModel(dataUser.getAdminUser());
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "false");
|
||||
|
||||
//permission denied
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
|
||||
//enable sync audit app
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(syncRestAuditAppModel, "isEnabled", "true");
|
||||
|
||||
//permission denied
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.AUDIT, TestGroup.CORE })
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.AUDIT }, executionType = ExecutionType.SANITY, description = "Verify that the normal user can't enable/disable tagging application auditing")
|
||||
public void enableDisableTaggingApplicationAuditingAsNormalUser() throws Exception
|
||||
{
|
||||
//disable tagging audit app
|
||||
taggingRestAuditAppModel = getTaggingRestAuditAppModel(dataUser.getAdminUser());
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "false");
|
||||
|
||||
//permission denied
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
|
||||
//disable tagging audit app
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingAudit().updateAuditApp(taggingRestAuditAppModel, "isEnabled", "true");
|
||||
|
||||
//permission denied
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user