mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-9023 Implement PUT method - Preferences API (#3075)
* ACS-9023 Implement PUT method - Preferences API * ACS-9023 Fix testUserPreferences * ACS-9023 Add override * ACS-9023 Update license header
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -29,6 +29,12 @@ import static io.restassured.RestAssured.given;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import org.alfresco.rest.core.JsonBodyGenerator;
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
@@ -56,12 +62,6 @@ import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
|
||||
/**
|
||||
* Declares all Rest API under the /people path
|
||||
@@ -97,9 +97,7 @@ public class People extends ModelRequest<People>
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve list of activities for a specific person using GET call on "people/{personId}/activities"
|
||||
* Please note that it retries to get the list of activities several times before returning the empty list. The list of activities are not displayed as
|
||||
* they are created.
|
||||
* Retrieve list of activities for a specific person using GET call on "people/{personId}/activities" Please note that it retries to get the list of activities several times before returning the empty list. The list of activities are not displayed as they are created.
|
||||
*/
|
||||
public RestActivityModelsCollection getPersonActivitiesUntilEntriesCountIs(int expectedNoOfEntries)
|
||||
{
|
||||
@@ -173,6 +171,15 @@ public class People extends ModelRequest<People>
|
||||
return restWrapper.processModel(RestPreferenceModel.class, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a specific preference of a specific person using PUT call on "people/{personId}/preferences/{preferenceName}"
|
||||
*/
|
||||
public RestPreferenceModel updatePersonPreferenceInformation(String preferenceName, RestPreferenceModel preferenceModel)
|
||||
{
|
||||
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, preferenceModel.toJson(), "people/{personId}/preferences/{preferenceName}", this.person.getUsername(), preferenceName);
|
||||
return restWrapper.processModel(RestPreferenceModel.class, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a specific site from favorite sites list of a person using DELETE call on "people/{personId}/favorite-sites/{siteId}"
|
||||
*/
|
||||
@@ -334,7 +341,7 @@ public class People extends ModelRequest<People>
|
||||
*/
|
||||
public RestWrapper deleteSiteFromFavorites(SiteModel site)
|
||||
{
|
||||
RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "people/{personId}/favorites/{favoriteId}", this.person.getUsername(), site.getGuid());
|
||||
RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "people/{personId}/favorites/{favoriteId}", this.person.getUsername(), site.getGuid());
|
||||
restWrapper.processEmptyModel(request);
|
||||
return restWrapper;
|
||||
}
|
||||
@@ -379,7 +386,7 @@ public class People extends ModelRequest<People>
|
||||
public RestNetworkModel getNetwork(UserModel tenant)
|
||||
{
|
||||
Utility.checkObjectIsInitialized(tenant.getDomain(), "tenant.getDomain()");
|
||||
String personId = tenant.getUsername().contains("-me-@")? "-me-" : tenant.getUsername();
|
||||
String personId = tenant.getUsername().contains("-me-@") ? "-me-" : tenant.getUsername();
|
||||
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/networks/{networkId}?{parameters}", personId, tenant.getDomain(), restWrapper.getParameters());
|
||||
return restWrapper.processModel(RestNetworkModel.class, request);
|
||||
}
|
||||
@@ -410,10 +417,9 @@ public class People extends ModelRequest<People>
|
||||
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, newPerson.toJson(), "people");
|
||||
return restWrapper.processModel(RestPersonModel.class, request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get people avatar image using GET call on '/people/{personId}/avatar Please note that it retries to get the
|
||||
* renditions response several times because on the alfresco server the rendition can take a while to be created.
|
||||
* Get people avatar image using GET call on '/people/{personId}/avatar Please note that it retries to get the renditions response several times because on the alfresco server the rendition can take a while to be created.
|
||||
*/
|
||||
public RestResponse downloadAvatarContent()
|
||||
{
|
||||
@@ -456,17 +462,8 @@ public class People extends ModelRequest<People>
|
||||
return new WhereClause(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the Where clause of getFavorites
|
||||
* You can use the where parameter to restrict the list in the response to entries of a specific kind. The where parameter takes a value. The value is a
|
||||
* single predicate that can include one or more EXISTS conditions. The EXISTS condition uses a single operand to limit the list to include entries that
|
||||
* include that one property. The property values are:-
|
||||
* target/file
|
||||
* target/folder
|
||||
* target/site
|
||||
* Usage:
|
||||
* where.. targetFileExist().or().targetSiteExist().filterAnd().getFavorites(...)
|
||||
* At this point this method is working only with @link {@link RestFavoritesApi#getFavorites(UserModel) method.
|
||||
/**
|
||||
* Construct the Where clause of getFavorites You can use the where parameter to restrict the list in the response to entries of a specific kind. The where parameter takes a value. The value is a single predicate that can include one or more EXISTS conditions. The EXISTS condition uses a single operand to limit the list to include entries that include that one property. The property values are:- target/file target/folder target/site Usage: where.. targetFileExist().or().targetSiteExist().filterAnd().getFavorites(...) At this point this method is working only with @link {@link RestFavoritesApi#getFavorites(UserModel) method.
|
||||
*
|
||||
* @author paul.brodner
|
||||
*/
|
||||
|
@@ -1,5 +1,11 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestPreferenceModel;
|
||||
@@ -9,11 +15,6 @@ 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;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class GetPeoplePreferenceFullTests extends RestTest
|
||||
{
|
||||
@@ -29,53 +30,53 @@ public class GetPeoplePreferenceFullTests extends RestTest
|
||||
dataSite.usingUser(userModel).usingSite(siteModel).addSiteToFavorites();
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Check that properties parameter is applied")
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Check that properties parameter is applied")
|
||||
public void propertiesParameterIsAppliedWhenRetrievingPreference() throws Exception
|
||||
{
|
||||
restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id").withCoreAPI().usingUser(userModel)
|
||||
.getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId()));
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId()))
|
||||
.and().field("value").isNull();
|
||||
|
||||
.and().field("value").isNull();
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(userModel).withParams("properties=id,value").withCoreAPI().usingUser(userModel)
|
||||
.getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId()));
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId()))
|
||||
.and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Validate ID element in get site preference response")
|
||||
.and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Validate ID element in get site preference response")
|
||||
public void validateIdElementInGetSitePreferenceResponse() throws Exception
|
||||
{
|
||||
restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId()));
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId()))
|
||||
.and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Validate ID element in get folder preference response")
|
||||
.and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Validate ID element in get folder preference response")
|
||||
public void validateIdElementInGetFolderPreferenceResponse() throws Exception
|
||||
{
|
||||
FolderModel folderFavorite = new FolderModel("favoriteFolder");
|
||||
folderFavorite = dataContent.usingSite(siteModel).createFolder(folderFavorite);
|
||||
dataContent.getContentActions().setFolderAsFavorite(userModel.getUsername(), userModel.getPassword(), siteModel.getId(), folderFavorite.getName());
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString());
|
||||
restPreferenceModel.assertThat().field("id").is(PreferenceName.FOLDERS_FAVORITES_PREFIX)
|
||||
.and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", folderFavorite.getNodeRef())));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Validate ID element in get file preference response")
|
||||
.and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", folderFavorite.getNodeRef())));
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Validate ID element in get file preference response")
|
||||
public void validateIdElementInGetFilePreferenceResponse() throws Exception
|
||||
{
|
||||
FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN);
|
||||
@@ -85,86 +86,86 @@ public class GetPeoplePreferenceFullTests extends RestTest
|
||||
restPreferenceModel = restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString());
|
||||
restPreferenceModel.assertThat().field("id").is(PreferenceName.DOCUMENTS_FAVORITES_PREFIX)
|
||||
.and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", fileFavorite.getNodeRefWithoutVersion())));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Get preference of an user that has no preferences")
|
||||
.and().field("value").is(Utility.removeLastSlash(Utility.buildPath("workspace://SpacesStore", fileFavorite.getNodeRefWithoutVersion())));
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Get preference of an user that has no preferences")
|
||||
public void getPreferenceForUserWithoutPreferences() throws Exception
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser();
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString());
|
||||
restClient.assertLastError().containsSummary(
|
||||
String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(),
|
||||
PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()));
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString());
|
||||
restClient.assertLastError().containsSummary(
|
||||
String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(),
|
||||
PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()));
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString());
|
||||
restClient.assertLastError().containsSummary(
|
||||
String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(),
|
||||
PreferenceName.SITES_FAVORITES_PREFIX.toString()));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Change one preference for an user then perform get call")
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Change one preference for an user then perform get call")
|
||||
@Bug(id = "REPO-1922")
|
||||
public void changePreferenceThenPerformGetPreferenceCall() throws Exception
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser();
|
||||
SiteModel site = dataSite.usingUser(newUser).createPublicRandomSite();
|
||||
|
||||
|
||||
dataSite.usingUser(newUser).usingSite(site).addSiteToFavorites();
|
||||
|
||||
|
||||
FileModel fileFavorite = new FileModel("favoriteFile", FileType.TEXT_PLAIN);
|
||||
fileFavorite = dataContent.usingSite(site).createContent(fileFavorite);
|
||||
dataContent.getContentActions().setFileAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), String.format("%s.%s", fileFavorite.getName(), fileFavorite.getFileType().extension));
|
||||
|
||||
|
||||
FolderModel folderFavorite = new FolderModel("favoriteFolder");
|
||||
folderFavorite = dataContent.usingSite(site).createFolder(folderFavorite);
|
||||
dataContent.getContentActions().setFolderAsFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName());
|
||||
|
||||
|
||||
dataSite.usingUser(newUser).usingSite(site).removeSiteFromFavorites();
|
||||
dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), folderFavorite.getName());
|
||||
dataContent.getContentActions().removeFavorite(newUser.getUsername(), newUser.getPassword(), site.getId(), Paths.get(fileFavorite.getCmisLocation()).getFileName().toString());
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString());
|
||||
restClient.assertLastError().containsSummary(
|
||||
String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(),
|
||||
PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()));
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX.toString());
|
||||
restClient.assertLastError().containsSummary(
|
||||
String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(),
|
||||
PreferenceName.SITES_FAVORITES_PREFIX.toString()));
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString());
|
||||
restClient.assertLastError().containsSummary(
|
||||
String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(),
|
||||
PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString()));
|
||||
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(PreferenceName.FOLDERS_FAVORITES_PREFIX.toString());
|
||||
restClient.assertLastError().containsSummary(
|
||||
String.format("The relationship resource was not found for the" + " entity with id: %s and a relationship id of %s", newUser.getUsername(),
|
||||
PreferenceName.FOLDERS_FAVORITES_PREFIX.toString()));
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is able to get preference of another user")
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is able to get preference of another user")
|
||||
public void adminIsAbleToGetOtherUserPreference() throws Exception
|
||||
{
|
||||
restPreferenceModel = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(userModel)
|
||||
@@ -172,18 +173,62 @@ public class GetPeoplePreferenceFullTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify regular user is not able to get preference of admin user")
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify regular user is not able to get preference of admin user")
|
||||
public void regularUserIsNotAbleToGetAdminPreference() throws Exception
|
||||
{
|
||||
SiteModel newSite = dataSite.usingUser(dataUser.getAdminUser()).createPublicRandomSite();
|
||||
dataSite.usingUser(dataUser.getAdminUser()).usingSite(newSite).addSiteToFavorites();
|
||||
|
||||
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingUser(dataUser.getAdminUser())
|
||||
.getPersonPreferenceInformation(PreferenceName.SITES_FAVORITES_PREFIX + newSite.getId());
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
restClient.assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify regular user is able to change own preferences")
|
||||
public void regularUserIsAbleToChangeOwnPreference() throws Exception
|
||||
{
|
||||
var newUser = dataUser.createRandomTestUser();
|
||||
var newSite = dataSite.usingUser(newUser).createPublicRandomSite();
|
||||
var preferenceId = String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), newSite.getId());
|
||||
var updatedPreferenceModel = new RestPreferenceModel();
|
||||
updatedPreferenceModel.setId(preferenceId);
|
||||
updatedPreferenceModel.setValue("");
|
||||
|
||||
dataSite.usingUser(newUser).usingSite(newSite).addSiteToFavorites();
|
||||
restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(preferenceId);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser().updatePersonPreferenceInformation(preferenceId, updatedPreferenceModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
var personPreferences = restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser().getPersonPreferences();
|
||||
personPreferences.assertThat().entriesListDoesNotContain("id", preferenceId);
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.REGRESSION})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is not able to change regular user preferences")
|
||||
public void adminIsNotAbleToChangeRegularUserPreference() throws Exception
|
||||
{
|
||||
var newUser = dataUser.createRandomTestUser();
|
||||
var newSite = dataSite.usingUser(newUser).createPublicRandomSite();
|
||||
var preferenceId = String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), newSite.getId());
|
||||
var updatedPreferenceModel = new RestPreferenceModel();
|
||||
updatedPreferenceModel.setId(preferenceId);
|
||||
updatedPreferenceModel.setValue("");
|
||||
|
||||
dataSite.usingUser(newUser).usingSite(newSite).addSiteToFavorites();
|
||||
restClient.authenticateUser(newUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(preferenceId);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(newUser).updatePersonPreferenceInformation(preferenceId, updatedPreferenceModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,10 @@
|
||||
package org.alfresco.rest.people.preferences;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestPreferenceModel;
|
||||
import org.alfresco.utility.constants.PreferenceName;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
@@ -10,9 +13,6 @@ 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;
|
||||
|
||||
/**
|
||||
* Tests for Get a Peference (/people/{personId}/preferences/{preferenceName}) RestAPI call
|
||||
@@ -33,8 +33,8 @@ public class GetPeoplePreferenceSanityTests extends RestTest
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)")
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.SANITY, description = "Verify manager user gets a specific preference with Rest API and response is successful (200)")
|
||||
public void managerUserGetsAPreferenceWithSuccess() throws Exception
|
||||
{
|
||||
UserModel managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
@@ -47,8 +47,8 @@ public class GetPeoplePreferenceSanityTests extends RestTest
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)")
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)")
|
||||
public void collaboratorUserGetsAPreferenceWithSuccess() throws Exception
|
||||
{
|
||||
UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
@@ -61,8 +61,24 @@ public class GetPeoplePreferenceSanityTests extends RestTest
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)")
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.SANITY, description = "Verify collaborator user gets a specific preference with Rest API and response is successful (200)")
|
||||
public void collaboratorUserUpdatesAPreferenceWithSuccess() throws Exception
|
||||
{
|
||||
UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
|
||||
var updatedRestPreferenceModel = new RestPreferenceModel();
|
||||
updatedRestPreferenceModel.setId("user.preference");
|
||||
updatedRestPreferenceModel.setValue("user.value");
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(collaboratorUser).withCoreAPI().usingAuthUser()
|
||||
.updatePersonPreferenceInformation(updatedRestPreferenceModel.getId(), updatedRestPreferenceModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restPreferenceModel.assertThat().field("id").is("user.preference").and().field("value").is("user.value");
|
||||
}
|
||||
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.SANITY, description = "Verify contributor user gets a specific preference with Rest API and response is successful (200)")
|
||||
public void contributorUserGetsAPreferenceWithSuccess() throws Exception
|
||||
{
|
||||
UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
@@ -75,8 +91,8 @@ public class GetPeoplePreferenceSanityTests extends RestTest
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY })
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.PEOPLE, TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)")
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.SANITY, description = "Verify consumer user gets a specific preference with Rest API and response is successful (200)")
|
||||
public void consumerUserGetsAPreferenceWithSuccess() throws Exception
|
||||
{
|
||||
UserModel consumerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
@@ -84,13 +100,13 @@ public class GetPeoplePreferenceSanityTests extends RestTest
|
||||
dataSite.usingUser(consumerUser).usingSite(siteModel).addSiteToFavorites();
|
||||
|
||||
restPreferenceModel = restClient.authenticateUser(consumerUser).withCoreAPI().usingAuthUser()
|
||||
.getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId()));
|
||||
.getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId()));
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(),siteModel.getId())).and().field("value").is("true");
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)")
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.SANITY, description = "Verify admin user gets a specific preference with Rest API and response is successful (200)")
|
||||
public void adminUserGetsAPreferenceWithSuccess() throws Exception
|
||||
{
|
||||
UserModel adminUser = dataUser.getAdminUser();
|
||||
@@ -102,9 +118,9 @@ public class GetPeoplePreferenceSanityTests extends RestTest
|
||||
restPreferenceModel.assertThat().field("id").is(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), siteModel.getId())).and().field("value").is("true");
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE,TestGroup.PREFERENCES }, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)")
|
||||
// @Bug(id = "MNT-16904", description = "fails only on environment with tenants")
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES, TestGroup.SANITY})
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.PREFERENCES}, executionType = ExecutionType.SANITY, description = "Verify manager user is NOT Authorized to get a specific preference with Rest API when authentication fails (401)")
|
||||
// @Bug(id = "MNT-16904", description = "fails only on environment with tenants")
|
||||
public void managerUserNotAuthorizedFailsToGetsAPreference() throws Exception
|
||||
{
|
||||
UserModel managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
|
Reference in New Issue
Block a user