|
|
@@ -132,6 +132,7 @@ class SmtpTransportTest extends TestCase {
|
|
|
* testConnectEhloTlsOnNonTlsServer method
|
|
|
*
|
|
|
* @expectedException \Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS.
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testConnectEhloTlsOnNonTlsServer() {
|
|
|
@@ -152,6 +153,7 @@ class SmtpTransportTest extends TestCase {
|
|
|
* testConnectEhloNoTlsOnRequiredTlsServer method
|
|
|
*
|
|
|
* @expectedException \Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage SMTP authentication method not allowed, check if SMTP server requires TLS.
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testConnectEhloNoTlsOnRequiredTlsServer() {
|
|
|
@@ -190,6 +192,7 @@ class SmtpTransportTest extends TestCase {
|
|
|
* testConnectFail method
|
|
|
*
|
|
|
* @expectedException \Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage SMTP server did not accept the connection.
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testConnectFail() {
|
|
|
@@ -225,6 +228,90 @@ class SmtpTransportTest extends TestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * testAuthNotRecognized method
|
|
|
+ *
|
|
|
+ * @expectedException Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAuthNotRecognized() {
|
|
|
+ $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
|
|
+ $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
|
|
|
+ $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
|
|
+ $this->SmtpTransport->auth();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testAuthNotImplemented method
|
|
|
+ *
|
|
|
+ * @expectedException Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAuthNotImplemented() {
|
|
|
+ $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
|
|
+ $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("502 5.3.3 Command not implemented\r\n"));
|
|
|
+ $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
|
|
+ $this->SmtpTransport->auth();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testAuthBadSequence method
|
|
|
+ *
|
|
|
+ * @expectedException Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage SMTP Error: 503 5.5.1 Already authenticated
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAuthBadSequence() {
|
|
|
+ $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
|
|
+ $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("503 5.5.1 Already authenticated\r\n"));
|
|
|
+ $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
|
|
+ $this->SmtpTransport->auth();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testAuthBadUsername method
|
|
|
+ *
|
|
|
+ * @expectedException Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage SMTP server did not accept the username.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAuthBadUsername() {
|
|
|
+ $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
|
|
+ $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n"));
|
|
|
+ $this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n");
|
|
|
+ $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n"));
|
|
|
+ $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
|
|
+ $this->SmtpTransport->auth();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testAuthBadPassword method
|
|
|
+ *
|
|
|
+ * @expectedException Cake\Network\Error\SocketException
|
|
|
+ * @expectedExceptionMessage SMTP server did not accept the password.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testAuthBadPassword() {
|
|
|
+ $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
|
|
|
+ $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n"));
|
|
|
+ $this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n");
|
|
|
+ $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("334 Pass\r\n"));
|
|
|
+ $this->socket->expects($this->at(6))->method('write')->with("c3Rvcnk=\r\n");
|
|
|
+ $this->socket->expects($this->at(7))->method('read')->will($this->returnValue(false));
|
|
|
+ $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n"));
|
|
|
+ $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
|
|
|
+ $this->SmtpTransport->auth();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* testAuthNoAuth method
|
|
|
*
|
|
|
* @return void
|