Differential D19947 Diff 47639 src/applications/metamta/receiver/__tests__/PhabricatorObjectMailReceiverTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/receiver/__tests__/PhabricatorObjectMailReceiverTestCase.php
| Show All 17 Lines | public function testDropUnconfiguredPublicMail() { | ||||
| $mail->save(); | $mail->save(); | ||||
| $mail->processReceivedMail(); | $mail->processReceivedMail(); | ||||
| $this->assertEqual( | $this->assertEqual( | ||||
| MetaMTAReceivedMailStatus::STATUS_NO_PUBLIC_MAIL, | MetaMTAReceivedMailStatus::STATUS_NO_PUBLIC_MAIL, | ||||
| $mail->getStatus()); | $mail->getStatus()); | ||||
| } | } | ||||
| /* | |||||
| TODO: Tasks don't support policies yet. Implement this once they do. | |||||
| public function testDropPolicyViolationMail() { | public function testDropPolicyViolationMail() { | ||||
| list($task, $user, $mail) = $this->buildMail('public'); | list($task, $user, $mail) = $this->buildMail('policy'); | ||||
| // TODO: Set task policy to "no one" here. | $task | ||||
| ->setViewPolicy(PhabricatorPolicies::POLICY_NOONE) | |||||
| ->setOwnerPHID(null) | |||||
| ->save(); | |||||
| $env = PhabricatorEnv::beginScopedEnv(); | |||||
| $env->overrideEnvConfig('metamta.public-replies', true); | |||||
| $mail->save(); | $mail->save(); | ||||
| $mail->processReceivedMail(); | $mail->processReceivedMail(); | ||||
| $this->assertEqual( | $this->assertEqual( | ||||
| MetaMTAReceivedMailStatus::STATUS_POLICY_PROBLEM, | MetaMTAReceivedMailStatus::STATUS_POLICY_PROBLEM, | ||||
| $mail->getStatus()); | $mail->getStatus()); | ||||
| } | } | ||||
| */ | |||||
| public function testDropInvalidObjectMail() { | public function testDropInvalidObjectMail() { | ||||
| list($task, $user, $mail) = $this->buildMail('404'); | list($task, $user, $mail) = $this->buildMail('404'); | ||||
| $mail->save(); | $mail->save(); | ||||
| $mail->processReceivedMail(); | $mail->processReceivedMail(); | ||||
| $this->assertEqual( | $this->assertEqual( | ||||
| MetaMTAReceivedMailStatus::STATUS_NO_SUCH_OBJECT, | MetaMTAReceivedMailStatus::STATUS_NO_SUCH_OBJECT, | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | private function buildMail($style) { | ||||
| $mail = new PhabricatorMetaMTAReceivedMail(); | $mail = new PhabricatorMetaMTAReceivedMail(); | ||||
| $mail->setHeaders( | $mail->setHeaders( | ||||
| array( | array( | ||||
| 'Message-ID' => 'test@example.com', | 'Message-ID' => 'test@example.com', | ||||
| 'From' => $user->loadPrimaryEmail()->getAddress(), | 'From' => $user->loadPrimaryEmail()->getAddress(), | ||||
| 'To' => $to, | 'To' => $to, | ||||
| )); | )); | ||||
| $mail->setBodies( | |||||
| array( | |||||
| 'text' => 'test', | |||||
| )); | |||||
| return array($task, $user, $mail); | return array($task, $user, $mail); | ||||
| } | } | ||||
| } | } | ||||