diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-11-23 19:58:43 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-23 19:58:43 +0100 |
commit | 4c5e7d270ae81c341195d47055aadabbb761b84c (patch) | |
tree | 68611ba0c21e97822f5aafe7e5c350313d326a26 /apps/user_ldap/tests/User_LDAPTest.php | |
parent | 861c8572c03ba577ca89e1f9e88ab108cfafdf49 (diff) | |
download | nextcloud-server-4c5e7d270ae81c341195d47055aadabbb761b84c.tar.gz nextcloud-server-4c5e7d270ae81c341195d47055aadabbb761b84c.zip |
Add tests
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps/user_ldap/tests/User_LDAPTest.php')
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 958d0b51979..606eff4e7a7 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -38,7 +38,9 @@ use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\User\Manager; use OCA\User_LDAP\User\OfflineUser; use OC\HintException; +use OCA\User_LDAP\User\User; use OCA\User_LDAP\User_LDAP as UserLDAP; +use OCA\User_LDAP\User_LDAP; use OCP\IAvatarManager; use OCP\IConfig; use OCP\IDBConnection; @@ -1058,4 +1060,45 @@ class User_LDAPTest extends TestCase { $this->assertFalse(\OC_User::setPassword('roland', 'dt12234$')); } + + /** + * @expectedException \Exception + * @expectedExceptionMessage LDAP setPassword: Could not get user object for uid NotExistingUser. Maybe the LDAP entry has no set display name attribute? + */ + public function testSetPasswordWithInvalidUser() { + $access = $this->createMock(Access::class); + $access->userManager = $this->createMock(IUserManager::class); + $access->userManager + ->expects($this->once()) + ->method('get') + ->with('NotExistingUser') + ->willReturn(null); + $config = $this->createMock(IConfig::class); + $ldap = new User_LDAP( + $access, + $config + ); + $ldap->setPassword('NotExistingUser', 'Password'); + } + + public function testSetPasswordWithUsernameFalse() { + $user = $this->createMock(User::class); + $user + ->expects($this->once()) + ->method('getUsername') + ->willReturn(false); + $access = $this->createMock(Access::class); + $access->userManager = $this->createMock(IUserManager::class); + $access->userManager + ->expects($this->once()) + ->method('get') + ->with('NotExistingUser') + ->willReturn($user); + $config = $this->createMock(IConfig::class); + $ldap = new User_LDAP( + $access, + $config + ); + $this->assertFalse($ldap->setPassword('NotExistingUser', 'Password')); + } } |