diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-09-23 16:52:48 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2015-09-23 17:27:40 +0200 |
commit | 002b6bf059377853dc174c1d49792e62983c4bec (patch) | |
tree | ef32e287f2fa472ff33154c79f0f03c48a10e070 /apps/user_ldap/tests/user/user.php | |
parent | 845485cfe637c3a7fdb72a110cb68c769b2f8d4b (diff) | |
download | nextcloud-server-002b6bf059377853dc174c1d49792e62983c4bec.tar.gz nextcloud-server-002b6bf059377853dc174c1d49792e62983c4bec.zip |
do not throw exception when no attribute is specified
Diffstat (limited to 'apps/user_ldap/tests/user/user.php')
-rw-r--r-- | apps/user_ldap/tests/user/user.php | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/user/user.php b/apps/user_ldap/tests/user/user.php index c074b2ceb75..1c41eb71ec2 100644 --- a/apps/user_ldap/tests/user/user.php +++ b/apps/user_ldap/tests/user/user.php @@ -736,4 +736,107 @@ class Test_User_User extends \Test\TestCase { $userMock->processAttributes($record); } + + public function emptyHomeFolderAttributeValueProvider() { + return array( + 'empty' => array(''), + 'prefixOnly' => array('attr:'), + ); + } + + /** + * @dataProvider emptyHomeFolderAttributeValueProvider + */ + public function testGetHomePathNotConfigured($attributeValue) { + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + $this->getTestInstances(); + + list($access, $connection) = + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + + $connection->expects($this->any()) + ->method('__get') + ->with($this->equalTo('homeFolderNamingRule')) + ->will($this->returnValue($attributeValue)); + + $access->expects($this->never()) + ->method('readAttribute'); + + $config->expects($this->never()) + ->method('getAppValue'); + + $uid = 'alice'; + $dn = 'uid=alice,dc=foo,dc=bar'; + + $user = new User( + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + + $path = $user->getHomePath(); + $this->assertSame($path, false); + } + + public function testGetHomePathConfiguredNotAvailableAllowed() { + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + $this->getTestInstances(); + + list($access, $connection) = + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + + $connection->expects($this->any()) + ->method('__get') + ->with($this->equalTo('homeFolderNamingRule')) + ->will($this->returnValue('attr:foobar')); + + $access->expects($this->once()) + ->method('readAttribute') + ->will($this->returnValue(false)); + + // asks for "enforce_home_folder_naming_rule" + $config->expects($this->once()) + ->method('getAppValue') + ->will($this->returnValue(false)); + + $uid = 'alice'; + $dn = 'uid=alice,dc=foo,dc=bar'; + + $user = new User( + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + + $path = $user->getHomePath(); + + $this->assertSame($path, false); + } + + /** + * @expectedException \Exception + */ + public function testGetHomePathConfiguredNotAvailableNotAllowed() { + list($access, $config, $filesys, $image, $log, $avaMgr, $dbc) = + $this->getTestInstances(); + + list($access, $connection) = + $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc); + + $connection->expects($this->any()) + ->method('__get') + ->with($this->equalTo('homeFolderNamingRule')) + ->will($this->returnValue('attr:foobar')); + + $access->expects($this->once()) + ->method('readAttribute') + ->will($this->returnValue(false)); + + // asks for "enforce_home_folder_naming_rule" + $config->expects($this->once()) + ->method('getAppValue') + ->will($this->returnValue(true)); + + $uid = 'alice'; + $dn = 'uid=alice,dc=foo,dc=bar'; + + $user = new User( + $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr); + + $user->getHomePath(); + } } |