Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

57912: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3)
      57879: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1)
         57877: MNT-9926: reformat code changes from
            53236: MNT-9101 Share: Cancelling an invitation for a disabled user, the user gets deleted in the process.
            	-add tests for both internal and external user invite cancellation
                -add new aspect to identify external invites and exclude from post invite cancellation cleanup


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61905 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-11 22:25:56 +00:00
parent f6104e80a9
commit d817f0522d
3 changed files with 45 additions and 47 deletions

View File

@@ -372,7 +372,6 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
nodeService.removeAspect(person, ContentModel.ASPECT_ANULLABLE); nodeService.removeAspect(person, ContentModel.ASPECT_ANULLABLE);
} }
return invitation; return invitation;
} }

View File

@@ -288,8 +288,8 @@ public class InviteHelper implements InitializingBean
// if invitee's user account is still disabled and there are no pending invites outstanding // if invitee's user account is still disabled and there are no pending invites outstanding
// for the invitee, then remove the account and delete the invitee's person node // for the invitee, then remove the account and delete the invitee's person node
if (person != null if (person != null
&& (authenticationService.isAuthenticationMutable(inviteeUserName)) && (authenticationService.isAuthenticationMutable(inviteeUserName))
&& (authenticationService.getAuthenticationEnabled(inviteeUserName) == false) && (authenticationService.getAuthenticationEnabled(inviteeUserName) == false)
&& (invitesPending == false) && (invitesPending == false)
&& nodeService.hasAspect(person, ContentModel.ASPECT_ANULLABLE)) && nodeService.hasAspect(person, ContentModel.ASPECT_ANULLABLE))

View File

@@ -184,53 +184,51 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
{ {
assertNotNull("Invitation service is null", invitationService); assertNotNull("Invitation service is null", invitationService);
} }
/** /**
* MNT-9101 An internal user account (disabled) should not be deleted if * MNT-9101 An internal user account (disabled) should not be deleted if an
* an associated nominated invitation is cancelled. * associated nominated invitation is cancelled.
* *
* @throws Exception * @throws Exception
*/ */
public void testInternalUserNotDeletedAfterInviteCancelled() throws Exception { public void testInternalUserNotDeletedAfterInviteCancelled() throws Exception
{
// Disable our existing User
boolean enabled = authenticationService.getAuthenticationEnabled(USER_ONE);
assertTrue("User One authentication disabled", enabled);
authenticationService.setAuthenticationEnabled(USER_ONE, false);
enabled = authenticationService.getAuthenticationEnabled(USER_ONE);
assertTrue("User One authentication enabled", !enabled);
//Disable our existing User String inviteeUserName = USER_ONE;
boolean enabled = authenticationService.getAuthenticationEnabled(USER_ONE); Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE;
assertTrue("User One authentication disabled", enabled); String resourceName = SITE_SHORT_NAME_INVITE;
authenticationService.setAuthenticationEnabled(USER_ONE, false); String inviteeRole = SiteModel.SITE_COLLABORATOR;
enabled = authenticationService.getAuthenticationEnabled(USER_ONE); String acceptUrl = "froob";
assertTrue("User One authentication enabled", !enabled); String rejectUrl = "marshmallow";
String inviteeUserName = USER_ONE; this.authenticationComponent.setCurrentUser(USER_MANAGER);
Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE;
String resourceName = SITE_SHORT_NAME_INVITE;
String inviteeRole = SiteModel.SITE_COLLABORATOR;
String acceptUrl = "froob";
String rejectUrl = "marshmallow";
this.authenticationComponent.setCurrentUser(USER_MANAGER); // Invite our existing user
NominatedInvitation nominatedInvitation = invitationService.inviteNominated(
inviteeUserName, resourceType, resourceName, inviteeRole, acceptUrl, rejectUrl);
//Invite our existing user // Cancel the invite
NominatedInvitation nominatedInvitation = invitationService invitationService.cancel(nominatedInvitation.getInviteId());
.inviteNominated(inviteeUserName, resourceType, resourceName,
inviteeRole, acceptUrl, rejectUrl);
//Cancel the invite // Our User and associated Authentication still exists
invitationService.cancel(nominatedInvitation.getInviteId()); assertNotNull("User Exists", personService.getPersonOrNull(USER_ONE));
assertTrue("Authentication Exists", authenticationService.authenticationExists(USER_ONE));
//Our User and associated Authentication still exists }
assertNotNull("User Exists", personService.getPersonOrNull(USER_ONE));
assertTrue("Authentication Exists", authenticationService.authenticationExists(USER_ONE));
} /**
* Ensure that an External user account is deleted when an invite is
/** * cancelled
* Ensure that an External user account is deleted when an invite is cancelled
* *
* @throws Exception * @throws Exception
*/ */
public void testExternalUserDeletedAfterInviteCancelled() throws Exception { public void testExternalUserDeletedAfterInviteCancelled() throws Exception
{
String inviteeFirstName = PERSON_FIRSTNAME; String inviteeFirstName = PERSON_FIRSTNAME;
String inviteeLastName = PERSON_LASTNAME; String inviteeLastName = PERSON_LASTNAME;
String inviteeEmail = "123@alfrescotesting.com"; String inviteeEmail = "123@alfrescotesting.com";
@@ -243,19 +241,20 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
this.authenticationComponent.setCurrentUser(USER_MANAGER); this.authenticationComponent.setCurrentUser(USER_MANAGER);
NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeFirstName, inviteeLastName, NominatedInvitation nominatedInvitation = invitationService.inviteNominated(
inviteeEmail, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); inviteeFirstName, inviteeLastName, inviteeEmail, resourceType, resourceName,
inviteeRole, serverPath, acceptUrl, rejectUrl);
String inviteeUsername = nominatedInvitation.getInviteeUserName(); String inviteeUsername = nominatedInvitation.getInviteeUserName();
invitationService.cancel(nominatedInvitation.getInviteId()); invitationService.cancel(nominatedInvitation.getInviteId());
//Our User and Authentication has been removed // Our User and Authentication has been removed
assertNull("Person deleted", personService.getPersonOrNull(inviteeUsername)); assertNull("Person deleted", personService.getPersonOrNull(inviteeUsername));
assertFalse("Authentication deleted", authenticationService.authenticationExists(inviteeUsername)); assertFalse("Authentication deleted",
} authenticationService.authenticationExists(inviteeUsername));
}
/** /**
* Test nominated user - new user * Test nominated user - new user
* *