diff options
author | Jarkko Lehtoranta <devel@jlranta.com> | 2017-07-17 19:14:13 +0300 |
---|---|---|
committer | Jarkko Lehtoranta <devel@jlranta.com> | 2017-07-23 14:50:01 +0300 |
commit | 6a62b4784a63f84758cea802546753f40a40e8d7 (patch) | |
tree | 385023b4c34ded3ee2c1cabc3d7c7fbb54636908 /apps/user_ldap/tests | |
parent | 3a6511eac8d5c59613df65bd39aa2e2977aa89b6 (diff) | |
download | nextcloud-server-6a62b4784a63f84758cea802546753f40a40e8d7.tar.gz nextcloud-server-6a62b4784a63f84758cea802546753f40a40e8d7.zip |
LDAP: Add testStartTlsNegotiationFailure unit test
Signed-off-by: Jarkko Lehtoranta <devel@jlranta.com>
Diffstat (limited to 'apps/user_ldap/tests')
-rw-r--r-- | apps/user_ldap/tests/ConnectionTest.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php index 65d148b709e..87ebc8d9ad3 100644 --- a/apps/user_ldap/tests/ConnectionTest.php +++ b/apps/user_ldap/tests/ConnectionTest.php @@ -186,4 +186,54 @@ class ConnectionTest extends \Test\TestCase { $this->fail('Failed asserting that exception of type "OC\ServerNotAvailableException" is not thrown.'); } } + + public function testStartTlsNegotiationFailure() { + // background: If Start TLS negotiation fails, + // a ServerNotAvailableException should be thrown. + + $host = 'ldap://nixda.ldap'; + $port = 389; + $config = [ + 'ldapConfigurationActive' => true, + 'ldapHost' => $host, + 'ldapPort' => $port, + 'ldapTLS' => true, + 'ldapBackupHost' => '', + 'ldapAgentName' => 'user', + 'ldapAgentPassword' => 'password' + ]; + + $this->connection->setIgnoreValidation(true); + $this->connection->setConfiguration($config); + + $this->ldap->expects($this->any()) + ->method('isResource') + ->will($this->returnValue(true)); + + $this->ldap->expects($this->any()) + ->method('connect') + ->will($this->returnValue('ldapResource')); + + $this->ldap->expects($this->any()) + ->method('setOption') + ->will($this->returnValue(true)); + + $this->ldap->expects($this->any()) + ->method('bind') + ->will($this->returnValue(true)); + + $this->ldap->expects($this->any()) + ->method('errno') + ->will($this->returnValue(0)); + + $this->ldap->expects($this->any()) + ->method('startTls') + ->will($this->returnValue(false)); + + $this->expectException(\OC\ServerNotAvailableException::class); + $this->expectExceptionMessage('Start TLS failed, when connecting to LDAP host ' . $host . '.'); + + $this->connection->init(); + } + } |