Add SPF check API method to backend [MAILPOET-2295]
This commit is contained in:
@ -7,6 +7,7 @@ use MailPoet\API\JSON\v1\Services;
|
||||
use MailPoet\API\JSON\Response as APIResponse;
|
||||
use MailPoet\Config\Installer;
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Services\SPFCheck;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
|
||||
class ServicesTest extends \MailPoetTest {
|
||||
@ -20,6 +21,30 @@ class ServicesTest extends \MailPoetTest {
|
||||
$this->settings = new SettingsController();
|
||||
}
|
||||
|
||||
function testItRespondsWithErrorIfSPFCheckFails() {
|
||||
$email = 'spf_test@example.com';
|
||||
$this->settings->set('sender.address', $email);
|
||||
$this->services_endpoint->spf_check = Stub::make(
|
||||
SPFCheck::class,
|
||||
['checkSPFRecord' => false],
|
||||
$this
|
||||
);
|
||||
$response = $this->services_endpoint->checkSPFRecord([]);
|
||||
expect($response->status)->equals(APIResponse::STATUS_NOT_FOUND);
|
||||
expect($response->meta['sender_address'])->equals($email);
|
||||
expect($response->meta['domain_name'])->equals('example.com');
|
||||
}
|
||||
|
||||
function testItRespondsWithSuccessIfSPFCheckPasses() {
|
||||
$this->services_endpoint->spf_check = Stub::make(
|
||||
SPFCheck::class,
|
||||
['checkSPFRecord' => true],
|
||||
$this
|
||||
);
|
||||
$response = $this->services_endpoint->checkSPFRecord([]);
|
||||
expect($response->status)->equals(APIResponse::STATUS_OK);
|
||||
}
|
||||
|
||||
function testItRespondsWithErrorIfNoMSSKeyIsGiven() {
|
||||
$response = $this->services_endpoint->checkMSSKey(['key' => '']);
|
||||
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
||||
|
Reference in New Issue
Block a user