1
+ <?php
2
+ /*
3
+ * File: Issue410Test.php
4
+ * Category: -
5
+ * Author: M.Goldenbaum
6
+ * Created: 23.06.23 20:41
7
+ * Updated: -
8
+ *
9
+ * Description:
10
+ * -
11
+ */
12
+
13
+ namespace Tests \issues ;
14
+
15
+ use PHPUnit \Framework \TestCase ;
16
+ use Tests \fixtures \FixtureTestCase ;
17
+ use Webklex \PHPIMAP \Attachment ;
18
+ use Webklex \PHPIMAP \ClientManager ;
19
+ use Webklex \PHPIMAP \Exceptions \AuthFailedException ;
20
+ use Webklex \PHPIMAP \Exceptions \ConnectionFailedException ;
21
+ use Webklex \PHPIMAP \Exceptions \ImapBadRequestException ;
22
+ use Webklex \PHPIMAP \Exceptions \ImapServerErrorException ;
23
+ use Webklex \PHPIMAP \Exceptions \InvalidMessageDateException ;
24
+ use Webklex \PHPIMAP \Exceptions \MaskNotFoundException ;
25
+ use Webklex \PHPIMAP \Exceptions \MessageContentFetchingException ;
26
+ use Webklex \PHPIMAP \Exceptions \ResponseException ;
27
+ use Webklex \PHPIMAP \Exceptions \RuntimeException ;
28
+ use Webklex \PHPIMAP \Exceptions \SpoofingAttemptDetectedException ;
29
+ use Webklex \PHPIMAP \Message ;
30
+
31
+ class Issue40Test extends FixtureTestCase {
32
+
33
+ /**
34
+ * @throws RuntimeException
35
+ * @throws MessageContentFetchingException
36
+ * @throws ResponseException
37
+ * @throws ImapBadRequestException
38
+ * @throws InvalidMessageDateException
39
+ * @throws ConnectionFailedException
40
+ * @throws \ReflectionException
41
+ * @throws ImapServerErrorException
42
+ * @throws AuthFailedException
43
+ * @throws MaskNotFoundException
44
+ */
45
+ public function testIssueEmail () {
46
+ $ message = $ this ->getFixture ("issue-40.eml " );
47
+
48
+ self ::assertSame ("Zly from " , (string )$ message ->subject );
49
+ self ::assertSame ([
50
+ 'personal ' => '' ,
51
+ 'mailbox ' => 'faked_sender ' ,
52
+ 'host ' => 'sender_domain.pl ' ,
53
+ 'mail ' => 'faked_sender@sender_domain.pl ' ,
54
+ 'full ' => 'faked_sender@sender_domain.pl ' ,
55
+ ], $ message ->from ->first ()->toArray ());
56
+ self ::assertSame ([
57
+ 'personal ' => '<real_sender@sender_domain.pl> ' ,
58
+ 'mailbox ' => 'real_sender ' ,
59
+ 'host ' => 'sender_domain.pl ' ,
60
+ 'mail ' => 'real_sender@sender_domain.pl ' ,
61
+ 'full ' => '<real_sender@sender_domain.pl> <real_sender@sender_domain.pl> ' ,
62
+ ], (array )$ message ->return_path ->first ());
63
+ self ::assertSame (true , $ message ->spoofed ->first ());
64
+
65
+ $ config = $ message ->getConfig ();
66
+ self ::assertSame (false , $ config ->get ("security.detect_spoofing_exception " ));
67
+ $ config ->set ("security.detect_spoofing_exception " , true );
68
+ self ::assertSame (true , $ config ->get ("security.detect_spoofing_exception " ));
69
+
70
+ $ this ->expectException (SpoofingAttemptDetectedException::class);
71
+ $ this ->getFixture ("issue-40.eml " , $ config );
72
+ }
73
+
74
+ }
0 commit comments