|
|
|
@ -21,6 +21,7 @@ class MessageTest extends TestCase
|
|
|
|
|
*/ |
|
|
|
|
protected $testEmailReceiver = 'someuser@somedomain.com'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setUp() |
|
|
|
|
{ |
|
|
|
|
$this->mockApplication([ |
|
|
|
@ -110,6 +111,24 @@ class MessageTest extends TestCase
|
|
|
|
|
return $attachment; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param Message $message |
|
|
|
|
* @return array list of attached swift signers |
|
|
|
|
*/ |
|
|
|
|
protected function getSwiftSigners(Message $message) |
|
|
|
|
{ |
|
|
|
|
$swiftMessage = $message->getSwiftMessage(); |
|
|
|
|
$reflection = new \ReflectionObject($message->getSwiftMessage()); |
|
|
|
|
$headerSignersReflection = $reflection->getProperty('headerSigners'); |
|
|
|
|
$headerSignersReflection->setAccessible(true); |
|
|
|
|
$bodySignersReflection = $reflection->getProperty('bodySigners'); |
|
|
|
|
$bodySignersReflection->setAccessible(true); |
|
|
|
|
return array_merge( |
|
|
|
|
$headerSignersReflection->getValue($swiftMessage), |
|
|
|
|
$bodySignersReflection->getValue($swiftMessage) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tests : |
|
|
|
|
|
|
|
|
|
public function testGetSwiftMessage() |
|
|
|
@ -186,6 +205,37 @@ class MessageTest extends TestCase
|
|
|
|
|
$this->assertContains('Bcc: ' . $bcc, $messageString, 'Incorrect "Bcc" header!'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testSetupSignature() |
|
|
|
|
{ |
|
|
|
|
$message = new Message(); |
|
|
|
|
|
|
|
|
|
$message->addSignature([ |
|
|
|
|
'type' => 'dkim', |
|
|
|
|
'key' => 'private key', |
|
|
|
|
]); |
|
|
|
|
$signers = $this->getSwiftSigners($message); |
|
|
|
|
$this->assertTrue($signers[0] instanceof \Swift_Signers_DKIMSigner); |
|
|
|
|
|
|
|
|
|
$signer = new \Swift_Signers_DKIMSigner('manual', null, null); |
|
|
|
|
$message->addSignature($signer); |
|
|
|
|
$signers = $this->getSwiftSigners($message); |
|
|
|
|
$this->assertSame($signer, $signers[1]); |
|
|
|
|
|
|
|
|
|
$signer = new \Swift_Signers_DKIMSigner('callable', null, null); |
|
|
|
|
$message->addSignature(function () use ($signer) { |
|
|
|
|
return $signer; |
|
|
|
|
}); |
|
|
|
|
$signers = $this->getSwiftSigners($message); |
|
|
|
|
$this->assertSame($signer, $signers[2]); |
|
|
|
|
|
|
|
|
|
$message->setSignature([ |
|
|
|
|
'type' => 'dkim', |
|
|
|
|
'key' => 'override', |
|
|
|
|
]); |
|
|
|
|
$signers = $this->getSwiftSigners($message); |
|
|
|
|
$this->assertCount(1, $signers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testGetSwiftMessage |
|
|
|
|
*/ |
|
|
|
@ -202,6 +252,52 @@ class MessageTest extends TestCase
|
|
|
|
|
/** |
|
|
|
|
* @depends testSend |
|
|
|
|
*/ |
|
|
|
|
public function testSendSigned() |
|
|
|
|
{ |
|
|
|
|
$privateKey = "-----BEGIN RSA PRIVATE KEY----- |
|
|
|
|
MIIEpAIBAAKCAQEAyehiMTRxvfQz8nbQQAgL481QipVMF+E7ljWKHTQQSYfqktR+ |
|
|
|
|
zFYqX81vKeK9/2D6AiK5KJSBVdF7aURasppuDaxFJWrPvacd3IQCrGxsGkwwlWPO |
|
|
|
|
ggB1WpOEKhVUZnGzdm96Fk23oHFKrEiQlSG0cB9P/wUKz57b8tsaPve5sKBG0Kww |
|
|
|
|
9YIDRM0x4w3c9fupPz8H5p2HHn4uPbn+whJyALZHD1+CftIGOHq8AUH4w4Z7bjF4 |
|
|
|
|
DD4zibpgRn96BVaRIJjxZdlKq69v52j3v8O8SAqSkWmpDWiIsm85Gl00Loay6iiJ |
|
|
|
|
XNy11y0sUysFeCSpb/9cRyxb6j0jEwQXrw0J/QIDAQABAoIBAQCFuRgXeKGAal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sddAEb54+u0EAa+Phz3eziYEkWUR71kG5aT/idYFvHNy513CYtIXxY |
|
|
|
|
zYzI1dOsUC6GvIZbDZgO0Jm7MMEMiVM8eIsLfGlzRm82RkSsbDsuPf183L/rTj46 |
|
|
|
|
tphI6QKBgQDobarzJhVUdME4QKAlhJecKBO1xlVCXWbKGdRcJn0Gzq6iwZKdx64C |
|
|
|
|
hQGpKaZBDDCHLk7dDzoKXF1udriW9EcImh09uIKGYYWS8poy8NUzmZ3fy/1o2C2O |
|
|
|
|
U41eAdnQ3dDGzUNedIJkSh6Z0A4VMZIEOag9hPNYqQXZBQgfobvPKw== |
|
|
|
|
-----END RSA PRIVATE KEY----- |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$message = $this->createTestMessage(); |
|
|
|
|
$message->setTo($this->testEmailReceiver); |
|
|
|
|
$message->setFrom('someuser@somedomain.com'); |
|
|
|
|
$message->setSubject('Signed message'); |
|
|
|
|
$message->setTextBody('Signed message body'); |
|
|
|
|
$message->setSignature([ |
|
|
|
|
'type' => 'dkim', |
|
|
|
|
'key' => $privateKey, |
|
|
|
|
]); |
|
|
|
|
$this->assertTrue($message->send()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testSend |
|
|
|
|
*/ |
|
|
|
|
public function testAttachFile() |
|
|
|
|
{ |
|
|
|
|
$message = $this->createTestMessage(); |
|
|
|
|