-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read only "from" header when composing a draft. (#53)
This will avoid incorrectly matching recipient address when composing a draft while sender address was already saved.
- Loading branch information
Showing
2 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,8 +99,18 @@ public function test_storage_init_should_fetch_headers($config_values, $user_pre | |
public static function message_compose_should_set_state_provider(): array | ||
{ | ||
return array( | ||
// Missing message shouldn't match anything | ||
array( | ||
'unknown', | ||
array('to' => '[email protected]'), | ||
array(self::RULES => 'to=o'), | ||
array(), | ||
null, | ||
null | ||
), | ||
// Subject rule "exact" should match address exactly | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::RULES => 'to=e'), | ||
array(), | ||
|
@@ -109,6 +119,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule "exact" shouldn't match suffix | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::RULES => 'to=e'), | ||
array(), | ||
|
@@ -117,6 +128,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule "prefix" should match address exactly | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(), | ||
array(), | ||
|
@@ -125,6 +137,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule "prefix" should match address by prefix | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(), | ||
array(), | ||
|
@@ -133,6 +146,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule "prefix" should not match different user | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(), | ||
array(), | ||
|
@@ -141,6 +155,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule "domain" on custom header should match address by domain | ||
array( | ||
'uid', | ||
array('to' => '[email protected]', 'x-custom' => '[email protected]'), | ||
array(self::RULES => 'x-custom=d'), | ||
array(), | ||
|
@@ -149,6 +164,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule "domain" should not match different domain | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::RULES => 'to=d'), | ||
array(), | ||
|
@@ -157,6 +173,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule "other" should match anything | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::RULES => 'to=o'), | ||
array(), | ||
|
@@ -165,6 +182,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Subject rule is overridden by user prefrences | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::RULES => 'to=e'), | ||
array(self::SUBJECT => 'domain'), | ||
|
@@ -173,6 +191,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Contains constraint in configuration options matches address | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::CONTAINS => 'match'), | ||
array(self::SUBJECT => 'domain'), | ||
|
@@ -181,6 +200,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Contains constraint in configuration options rejects no match | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::CONTAINS => 'match'), | ||
array(self::SUBJECT => 'domain'), | ||
|
@@ -189,6 +209,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Contains constraint in user preferences rejects no match | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::CONTAINS => 'other'), | ||
array(self::CONTAINS => 'match', self::SUBJECT => 'always'), | ||
|
@@ -197,6 +218,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Identity behavior "default" returns matched identity with no sender on exact match | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(), | ||
array(self::SUBJECT => 'always'), | ||
|
@@ -205,6 +227,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Identity behavior "default" returns matched identity and sender with identity name on domain match | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(), | ||
array(self::SUBJECT => 'domain'), | ||
|
@@ -213,6 +236,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Identity behavior "loose" returns matched identity and sender with identity name on prefix match | ||
array( | ||
'uid', | ||
array('to' => 'SomeName <[email protected]>'), | ||
array(), | ||
array(self::IDENTITY => 'loose', self::SUBJECT => 'prefix'), | ||
|
@@ -221,6 +245,7 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Identity behavior "exact" returns matched identity with no sender on exact match | ||
array( | ||
'uid', | ||
array('to' => '[email protected]'), | ||
array(self::IDENTITY => 'exact'), | ||
array(self::SUBJECT => 'always'), | ||
|
@@ -229,17 +254,27 @@ public static function message_compose_should_set_state_provider(): array | |
), | ||
// Identity behavior "exact" returns no identity and sender with recipient name on prefix match | ||
array( | ||
'uid', | ||
array('to' => 'SomeName <[email protected]>'), | ||
array(), | ||
array(self::IDENTITY => 'exact', self::SUBJECT => 'prefix'), | ||
null, | ||
'SomeName <[email protected]>' | ||
), | ||
// Header "from" should be selected when composing a draft | ||
array( | ||
'draft_uid', | ||
array('from' => '[email protected]', 'to' => '[email protected]'), | ||
array(self::RULES => 'from=d;to=e'), | ||
array(), | ||
'2', | ||
'Bob <[email protected]>' | ||
) | ||
); | ||
} | ||
|
||
#[DataProvider('message_compose_should_set_state_provider')] | ||
public function test_message_compose_should_set_state($message, $config_values, $user_prefs, $expected_identity, $expected_sender): void | ||
public function test_message_compose_should_set_state($uid_key, $message, $config_values, $user_prefs, $expected_identity, $expected_sender): void | ||
{ | ||
$identity1 = array('identity_id' => '1', 'email' => '[email protected]', 'name' => 'Alice', 'standard' => '0'); | ||
$identity2 = array('identity_id' => '2', 'email' => '[email protected]', 'name' => 'Bob', 'standard' => '1'); | ||
|
@@ -253,7 +288,7 @@ public function test_message_compose_should_set_state($message, $config_values, | |
$rcmail->mock_user(array($identity1, $identity2, $identity3), $user_prefs); | ||
|
||
$plugin = self::create_plugin(); | ||
$plugin->message_compose(array('id' => $compose_id, 'param' => array('uid' => $message_id))); | ||
$plugin->message_compose(array('id' => $compose_id, 'param' => array($uid_key => $message_id))); | ||
|
||
$state = self::get_state($plugin, $compose_id); | ||
|
||
|