Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-02-13 02:14:56 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-02-14 17:22:22 +0300
commit792bcb82ae5149c86afcd4d550e3a22d60d330f7 (patch)
treeca2ecccf6865254fb7ed463424a4ae34d7ddeded /apps/user_ldap/tests
parenta26bcd8e8fa11870c9192d24c73fbef3ef6112de (diff)
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')
-rw-r--r--apps/user_ldap/tests/ConfigurationTest.php2
-rw-r--r--apps/user_ldap/tests/User/UserTest.php52
2 files changed, 51 insertions, 3 deletions
diff --git a/apps/user_ldap/tests/ConfigurationTest.php b/apps/user_ldap/tests/ConfigurationTest.php
index ab1312860fa..6e45f163867 100644
--- a/apps/user_ldap/tests/ConfigurationTest.php
+++ b/apps/user_ldap/tests/ConfigurationTest.php
@@ -97,6 +97,8 @@ class ConfigurationTest extends \Test\TestCase {
'set avatar rule, default' => ['ldapUserAvatarRule', 'default', 'default'],
'set avatar rule, none' => ['ldapUserAvatarRule', 'none', 'none'],
'set avatar rule, data attribute' => ['ldapUserAvatarRule', 'data:jpegPhoto', 'data:jpegPhoto'],
+
+ 'set external storage home attribute' => ['ldapExtStorageHomeAttribute', 'homePath', 'homePath'],
);
}
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'],