mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (4.3/Cloud)
73354: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 73241: MNT-11079: Merged DEV to V4.2-BUG-FIX (4.2.3) 67748: MNT-11079: "Start Workflow" email notification is not sent out if the recipient's User Name contians "@" - During defining mail recipients first check email field and only then check if the username is the valid email address. Fix formatting and cleanup for other MailActionExecuterTest tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@74772 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1168,14 +1168,6 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
if (authority != null && authority.length() != 0)
|
if (authority != null && authority.length() != 0)
|
||||||
{
|
{
|
||||||
if (personExists(authority))
|
if (personExists(authority))
|
||||||
{
|
|
||||||
EmailValidator emailValidator = EmailValidator.getInstance(true);
|
|
||||||
if (validateAddresses && emailValidator.isValid(authority))
|
|
||||||
{
|
|
||||||
Locale locale = getLocaleForUser(authority);
|
|
||||||
recipients.add(new Pair<String, Locale>(authority, locale));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
String address = getPersonEmail(authority);
|
String address = getPersonEmail(authority);
|
||||||
if (address != null && address.length() != 0 && validateAddress(address))
|
if (address != null && address.length() != 0 && validateAddress(address))
|
||||||
@@ -1183,6 +1175,14 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
Locale locale = getLocaleForUser(authority);
|
Locale locale = getLocaleForUser(authority);
|
||||||
recipients.add(new Pair<String, Locale>(address, locale));
|
recipients.add(new Pair<String, Locale>(address, locale));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EmailValidator emailValidator = EmailValidator.getInstance(true);
|
||||||
|
if (validateAddresses && emailValidator.isValid(authority))
|
||||||
|
{
|
||||||
|
Locale locale = getLocaleForUser(authority);
|
||||||
|
recipients.add(new Pair<String, Locale>(authority, locale));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1211,6 +1211,14 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
// Check the user name to be a valid email and we don't need to log an error in this case
|
// Check the user name to be a valid email and we don't need to log an error in this case
|
||||||
// ALF-19231
|
// ALF-19231
|
||||||
// Validate the email, allowing for local email addresses
|
// Validate the email, allowing for local email addresses
|
||||||
|
String address = getPersonEmail(userAuth);
|
||||||
|
if (address != null && address.length() != 0 && validateAddress(address))
|
||||||
|
{
|
||||||
|
Locale locale = getLocaleForUser(userAuth);
|
||||||
|
recipients.add(new Pair<String, Locale>(address, locale));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
EmailValidator emailValidator = EmailValidator.getInstance(true);
|
EmailValidator emailValidator = EmailValidator.getInstance(true);
|
||||||
if (validateAddresses && emailValidator.isValid(userAuth))
|
if (validateAddresses && emailValidator.isValid(userAuth))
|
||||||
{
|
{
|
||||||
@@ -1220,14 +1228,6 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
recipients.add(new Pair<String, Locale>(userAuth, locale));
|
recipients.add(new Pair<String, Locale>(userAuth, locale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
String address = getPersonEmail(userAuth);
|
|
||||||
if (address != null && address.length() != 0 && validateAddress(address))
|
|
||||||
{
|
|
||||||
Locale locale = getLocaleForUser(userAuth);
|
|
||||||
recipients.add(new Pair<String, Locale>(address, locale));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -335,10 +335,10 @@ public abstract class AbstractMailActionExecuterTest
|
|||||||
public void testPrepareEmailForDisabledUsers() throws MessagingException
|
public void testPrepareEmailForDisabledUsers() throws MessagingException
|
||||||
{
|
{
|
||||||
String groupName = null;
|
String groupName = null;
|
||||||
try
|
|
||||||
{
|
|
||||||
final String USER1 = "test_user1";
|
final String USER1 = "test_user1";
|
||||||
final String USER2 = "test_user2";
|
final String USER2 = "test_user2";
|
||||||
|
try
|
||||||
|
{
|
||||||
createUser(USER1, null);
|
createUser(USER1, null);
|
||||||
NodeRef userNode = createUser(USER2, null);
|
NodeRef userNode = createUser(USER2, null);
|
||||||
groupName = AUTHORITY_SERVICE.createAuthority(AuthorityType.GROUP, "testgroup1");
|
groupName = AUTHORITY_SERVICE.createAuthority(AuthorityType.GROUP, "testgroup1");
|
||||||
@@ -373,6 +373,8 @@ public abstract class AbstractMailActionExecuterTest
|
|||||||
{
|
{
|
||||||
AUTHORITY_SERVICE.deleteAuthority(groupName, true);
|
AUTHORITY_SERVICE.deleteAuthority(groupName, true);
|
||||||
}
|
}
|
||||||
|
PERSON_SERVICE.deletePerson(USER1);
|
||||||
|
PERSON_SERVICE.deletePerson(USER2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,6 +412,8 @@ public abstract class AbstractMailActionExecuterTest
|
|||||||
{
|
{
|
||||||
final String USER_WITH_NON_EXISTING_TENANT = "test_user_non_tenant@non_existing_tenant.com";
|
final String USER_WITH_NON_EXISTING_TENANT = "test_user_non_tenant@non_existing_tenant.com";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
createUser(USER_WITH_NON_EXISTING_TENANT, USER_WITH_NON_EXISTING_TENANT);
|
createUser(USER_WITH_NON_EXISTING_TENANT, USER_WITH_NON_EXISTING_TENANT);
|
||||||
|
|
||||||
final Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME);
|
final Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME);
|
||||||
@@ -428,9 +432,16 @@ public abstract class AbstractMailActionExecuterTest
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// restore system user as current user
|
||||||
|
AuthenticationUtil.setRunAsUserSystem();
|
||||||
|
// tidy up
|
||||||
|
PERSON_SERVICE.deletePerson(USER_WITH_NON_EXISTING_TENANT);
|
||||||
AuthenticationUtil.clearCurrentSecurityContext();
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for MNT-11488
|
* Test for MNT-11488
|
||||||
@@ -478,4 +489,42 @@ public abstract class AbstractMailActionExecuterTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for MNT-11079
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSendingToUserWithMailAlikeName() throws IOException, MessagingException
|
||||||
|
{
|
||||||
|
final String USER_1 = "user1@namelookslikeemail";
|
||||||
|
final String USER_1_EMAIL = "user1@trueemail.com";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
createUser(USER_1, USER_1_EMAIL);
|
||||||
|
|
||||||
|
Action mailAction = ACTION_SERVICE.createAction(MailActionExecuter.NAME);
|
||||||
|
mailAction.setParameterValue(MailActionExecuter.PARAM_FROM, "some.body@example.com");
|
||||||
|
mailAction.setParameterValue(MailActionExecuter.PARAM_TO_MANY, USER_1);
|
||||||
|
|
||||||
|
mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Testing");
|
||||||
|
mailAction.setParameterValue(MailActionExecuter.PARAM_TEMPLATE, "alfresco/templates/mail/test.txt.ftl");
|
||||||
|
|
||||||
|
mailAction.setParameterValue(MailActionExecuter.PARAM_TEMPLATE_MODEL, (Serializable) getModel());
|
||||||
|
|
||||||
|
ACTION_SERVICE.executeAction(mailAction, null);
|
||||||
|
|
||||||
|
MimeMessage message = ACTION_EXECUTER.retrieveLastTestMessage();
|
||||||
|
Assert.assertNotNull(message);
|
||||||
|
Assert.assertEquals("Hello Jan 1, 1970", (String) message.getContent());
|
||||||
|
Assert.assertEquals(1, message.getAllRecipients().length);
|
||||||
|
javax.mail.internet.InternetAddress address = (InternetAddress) message.getAllRecipients()[0];
|
||||||
|
Assert.assertEquals(USER_1_EMAIL, address.getAddress());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// tidy up
|
||||||
|
PERSON_SERVICE.deletePerson(USER_1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user