3 final class PhabricatorMetaMTAReceivedMailTestCase
extends PhabricatorTestCase
{
5 protected function getPhabricatorTestCaseConfiguration() {
7 self
::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES
=> true,
11 public function testDropSelfMail() {
12 $mail = new PhabricatorMetaMTAReceivedMail();
15 'X-Phabricator-Sent-This-Message' => 'yes',
19 $mail->processReceivedMail();
22 MetaMTAReceivedMailStatus
::STATUS_FROM_PHABRICATOR
,
27 public function testDropDuplicateMail() {
28 $mail_a = new PhabricatorMetaMTAReceivedMail();
31 'Message-ID' => 'test@example.com',
35 $mail_b = new PhabricatorMetaMTAReceivedMail();
38 'Message-ID' => 'test@example.com',
42 $mail_a->processReceivedMail();
43 $mail_b->processReceivedMail();
46 MetaMTAReceivedMailStatus
::STATUS_DUPLICATE
,
47 $mail_b->getStatus());
50 public function testDropUnreceivableMail() {
51 $user = $this->generateNewTestUser()
54 $mail = new PhabricatorMetaMTAReceivedMail();
57 'Message-ID' => 'test@example.com',
58 'To' => 'does+not+exist@example.com',
59 'From' => $user->loadPrimaryEmail()->getAddress(),
67 $mail->processReceivedMail();
70 MetaMTAReceivedMailStatus
::STATUS_NO_RECEIVERS
,
74 public function testDropUnknownSenderMail() {
75 $this->setManiphestCreateEmail();
77 $mail = new PhabricatorMetaMTAReceivedMail();
80 'Message-ID' => 'test@example.com',
81 'To' => 'bugs@example.com',
82 'From' => 'does+not+exist@example.com',
90 $mail->processReceivedMail();
93 MetaMTAReceivedMailStatus
::STATUS_UNKNOWN_SENDER
,
98 public function testDropDisabledSenderMail() {
99 $this->setManiphestCreateEmail();
101 $user = $this->generateNewTestUser()
102 ->setIsDisabled(true)
105 $mail = new PhabricatorMetaMTAReceivedMail();
108 'Message-ID' => 'test@example.com',
109 'From' => $user->loadPrimaryEmail()->getAddress(),
110 'To' => 'bugs@example.com',
118 $mail->processReceivedMail();
121 MetaMTAReceivedMailStatus
::STATUS_DISABLED_SENDER
,
125 private function setManiphestCreateEmail() {
126 $maniphest_app = new PhabricatorManiphestApplication();
128 id(new PhabricatorMetaMTAApplicationEmail())
129 ->setApplicationPHID($maniphest_app->getPHID())
130 ->setAddress('bugs@example.com')
131 ->setConfigData(array())
133 } catch (AphrontDuplicateKeyQueryException
$ex) {}