mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
67750: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 66138: Merged DEV to V4.2-BUG-FIX (4.2.2) 66134: MNT-10874 : If userA's email address is used as userB's username then the userA cannot be invited to a Share site by a non-admin user Added a JUnit test to simulate the issue. 64109: MNT-10874 : If userA's email address is used as userB's username then the userA cannot be invited to a Share site by a non-admin user Fixed MailActionExecuter to use system user to retrieve user's locale. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@68385 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,6 +33,7 @@ import javax.mail.internet.MimeMessage;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.management.subsystems.ApplicationContextFactory;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.tenant.TenantUtil;
|
||||
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||
@@ -336,8 +337,8 @@ public abstract class AbstractMailActionExecuterTest
|
||||
{
|
||||
final String USER1 = "test_user1";
|
||||
final String USER2 = "test_user2";
|
||||
createUser(USER1);
|
||||
NodeRef userNode = createUser(USER2);
|
||||
createUser(USER1, null);
|
||||
NodeRef userNode = createUser(USER2, null);
|
||||
groupName = AUTHORITY_SERVICE.createAuthority(AuthorityType.GROUP, "testgroup1");
|
||||
AUTHORITY_SERVICE.addAuthority(groupName, USER1);
|
||||
AUTHORITY_SERVICE.addAuthority(groupName, USER2);
|
||||
@@ -373,15 +374,59 @@ public abstract class AbstractMailActionExecuterTest
|
||||
}
|
||||
}
|
||||
|
||||
private NodeRef createUser(String userName)
|
||||
/**
|
||||
* Creates a test user with the specified username and optionally custom email.
|
||||
*
|
||||
* @param userName
|
||||
* @param email Optional, if not specified assigned to <code>userName + "@email.com"</code>
|
||||
* @return
|
||||
*/
|
||||
private NodeRef createUser(String userName, String email)
|
||||
{
|
||||
PropertyMap personProps = new PropertyMap();
|
||||
personProps.put(ContentModel.PROP_USERNAME, userName);
|
||||
personProps.put(ContentModel.PROP_FIRSTNAME, userName);
|
||||
personProps.put(ContentModel.PROP_LASTNAME, userName);
|
||||
personProps.put(ContentModel.PROP_EMAIL, userName + "@email.com");
|
||||
if (email != null)
|
||||
{
|
||||
personProps.put(ContentModel.PROP_EMAIL, email);
|
||||
}
|
||||
else
|
||||
{
|
||||
personProps.put(ContentModel.PROP_EMAIL, userName + "@email.com");
|
||||
}
|
||||
|
||||
return PERSON_SERVICE.createPerson(personProps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for MNT-10874
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testUserWithNonExistingTenant() throws Exception
|
||||
{
|
||||
final String USER_WITH_NON_EXISTING_TENANT = "test_user_non_tenant@non_existing_tenant.com";
|
||||
|
||||
createUser(USER_WITH_NON_EXISTING_TENANT, USER_WITH_NON_EXISTING_TENANT);
|
||||
|
||||
final Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME);
|
||||
mailAction.setParameterValue(MailActionExecuter.PARAM_TO, USER_WITH_NON_EXISTING_TENANT);
|
||||
mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Testing");
|
||||
mailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, "This is a test message.");
|
||||
|
||||
// run as non admin and non system
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(BRITISH_USER.getUsername());
|
||||
TRANSACTION_SERVICE.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
ACTION_EXECUTER.executeImpl(mailAction, null);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user