diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/potentialmembers.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/potentialmembers.get.js index a703600264..ec19c7995d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/potentialmembers.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/potentialmembers.get.js @@ -37,6 +37,13 @@ function main() for (i = 0, ii = peopleFound.length; i < ii; i++) { name = search.findNode(peopleFound[i]).properties.userName; + + if (!people.isAccountEnabled(name)) + { + //user is disabled + notAllowed.push(name); + } + if (site.getMembersRole(name) != null) { // User is already a member diff --git a/source/test-java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java b/source/test-java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java index 5677f96e49..c0be71aa58 100644 --- a/source/test-java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java +++ b/source/test-java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java @@ -52,6 +52,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; @@ -883,7 +884,7 @@ public class SiteServiceTest extends BaseWebScriptTest String rejectURL = "page/reject-invite"; // 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 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 acceptURL = "page/accept-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 @@ -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. * @throws Exception @@ -1043,7 +1079,7 @@ public class SiteServiceTest extends BaseWebScriptTest String rejectURL = "page/reject-invite"; // 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 @@ -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 @@ -1216,7 +1252,7 @@ public class SiteServiceTest extends BaseWebScriptTest newInvitation.put("acceptURL", acceptURL); 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 data = top.getJSONObject("data"); String inviteId = data.getString("inviteId");