diff --git a/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java new file mode 100644 index 000000000..5b6276d24 --- /dev/null +++ b/e2e-test/java/org/alfresco/rest/people/AvatarPeopleSanityTest.java @@ -0,0 +1,61 @@ +package org.alfresco.rest.people; + +import java.io.File; + +import org.alfresco.rest.RestTest; +import org.alfresco.utility.Utility; +import org.alfresco.utility.exception.DataPreparationException; +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; + +import com.jayway.restassured.response.ValidatableResponse; + +import junit.framework.Assert; + +public class AvatarPeopleSanityTest extends RestTest +{ + + private UserModel userModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + userModel = dataUser.createRandomTestUser(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Update Avatar for People") + public void updateGetAvatarForPeople() throws Exception + { + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + ValidatableResponse response = restClient.withCoreAPI().usingAuthUser() + .uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.OK); + Assert.assertNotNull(response.extract().body().asByteArray()); + Assert.assertTrue("Avatar Image not uploaded", response.extract().body().asByteArray().length > 0); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.SANITY, description = "Remove Avatar for People") + public void removeGetAvatarForPeople() throws Exception + { + File avatarFile = Utility.getResourceTestDataFile("avatar.jpg"); + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().uploadAvatarContent(restProperties.envProperty().getFullServerUrl(), avatarFile).statusCode(200); + + restClient.authenticateUser(userModel); + restClient.withCoreAPI().usingAuthUser().resetAvatarImageRequest(); + restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + restClient.authenticateUser(userModel).withCoreAPI().usingAuthUser().downloadAvatarContent(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND); + } + +}