瀏覽代碼

Fix case on domains

Will Browning 5 年之前
父節點
當前提交
5751ade104
共有 3 個文件被更改,包括 69 次插入2 次删除
  1. 2 2
      app/Console/Commands/ReceiveEmail.php
  2. 39 0
      tests/Feature/ReceiveEmailTest.php
  3. 28 0
      tests/emails/email_caps.eml

+ 2 - 2
app/Console/Commands/ReceiveEmail.php

@@ -257,9 +257,9 @@ class ReceiveEmail extends Command
         return collect($this->option('recipient'))->map(function ($item, $key) {
             return [
                 'email' => $item,
-                'local_part' => $this->option('local_part')[$key],
+                'local_part' => strtolower($this->option('local_part')[$key]),
                 'extension' => $this->option('extension')[$key],
-                'domain' => $this->option('domain')[$key]
+                'domain' => strtolower($this->option('domain')[$key])
             ];
         });
     }

+ 39 - 0
tests/Feature/ReceiveEmailTest.php

@@ -71,6 +71,45 @@ class ReceiveEmailTest extends TestCase
         Notification::assertNothingSent();
     }
 
+    /** @test */
+    public function it_can_forward_email_from_file_with_capitals()
+    {
+        Mail::fake();
+
+        Mail::assertNothingSent();
+
+        $this->artisan(
+            'anonaddy:receive-email',
+            [
+                'file' => base_path('tests/emails/email_caps.eml'),
+                '--sender' => 'will@anonaddy.com',
+                '--recipient' => ['EBAY@JOHNDOE.ANONADDY.COM'],
+                '--local_part' => ['EBAY'],
+                '--extension' => [''],
+                '--domain' => ['JOHNDOE.ANONADDY.COM'],
+                '--size' => '1000'
+            ]
+        )->assertExitCode(0);
+
+        $this->assertDatabaseHas('aliases', [
+            'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
+            'local_part' => 'ebay',
+            'domain' => 'johndoe.'.config('anonaddy.domain'),
+            'emails_forwarded' => 1,
+            'emails_blocked' => 0
+        ]);
+        $this->assertEquals(1, $this->user->aliases()->count());
+        $this->assertDatabaseHas('users', [
+            'id' => $this->user->id,
+            'username' => 'johndoe',
+            'bandwidth' => '1000'
+        ]);
+
+        Mail::assertQueued(ForwardEmail::class, function ($mail) {
+            return $mail->hasTo($this->user->email);
+        });
+    }
+
     /** @test */
     public function it_can_forward_email_from_file_with_attachment()
     {

+ 28 - 0
tests/emails/email_caps.eml

@@ -0,0 +1,28 @@
+Date: Wed, 20 Feb 2019 15:00:00 +0100 (CET)
+From: Will <will@anonaddy.com>
+To: <EBAY@JOHNDOE.ANONADDY.COM>
+Subject: Test Email
+Content-Type: multipart/mixed; boundary="----=_Part_10031_1199410393.1550677940425"
+
+------=_Part_10031_1199410393.1550677940425
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+Hi,<br>
+<br>
+This is a test email.<br>
+<br>
+Will
+
+
+------=_Part_10031_1199410393.1550677940425
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+Hi,
+
+This is a test email.
+
+Will
+
+------=_Part_10031_1199410393.1550677940425--