mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
93248: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud) 93130: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1) 93124: Merged DEV to V4.2-BUG-FIX (4.2.5) 92705 : MNT-12991 : Disabled users can be invited in site - Added check for disabled user - Added unit test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94946 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,6 +37,13 @@ function main()
|
|||||||
for (i = 0, ii = peopleFound.length; i < ii; i++)
|
for (i = 0, ii = peopleFound.length; i < ii; i++)
|
||||||
{
|
{
|
||||||
name = search.findNode(peopleFound[i]).properties.userName;
|
name = search.findNode(peopleFound[i]).properties.userName;
|
||||||
|
|
||||||
|
if (!people.isAccountEnabled(name))
|
||||||
|
{
|
||||||
|
//user is disabled
|
||||||
|
notAllowed.push(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (site.getMembersRole(name) != null)
|
if (site.getMembersRole(name) != null)
|
||||||
{
|
{
|
||||||
// User is already a member
|
// User is already a member
|
||||||
|
@@ -52,6 +52,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
||||||
@@ -883,7 +884,7 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
String rejectURL = "page/reject-invite";
|
String rejectURL = "page/reject-invite";
|
||||||
|
|
||||||
// Create a nominated invitation
|
// Create a nominated invitation
|
||||||
String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL);
|
String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL, 201);
|
||||||
|
|
||||||
// Get the nominated invitation
|
// Get the nominated invitation
|
||||||
sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations/" + nominatedId), 200);
|
sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations/" + nominatedId), 200);
|
||||||
@@ -984,7 +985,7 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
String serverPath = "http://localhost:8081/share/";
|
String serverPath = "http://localhost:8081/share/";
|
||||||
String acceptURL = "page/accept-invite";
|
String acceptURL = "page/accept-invite";
|
||||||
String rejectURL = "page/reject-invite";
|
String rejectURL = "page/reject-invite";
|
||||||
inviteId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL);
|
inviteId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL, 201);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Positive test - get the invitation and validate that it is correct
|
* Positive test - get the invitation and validate that it is correct
|
||||||
@@ -1015,6 +1016,41 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInviteDisabledUser() throws Exception
|
||||||
|
{
|
||||||
|
AuthenticationUtil.pushAuthentication();
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
String username = "testUser" + System.nanoTime();
|
||||||
|
String siteShortName = GUID.generate();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
createUser(username);
|
||||||
|
createSite("myPreset", siteShortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
|
||||||
|
|
||||||
|
NodeRef personNodeRef = personService.getPerson(username);
|
||||||
|
String firstName = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_FIRSTNAME);
|
||||||
|
String lastName = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_LASTNAME);
|
||||||
|
String email = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_EMAIL);
|
||||||
|
String serverPath = "http://localhost:8081/share/";
|
||||||
|
String acceptURL = "page/accept-invite";
|
||||||
|
String rejectURL = "page/reject-invite";
|
||||||
|
|
||||||
|
authenticationService.setAuthenticationEnabled(username, false);
|
||||||
|
createNominatedInvitation(siteShortName, firstName, lastName, email, username, SiteModel.SITE_CONSUMER, serverPath, acceptURL, rejectURL, 500);
|
||||||
|
fail("The user " + username + " is disabled and cannot be invited");
|
||||||
|
}
|
||||||
|
catch (JSONException e)
|
||||||
|
{
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
siteService.deleteSite(siteShortName);
|
||||||
|
deleteUser(username);
|
||||||
|
AuthenticationUtil.popAuthentication();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detailed Test of List Invitation Web Script.
|
* Detailed Test of List Invitation Web Script.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -1043,7 +1079,7 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
String rejectURL = "page/reject-invite";
|
String rejectURL = "page/reject-invite";
|
||||||
|
|
||||||
// Create a nominated invitation
|
// Create a nominated invitation
|
||||||
String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL);
|
String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL, 201);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* search by user - negative test wombat does not have an invitation
|
* search by user - negative test wombat does not have an invitation
|
||||||
@@ -1191,7 +1227,7 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createNominatedInvitation(String siteName, String inviteeFirstName, String inviteeLastName, String inviteeEmail, String inviteeUserName, String inviteeRoleName, String serverPath, String acceptURL, String rejectURL) throws Exception
|
private String createNominatedInvitation(String siteName, String inviteeFirstName, String inviteeLastName, String inviteeEmail, String inviteeUserName, String inviteeRoleName, String serverPath, String acceptURL, String rejectURL, int expectedStatus) throws Exception
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Create a new nominated invitation
|
* Create a new nominated invitation
|
||||||
@@ -1216,7 +1252,7 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
newInvitation.put("acceptURL", acceptURL);
|
newInvitation.put("acceptURL", acceptURL);
|
||||||
newInvitation.put("rejectURL", rejectURL);
|
newInvitation.put("rejectURL", rejectURL);
|
||||||
|
|
||||||
Response response = sendRequest(new PostRequest(URL_SITES + "/" + siteName + "/invitations", newInvitation.toString(), "application/json"), 201);
|
Response response = sendRequest(new PostRequest(URL_SITES + "/" + siteName + "/invitations", newInvitation.toString(), "application/json"), expectedStatus);
|
||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
JSONObject data = top.getJSONObject("data");
|
JSONObject data = top.getJSONObject("data");
|
||||||
String inviteId = data.getString("inviteId");
|
String inviteId = data.getString("inviteId");
|
||||||
|
Reference in New Issue
Block a user