security updates
have to check views and entityreference for custom patches
This commit is contained in:
@@ -41,6 +41,55 @@ class MimeMailUnitTestCase extends DrupalUnitTestCase {
|
||||
function testUrl() {
|
||||
$result = _mimemail_url('#');
|
||||
$this->assertIdentical($result, '#', 'Hash mark URL without fragment left intact.');
|
||||
|
||||
$url = '/sites/default/files/styles/thumbnail/public/image.jpg?itok=Wrl6Qi9U';
|
||||
$result = _mimemail_url($url, TRUE);
|
||||
$expected = 'sites/default/files/styles/thumbnail/public/image.jpg';
|
||||
$this->assertIdentical($result, $expected, 'Security token removed from styled image URL.');
|
||||
|
||||
$expected = $url = 'public://' . $this->randomName() . ' '. $this->randomName() . '.' . $this->randomName(3);
|
||||
$result = _mimemail_url($url, TRUE);
|
||||
$this->assertIdentical($result, $expected, 'Space in the filename of the attachment left intact.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests functions from the Mime Mail module.
|
||||
*/
|
||||
class MimeMailWebTestCase extends DrupalWebTestCase {
|
||||
protected $adminUser;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Mime Mail web tests',
|
||||
'description' => 'Test that Mime Mail works properly.',
|
||||
'group' => 'Mime Mail',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('mailsystem', 'mimemail');
|
||||
|
||||
// Create and login user.
|
||||
$this->adminUser = $this->drupalCreateUser(array(
|
||||
'access administration pages',
|
||||
'administer site configuration',
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
}
|
||||
|
||||
public function testUrl() {
|
||||
$this->drupalPost('admin/config/system/mimemail',
|
||||
array('mimemail_linkonly' => TRUE),
|
||||
t('Save configuration'));
|
||||
|
||||
$url = 'public://' . $this->randomName() . ' '. $this->randomName() . '.jpg';
|
||||
$result = _mimemail_url($url, TRUE);
|
||||
$expected = str_replace(' ', '%20', file_create_url($url));
|
||||
$message = 'Stream wrapper converted to web accessible URL for linked image.';
|
||||
$this->assertIdentical($result, $expected, $message);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,10 +11,6 @@
|
||||
* Tests the Rules integration.
|
||||
*/
|
||||
class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* The user with administration permissions.
|
||||
* @var object
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
public static function getInfo() {
|
||||
@@ -25,14 +21,8 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'mailsystem';
|
||||
$modules[] = 'locale';
|
||||
$modules[] = 'entity';
|
||||
$modules[] = 'entity_token';
|
||||
$modules[] = 'rules';
|
||||
$modules[] = 'mimemail';
|
||||
parent::setUp($modules);
|
||||
public function setUp() {
|
||||
parent::setUp('mailsystem', 'locale', 'entity', 'entity_token', 'rules', 'mimemail');
|
||||
|
||||
// Create and login user.
|
||||
$this->adminUser = $this->drupalCreateUser(array(
|
||||
@@ -56,11 +46,10 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
drupal_static_reset('language_list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create mimemail action rule and fire it.
|
||||
* Create rule with "mimemail" action and fire it.
|
||||
*/
|
||||
public function testMimemailAction() {
|
||||
public function testMailToUserAction() {
|
||||
$settings = array(
|
||||
'key' => 'mail-key-' . $this->randomName(),
|
||||
'to' => $this->randomName() . '@example.com',
|
||||
@@ -70,7 +59,6 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
'plaintext' => $this->randomName(30) . '<div></div><br /><hr>',
|
||||
);
|
||||
|
||||
|
||||
// Set no language for the mail and check if the system default is used.
|
||||
$rule = rule();
|
||||
$rule->action('mimemail', array(
|
||||
@@ -108,12 +96,12 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create mimemail to users by role action rule and fire it.
|
||||
* Create rule with "mimemail_to_users_of_role" action and fire it.
|
||||
*/
|
||||
public function testMimemaiToUsersOfRoleAction() {
|
||||
public function testMailToUsersOfRoleAction() {
|
||||
$languages = language_list();
|
||||
|
||||
// Add more uses and roles.
|
||||
// Add more users and roles.
|
||||
$users = array(
|
||||
$this->randomName() . '@example.com' => 'en',
|
||||
$this->randomName() . '@example.com' => 'de',
|
||||
@@ -121,7 +109,9 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
$this->randomName() . '@example.com' => '',
|
||||
$this->randomName() . '@example.com' => 'invalid',
|
||||
);
|
||||
|
||||
$mimemail_role = $this->drupalCreateRole(array());
|
||||
|
||||
foreach ($users as $email => $language) {
|
||||
$user = $this->drupalCreateUser(array(
|
||||
'access administration pages',
|
||||
@@ -131,6 +121,7 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
$user->roles[$mimemail_role] = $mimemail_role;
|
||||
user_save($user);
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
'key' => 'mail-key-' . $this->randomName(),
|
||||
'from' => $this->randomName() . '@example.com',
|
||||
@@ -138,6 +129,7 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
'body' => $this->randomName(60) . '<div></div><br /><hr>',
|
||||
'plaintext' => $this->randomName(30) . '<div></div><br /><hr>',
|
||||
);
|
||||
|
||||
// Rest the collected mails.
|
||||
variable_set('drupal_test_email_collector', array());
|
||||
|
||||
@@ -171,10 +163,11 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
$this->assertEqual($mail['language']->language, $user_language);
|
||||
}
|
||||
|
||||
// Send mails to all users of a role and respect the language of the users.
|
||||
// Enforce German as fallback language if an user doesn't have a language.
|
||||
// Rest the collected mails.
|
||||
variable_set('drupal_test_email_collector', array());
|
||||
|
||||
// Send mails to all users of a role and respect the language of the users.
|
||||
// Enforce German as fallback language if an user doesn't have a language.
|
||||
$rule->elementMap()->lookup(3)->settings['language'] = 'de';
|
||||
$rule->save();
|
||||
$rule->execute();
|
||||
@@ -187,9 +180,10 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
$this->assertEqual($mail['language']->language, $user_language);
|
||||
}
|
||||
|
||||
// Send mails to all users of a role but use the same language for all.
|
||||
// Rest the collected mails.
|
||||
variable_set('drupal_test_email_collector', array());
|
||||
|
||||
// Send mails to all users of a role but use the same language for all.
|
||||
$rule->elementMap()->lookup(3)->settings['language_user'] = FALSE;
|
||||
$rule->elementMap()->lookup(3)->settings['language'] = 'it';
|
||||
$rule->save();
|
||||
@@ -199,9 +193,10 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
|
||||
$this->assertEqual($mail['language']->language, 'it');
|
||||
}
|
||||
|
||||
// Send mails to all users of a role except deactivated users.
|
||||
// Rest the collected mails.
|
||||
variable_set('drupal_test_email_collector', array());
|
||||
|
||||
// Send mails to all users of a role except deactivated users.
|
||||
// Disable one of the users.
|
||||
reset($users);
|
||||
$user = user_load_by_mail(key($users));
|
||||
|
Reference in New Issue
Block a user