1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Add unit tests to cover PhabricatorMailReceiver::matchAddresses()

Summary: Ref T3183. We should accept addresses like `"New Bug" <bugs@example.com>` to match `bugs@example.com`.

Test Plan: Ran unit tests.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3183

Differential Revision: https://secure.phabricator.com/D5923
This commit is contained in:
epriestley 2013-05-14 15:04:17 -07:00
parent c1d771d86c
commit b10b1fc65f
2 changed files with 46 additions and 2 deletions

View file

@ -1080,6 +1080,7 @@ phutil_register_library_map(array(
'PhabricatorMailManagementResendWorkflow' => 'applications/metamta/management/PhabricatorMailManagementResendWorkflow.php',
'PhabricatorMailManagementWorkflow' => 'applications/metamta/management/PhabricatorMailManagementWorkflow.php',
'PhabricatorMailReceiver' => 'applications/metamta/receiver/PhabricatorMailReceiver.php',
'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php',
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php',
'PhabricatorMailingListsController' => 'applications/mailinglists/controller/PhabricatorMailingListsController.php',
'PhabricatorMailingListsEditController' => 'applications/mailinglists/controller/PhabricatorMailingListsEditController.php',
@ -1757,8 +1758,8 @@ phutil_register_library_map(array(
'ReleephRequestHeaderListView' => 'applications/releeph/view/request/header/ReleephRequestHeaderListView.php',
'ReleephRequestHeaderView' => 'applications/releeph/view/request/header/ReleephRequestHeaderView.php',
'ReleephRequestIntentsView' => 'applications/releeph/view/request/ReleephRequestIntentsView.php',
'ReleephRequestQuery' => 'applications/releeph/query/ReleephRequestQuery.php',
'ReleephRequestMailReceiver' => 'applications/releeph/mail/ReleephRequestMailReceiver.php',
'ReleephRequestQuery' => 'applications/releeph/query/ReleephRequestQuery.php',
'ReleephRequestReplyHandler' => 'applications/releeph/mail/ReleephRequestReplyHandler.php',
'ReleephRequestStatus' => 'applications/releeph/constants/ReleephRequestStatus.php',
'ReleephRequestStatusView' => 'applications/releeph/view/request/ReleephRequestStatusView.php',
@ -2823,6 +2824,7 @@ phutil_register_library_map(array(
'PhabricatorMailImplementationTestAdapter' => 'PhabricatorMailImplementationAdapter',
'PhabricatorMailManagementResendWorkflow' => 'PhabricatorSearchManagementWorkflow',
'PhabricatorMailManagementWorkflow' => 'PhutilArgumentWorkflow',
'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase',
'PhabricatorMailingListsController' => 'PhabricatorController',
'PhabricatorMailingListsEditController' => 'PhabricatorMailingListsController',
'PhabricatorMailingListsListController' => 'PhabricatorMailingListsController',
@ -3539,8 +3541,8 @@ phutil_register_library_map(array(
'ReleephRequestHeaderListView' => 'AphrontView',
'ReleephRequestHeaderView' => 'AphrontView',
'ReleephRequestIntentsView' => 'AphrontView',
'ReleephRequestQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'ReleephRequestMailReceiver' => 'PhabricatorObjectMailReceiver',
'ReleephRequestQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'ReleephRequestReplyHandler' => 'PhabricatorMailReplyHandler',
'ReleephRequestStatusView' => 'AphrontView',
'ReleephRequestTransaction' => 'PhabricatorApplicationTransaction',

View file

@ -0,0 +1,42 @@
<?php
final class PhabricatorMailReceiverTestCase extends PhabricatorTestCase {
public function testAddressSimilarity() {
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('metamta.single-reply-handler-prefix', 'prefix');
$base = 'alincoln@example.com';
$same = array(
'alincoln@example.com',
'"Abrahamn Lincoln" <alincoln@example.com>',
'ALincoln@example.com',
'prefix+alincoln@example.com',
);
foreach ($same as $address) {
$this->assertEqual(
true,
PhabricatorMailReceiver::matchAddresses($base, $address),
"Address {$address}");
}
$diff = array(
'a.lincoln@example.com',
'aluncoln@example.com',
'prefixalincoln@example.com',
'badprefix+alincoln@example.com',
'bad+prefix+alincoln@example.com',
'prefix+alincoln+sufffix@example.com',
);
foreach ($diff as $address) {
$this->assertEqual(
false,
PhabricatorMailReceiver::matchAddresses($base, $address),
"Address: {$address}");
}
}
}