diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-02-13 00:14:56 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-02-14 15:22:22 +0100 |
commit | 792bcb82ae5149c86afcd4d550e3a22d60d330f7 (patch) | |
tree | ca2ecccf6865254fb7ed463424a4ae34d7ddeded /apps/user_ldap/tests/User/UserTest.php | |
parent | a26bcd8e8fa11870c9192d24c73fbef3ef6112de (diff) | |
download | nextcloud-server-792bcb82ae5149c86afcd4d550e3a22d60d330f7.tar.gz nextcloud-server-792bcb82ae5149c86afcd4d550e3a22d60d330f7.zip |
add LDAP ConfigHandler for external storages and "$home" var
* handler registered upon OCA\\Files_External::loadAdditionalBackends
event as user_ldap is loaded before files_external
* new configuration field "ldapExtStorageHomeAttribute" (not in GUI yet)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/tests/User/UserTest.php')
-rw-r--r-- | apps/user_ldap/tests/User/UserTest.php | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index 6ff9defe47b..f99100789d8 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -789,6 +789,50 @@ class UserTest extends \Test\TestCase { $this->user->update(); } + public function extStorageHomeDataProvider() { + return [ + [ 'myFolder', null ], + [ '', null, false ], + [ 'myFolder', 'myFolder' ], + ]; + } + + /** + * @dataProvider extStorageHomeDataProvider + */ + public function testUpdateExtStorageHome(string $expected, string $valueFromLDAP = null, bool $isSet = true) { + if($valueFromLDAP === null) { + $this->connection->expects($this->once()) + ->method('__get') + ->willReturnMap([ + ['ldapExtStorageHomeAttribute', 'homeDirectory'], + ]); + + $return = []; + if($isSet) { + $return[] = $expected; + } + $this->access->expects($this->once()) + ->method('readAttribute') + ->with($this->dn, 'homeDirectory') + ->willReturn($return); + } + + if($expected !== '') { + $this->config->expects($this->once()) + ->method('setUserValue') + ->with($this->uid, 'user_ldap', 'extStorageHome', $expected); + } else { + $this->config->expects($this->once()) + ->method('deleteUserValue') + ->with($this->uid, 'user_ldap', 'extStorageHome'); + } + + $actual = $this->user->updateExtStorageHome($valueFromLDAP); + $this->assertSame($expected, $actual); + + } + public function testUpdateNoRefresh() { $this->config->expects($this->at(0)) ->method('getUserValue') @@ -867,15 +911,16 @@ class UserTest extends \Test\TestCase { } public function testProcessAttributes() { - $requiredMethods = array( + $requiredMethods = [ 'markRefreshTime', 'updateQuota', 'updateEmail', 'composeAndStoreDisplayName', 'storeLDAPUserName', 'getHomePath', - 'updateAvatar' - ); + 'updateAvatar', + 'updateExtStorageHome', + ]; /** @var User|\PHPUnit_Framework_MockObject_MockObject $userMock */ $userMock = $this->getMockBuilder(User::class) @@ -914,6 +959,7 @@ class UserTest extends \Test\TestCase { strtolower($this->connection->ldapQuotaAttribute) => ['4096'], strtolower($this->connection->ldapEmailAttribute) => ['alice@wonderland.org'], strtolower($this->connection->ldapUserDisplayName) => ['Aaaaalice'], + strtolower($this->connection->ldapExtStorageHomeAttribute) => ['homeDirectory'], 'uid' => [$this->uid], 'homedirectory' => ['Alice\'s Folder'], 'memberof' => ['cn=groupOne', 'cn=groupTwo'], |