mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -437,6 +437,15 @@ public class People extends ModelRequest<People>
|
|||||||
restWrapper.processEmptyModel(request);
|
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
|
* Update avatar image PUT call on 'people/{nodeId}/children
|
||||||
*/
|
*/
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2023 Alfresco Software Limited
|
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -28,9 +28,10 @@ package org.alfresco.rest.api.people;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.rest.api.People;
|
import org.alfresco.rest.api.People;
|
||||||
import org.alfresco.rest.api.model.Client;
|
import org.alfresco.rest.api.model.Client;
|
||||||
@@ -53,9 +54,6 @@ import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
|||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of an Entity Resource for a Person
|
* An implementation of an Entity Resource for a Person
|
||||||
@@ -69,8 +67,6 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById<Perso
|
|||||||
|
|
||||||
BinaryResourceAction.Read, BinaryResourceAction.Update<Person>, BinaryResourceAction.Delete, InitializingBean
|
BinaryResourceAction.Read, BinaryResourceAction.Update<Person>, BinaryResourceAction.Delete, InitializingBean
|
||||||
{
|
{
|
||||||
private static Log logger = LogFactory.getLog(PeopleEntityResource.class);
|
|
||||||
|
|
||||||
private People people;
|
private People people;
|
||||||
|
|
||||||
public void setPeople(People people)
|
public void setPeople(People people)
|
||||||
@@ -186,7 +182,8 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById<Perso
|
|||||||
* Download avatar image content
|
* Download avatar image content
|
||||||
*
|
*
|
||||||
* @param personId
|
* @param personId
|
||||||
* @param parameters {@link Parameters}
|
* @param parameters
|
||||||
|
* {@link Parameters}
|
||||||
* @return
|
* @return
|
||||||
* @throws EntityNotFoundException
|
* @throws EntityNotFoundException
|
||||||
*/
|
*/
|
||||||
@@ -202,8 +199,10 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById<Perso
|
|||||||
* Upload avatar image content
|
* Upload avatar image content
|
||||||
*
|
*
|
||||||
* @param personId
|
* @param personId
|
||||||
* @param contentInfo Basic information about the content stream
|
* @param contentInfo
|
||||||
* @param stream An inputstream
|
* Basic information about the content stream
|
||||||
|
* @param stream
|
||||||
|
* An inputstream
|
||||||
* @param parameters
|
* @param parameters
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -230,5 +229,20 @@ public class PeopleEntityResource implements EntityResourceAction.ReadById<Perso
|
|||||||
people.deleteAvatarContent(personId);
|
people.deleteAvatarContent(personId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De-authorize user
|
||||||
|
*
|
||||||
|
* Not currently supported in community edition.
|
||||||
|
*
|
||||||
|
* @param personId
|
||||||
|
* @param body
|
||||||
|
* @param parameters
|
||||||
|
* @param withResponse
|
||||||
|
*/
|
||||||
|
@Operation("deauthorize")
|
||||||
|
@WebApiDescription(title = "De-authorize user", description = "Performs user de-authorization", successStatus = HttpServletResponse.SC_NOT_IMPLEMENTED)
|
||||||
|
public void deauthorizeUser(String personId, Void body, Parameters parameters, WithResponse withResponse)
|
||||||
|
{
|
||||||
|
// functionality is not implemented in community edition
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1116,7 +1116,7 @@
|
|||||||
<property name="siteMembershipRequests" ref="SiteMembershipRequests" />
|
<property name="siteMembershipRequests" ref="SiteMembershipRequests" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean class="org.alfresco.rest.api.people.PeopleEntityResource">
|
<bean id="peopleEntityResource" class="org.alfresco.rest.api.people.PeopleEntityResource">
|
||||||
<property name="people" ref="People" />
|
<property name="people" ref="People" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user