Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

DomainStatusTest.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace AuthresStatusTests;
  3. use stdClass;
  4. use authres_status;
  5. use PHPUnit\Framework\TestCase;
  6. class DomainStatusTest extends TestCase
  7. {
  8. public function test_pass_from_subdomain()
  9. {
  10. $headers = $this->create_header_object('mail.domain.net; dkim=pass (1024-bit key; secure) header.d=email.com header.i=@email.com header.b=XXXXXXXX; dkim-atps=neutral', 'Test <test@subdomain.email.com>');
  11. $plugin = new authres_status();
  12. $result = $plugin->get_authentication_status($headers);
  13. $expected = <<<EOT
  14. <img src="plugins/authres_status/images/status_pass.png" alt="signaturepass" title="Valid signature(s) from the sender's domain. verified by dkim=pass (1024-bit key; secure)" class="authres-status-img" />
  15. EOT;
  16. $this->assertEquals($expected, $result);
  17. }
  18. public function test_pass_single_signature()
  19. {
  20. $headers = $this->create_header_object('mail.domain.net; dkim=pass (1024-bit key; secure) header.d=email.com header.i=@email.com header.b=XXXXXXXX; dkim-atps=neutral');
  21. $plugin = new authres_status();
  22. $result = $plugin->get_authentication_status($headers);
  23. $expected = <<<EOT
  24. <img src="plugins/authres_status/images/status_pass.png" alt="signaturepass" title="Valid signature(s) from the sender's domain. verified by dkim=pass (1024-bit key; secure)" class="authres-status-img" />
  25. EOT;
  26. $this->assertEquals($expected, $result);
  27. }
  28. public function test_pass_multiple_signatures()
  29. {
  30. $headers = $this->create_header_object('mail.domain.net; dkim=pass header.i=@smtpcorp.com; dkim=pass header.i=@email.com; dkim=pass header.i=@email.com');
  31. $plugin = new authres_status();
  32. $result = $plugin->get_authentication_status($headers);
  33. $expected = <<<EOT
  34. <img src="plugins/authres_status/images/status_pass.png" alt="signaturepass" title="Valid signature(s) from the sender's domain. verified by dkim=pass; dkim=pass" class="authres-status-img" />
  35. EOT;
  36. $this->assertEquals($expected, $result);
  37. }
  38. public function test_third_signature()
  39. {
  40. $headers = $this->create_header_object('mail.domain.net; dkim=pass (1024-bit key; unprotected) header.d=mail.3rdparty.com header.i=@mail.3rdparty.com header.b=XXXXXXXX;');
  41. $plugin = new authres_status();
  42. $result = $plugin->get_authentication_status($headers);
  43. $expected = <<<EOT
  44. <img src="plugins/authres_status/images/status_third.png" alt="thirdparty" title="Signed by third party, signature is present but for different domain than from address. verified for mail.3rdparty.com by dkim=pass (1024-bit key; unprotected)" class="authres-status-img" />
  45. EOT;
  46. $this->assertEquals($expected, $result);
  47. }
  48. public function test_smtp_auth_signature()
  49. {
  50. $headers = $this->create_header_object('auth=pass smtp.auth=sendonly smtp.mailfrom=mail@example.com');
  51. $plugin = new authres_status();
  52. $result = $plugin->get_authentication_status($headers);
  53. $expected = <<<EOT
  54. <img src="plugins/authres_status/images/status_pass.png" alt="signaturepass" title="Valid signature(s) from the sender's domain. verified by " class="authres-status-img" />
  55. EOT;
  56. $this->assertEquals($expected, $result);
  57. }
  58. public function test_arc_header()
  59. {
  60. $headers = $this->create_header_object('arc=fail (signature failed)');
  61. $plugin = new authres_status();
  62. $result = $plugin->get_authentication_status($headers);
  63. $expected = <<<EOT
  64. <img src="plugins/authres_status/images/status_fail.png" alt="invalidsignature" title="Signature is not valid! verified by arc=fail (signature failed)" class="authres-status-img" />
  65. EOT;
  66. $this->assertEquals($expected, $result);
  67. }
  68. protected function create_header_object($authres_header, $from = 'Test <test@email.com>')
  69. {
  70. $headers = new stdClass;
  71. $headers->from = $from;
  72. $headers->others = array(
  73. 'x-dkim-authentication-results' => false,
  74. 'authentication-results' => $authres_header
  75. );
  76. return $headers;
  77. }
  78. }