summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2019-02-15 23:09:45 +0100
committerGitHub <noreply@github.com>2019-02-15 23:09:45 +0100
commitbfd61d849f1f8dc726b1dc42d827bcb98bfe8b9d (patch)
treef08973b8a0c420c3479d9a2574ffc10aa6e077c8 /apps/user_ldap/tests
parentbf19431f2a1c08e62d78506a344c99dc4ea4078b (diff)
parent173836b95af7cdc87cb603c5d98494b02242a949 (diff)
downloadnextcloud-server-bfd61d849f1f8dc726b1dc42d827bcb98bfe8b9d.tar.gz
nextcloud-server-bfd61d849f1f8dc726b1dc42d827bcb98bfe8b9d.zip
Merge pull request #14174 from nextcloud/feature/noid/extstorage-mountconfighandler
Mount configuration handlers for external storages
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'],