Browse Source

Merge branch '4.next' into 5.x

Corey Taylor 2 years ago
parent
commit
de27fd6655

+ 1 - 1
composer.json

@@ -65,7 +65,7 @@
     "suggest": {
         "ext-curl": "To enable more efficient network calls in Http\\Client.",
         "ext-openssl": "To use Security::encrypt() or have secure CSRF token generation.",
-        "lib-ICU": "The intl PHP library, to use Text::transliterate() or Text::slug()",
+        "lib-ICU": "To use locale-aware features in the I18n and Database packages",
         "paragonie/csp-builder": "CSP builder, to use the CSP Middleware"
     },
     "provide": {

+ 4 - 0
src/Mailer/Transport/SmtpTransport.php

@@ -253,6 +253,10 @@ class SmtpTransport extends AbstractTransport
             return;
         }
 
+        if (!isset($this->_config['username'], $this->_config['password'])) {
+            return;
+        }
+
         $auth = '';
         foreach ($this->_lastResponse as $line) {
             if (strlen($line['message']) === 0 || substr($line['message'], 0, 5) === 'AUTH ') {

+ 21 - 1
tests/TestCase/Mailer/Transport/SmtpTransportTest.php

@@ -371,8 +371,28 @@ class SmtpTransportTest extends TestCase
                 )
             );
 
+        $this->SmtpTransport->setConfig($this->credentials);
         $this->SmtpTransport->connect();
-        $this->assertEquals($this->SmtpTransport->getAuthType(), SmtpTransport::AUTH_XOAUTH2);
+    }
+
+    public function testAuthTypeParsingIsSkippedIfNoCredentialsProvided(): void
+    {
+        $this->socket->expects($this->once())->method('connect')->will($this->returnValue(true));
+
+        $this->socket->expects($this->exactly(2))
+            ->method('read')
+            ->will($this->onConsecutiveCalls(
+                "220 Welcome message\r\n",
+                "250 Accepted\r\n250 AUTH CRAM-MD5\r\n",
+            ));
+        $this->socket->expects($this->exactly(1))
+            ->method('write')
+            ->withConsecutive(
+                ["EHLO localhost\r\n"],
+            );
+
+        $this->SmtpTransport->connect();
+        $this->assertNull($this->SmtpTransport->getAuthType());
     }
 
     public function testAuthPlain(): void