ACS-9178 Add REST API for deauthorizing (#3169)

* ACS-9178 Set peopleEntityResource bean id

* ACS-9178 Add the 'deauthorizeUser' operation

* ACS-9178 Add 'deauthorizeUser' to Rest API

* ACS-9178 Add test

* ACS-9178 Fix PMD

* ACS-9178 Fix deauthorize API tests

---------

Co-authored-by: Gerard Olenski <gerard.olenski@hyland.com>
This commit is contained in:
Damian Ujma
2025-01-30 11:07:57 +01:00
committed by GitHub
parent 6804d5e288
commit 733e232e42
4 changed files with 299 additions and 236 deletions

View File

@@ -437,6 +437,15 @@ public class People extends ModelRequest<People>
restWrapper.processEmptyModel(request);
}
/**
* Deauthorize a user
*/
public void deauthorizeUser()
{
RestRequest request = RestRequest.simpleRequest(HttpMethod.POST, "people/{personId}/deauthorize", this.person.getUsername(), restWrapper.getParameters());
restWrapper.processEmptyModel(request);
}
/**
* Update avatar image PUT call on 'people/{nodeId}/children
*/
@@ -514,4 +523,4 @@ public class People extends ModelRequest<People>
return people.getFavorites();
}
}
}
}

View File

@@ -0,0 +1,40 @@
package org.alfresco.rest.people.deauthorization.community;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.alfresco.rest.RestTest;
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;
/**
* Verifies API behavior in community edition. Should be excluded in enterprise edition.
*/
@Test
public class DeauthorizeSanityTests extends RestTest
{
private UserModel userModel;
private UserModel adminUser;
@BeforeClass(alwaysRun = true)
public void dataPreparation()
{
adminUser = dataUser.getAdminUser();
userModel = dataUser.createRandomTestUser();
}
@Test(groups = {TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.SANITY})
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE}, executionType = ExecutionType.SANITY,
description = "Check if de-authorization is not implemented in Community Edition")
public void deauthorizationIsNotImplementedInCommunityEdition()
{
restClient.authenticateUser(adminUser).withCoreAPI().usingUser(userModel).deauthorizeUser();
restClient.assertStatusCodeIs(HttpStatus.NOT_IMPLEMENTED);
restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).deauthorizeUser();
restClient.assertStatusCodeIs(HttpStatus.NOT_IMPLEMENTED);
}
}