]> source.dussan.org Git - nextcloud-server.git/commitdiff
Backport of #5122 to stable12 5320/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Fri, 26 May 2017 09:25:54 +0000 (11:25 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Fri, 9 Jun 2017 14:30:56 +0000 (16:30 +0200)
add missing INotificationManager when creating User backend, LDAP
UserManager

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Make IDE happy

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
add convenience script to run all tests at once

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
13 files changed:
apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestAccessGroupsMatchFilter.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestAttributeDetection.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestBackupServer.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestBatchApplyUserAttributes.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestConnect.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestCountUsersByLoginName.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php
apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
apps/user_ldap/tests/Integration/run-all.sh [new file with mode: 0755]

index 2966180f5a15af30db271f9b8499f587cf053297..9891a4f719d1694c3676434af41e3189ba19c2bf 100644 (file)
@@ -105,7 +105,6 @@ abstract class AbstractIntegrationTest {
 
        /**
         * initializes an LDAP user manager instance
-        * @return Manager
         */
        protected function initUserManager() {
                $this->userManager = new Manager(
@@ -115,7 +114,8 @@ abstract class AbstractIntegrationTest {
                        \OC::$server->getAvatarManager(),
                        new \OCP\Image(),
                        \OC::$server->getDatabaseConnection(),
-                       \OC::$server->getUserManager()
+                       \OC::$server->getUserManager(),
+                       \OC::$server->getNotificationManager()
                );
        }
        
index 2411a46d8eeae76d699ef1c3c147a5518eb4245c..87c2e408424d7e70a7b4ad05c58d6c82575f1d98 100644 (file)
@@ -117,6 +117,11 @@ class IntegrationTestAccessGroupsMatchFilter extends AbstractIntegrationTest {
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestAccessGroupsMatchFilter($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 55b2eabedc2a7c8d9da9bfde66f8263d26a22f9d..be35556111fe8e76fb65c6a5d2406e58adadaa80 100644 (file)
@@ -49,7 +49,7 @@ class IntegrationTestAttributeDetection extends AbstractIntegrationTest {
                $groupMapper->clear();
                $this->access->setGroupMapper($groupMapper);
 
-               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig());
+               $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
                $userManager = \OC::$server->getUserManager();
                $userManager->clearBackends();
                $userManager->registerBackend($userBackend);
index f433930bd2648f947c2fbb8fff72e8f1e98c23f7..0eef5507538e89a5b3ef8001e754d860218a3c5e 100644 (file)
@@ -23,6 +23,7 @@
 
 namespace OCA\User_LDAP\Tests\Integration\Lib;
 
+use OC\ServerNotAvailableException;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\User_LDAP;
@@ -64,7 +65,7 @@ class IntegrationTestBackupServer extends AbstractIntegrationTest {
        protected function case1() {
                try {
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return false;
                }
                return true;
@@ -85,7 +86,7 @@ class IntegrationTestBackupServer extends AbstractIntegrationTest {
                                'ldap_backup_port' => '32123',
                        ]);
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return true;
                }
                return false;
@@ -106,13 +107,18 @@ class IntegrationTestBackupServer extends AbstractIntegrationTest {
                                'ldap_backup_port' => '',
                        ]);
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return true;
                }
                return false;
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestBackupServer($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 89ce764e51a843ed78f99ee29b63f49dae115161..24476c9a8683cc08fc1459627a16cb8a7df2a8b6 100644 (file)
@@ -29,6 +29,9 @@ use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
 require_once __DIR__ . '/../Bootstrap.php';
 
 class IntegrationTestBatchApplyUserAttributes extends AbstractIntegrationTest {
+       /** @var  UserMapping */
+       protected $mapping;
+
        /**
         * prepares the LDAP environment and sets up a test configuration for
         * the LDAP backend.
@@ -68,6 +71,11 @@ class IntegrationTestBatchApplyUserAttributes extends AbstractIntegrationTest {
 
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestBatchApplyUserAttributes($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 44b16aed6a12c7076eb2e0af9098004ae1e49f0f..f4fc0f189b41933de2b11d439e824883efa40edf 100644 (file)
@@ -23,6 +23,7 @@
 
 namespace OCA\User_LDAP\Tests\Integration\Lib;
 
+use OC\ServerNotAvailableException;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\User_LDAP;
@@ -68,7 +69,7 @@ class IntegrationTestConnect extends AbstractIntegrationTest {
                ]);
                try {
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return true;
                }
                return false;
@@ -87,7 +88,7 @@ class IntegrationTestConnect extends AbstractIntegrationTest {
                ]);
                try {
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return false;
                }
                return true;
@@ -106,7 +107,7 @@ class IntegrationTestConnect extends AbstractIntegrationTest {
                ]);
                try {
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return false;
                }
                return true;
@@ -125,7 +126,7 @@ class IntegrationTestConnect extends AbstractIntegrationTest {
                ]);
                try {
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return false;
                }
                return true;
@@ -144,7 +145,7 @@ class IntegrationTestConnect extends AbstractIntegrationTest {
                ]);
                try {
                        $this->connection->getConnectionResource();
-               } catch (\OC\ServerNotAvailableException $e) {
+               } catch (ServerNotAvailableException $e) {
                        return false;
                }
                return true;
@@ -161,6 +162,11 @@ class IntegrationTestConnect extends AbstractIntegrationTest {
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestConnect($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index eb4a0a5c9cfe4ddeb481e18fb751a7c8537dfed3..ebbe21975048eb5f25c66343418a23cf56675ffa 100644 (file)
@@ -61,6 +61,11 @@ class IntegrationTestCountUsersByLoginName extends AbstractIntegrationTest {
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestCountUsersByLoginName($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 25b7cf83f9948dabfb7afc0c0bee30feeb16dca7..5dda79c2ec0c143b843f05186981fdeed60ce649 100644 (file)
@@ -47,7 +47,7 @@ class IntegrationTestFetchUsersByLoginName extends AbstractIntegrationTest {
                $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
                $this->mapping->clear();
                $this->access->setUserMapper($this->mapping);
-               $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
+               $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
        }
 
        /**
@@ -74,6 +74,11 @@ class IntegrationTestFetchUsersByLoginName extends AbstractIntegrationTest {
 
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestFetchUsersByLoginName($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 2f14b0d1c1b8b47a4edfdf34dd5e193f93f5e60e..44ee1c3bb5c853635a295d3a0e8c188062f6a0a0 100644 (file)
@@ -44,7 +44,7 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
                require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
                parent::init();
 
-               $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
+               $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
        }
 
        /**
@@ -76,6 +76,11 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestPaging($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 57c48fa18e04b1282a18dec5cfae9652939d8d20..9226c56ee89568c78f4a10d31885203675b7670d 100644 (file)
 
 namespace OCA\User_LDAP\Tests\Integration\Lib;
 
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\LogWrapper;
 use OCA\User_LDAP\User\Manager as LDAPUserManager;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\User_LDAP;
+use OCP\Image;
 
 require_once __DIR__ . '/../Bootstrap.php';
 
@@ -48,7 +51,7 @@ class IntegrationTestUserHome extends AbstractIntegrationTest {
                $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
                $this->mapping->clear();
                $this->access->setUserMapper($this->mapping);
-               $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
+               $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
        }
 
        /**
@@ -68,12 +71,13 @@ class IntegrationTestUserHome extends AbstractIntegrationTest {
        protected function initUserManager() {
                $this->userManager = new LDAPUserManager(
                        \OC::$server->getConfig(),
-                       new \OCA\User_LDAP\FilesystemHelper(),
-                       new \OCA\User_LDAP\LogWrapper(),
+                       new FilesystemHelper(),
+                       new LogWrapper(),
                        \OC::$server->getAvatarManager(),
-                       new \OCP\Image(),
+                       new Image(),
                        \OC::$server->getDatabaseConnection(),
-                       \OC::$server->getUserManager()
+                       \OC::$server->getUserManager(),
+                       \OC::$server->getNotificationManager()
                );
        }
 
@@ -169,6 +173,11 @@ class IntegrationTestUserHome extends AbstractIntegrationTest {
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestUserHome($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 3fb5a67591b0f94d000a0d94a5d315bfac304c02..1710f519158829a9557893ac488988dbe51f532d 100644 (file)
 
 namespace OCA\User_LDAP\Tests\Integration\Lib\User;
 
+use OCA\User_LDAP\FilesystemHelper;
+use OCA\User_LDAP\LogWrapper;
+use OCA\User_LDAP\User\Manager;
 use OCA\User_LDAP\User\User;
 use OCA\User_LDAP\Mapping\UserMapping;
 use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
+use OCA\User_LDAP\User_LDAP;
+use OCP\Image;
 
 require_once __DIR__ . '/../../Bootstrap.php';
 
@@ -45,7 +50,7 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
                $this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
                $this->mapping->clear();
                $this->access->setUserMapper($this->mapping);
-               $userBackend  = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
+               $userBackend  = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
                \OC_User::useBackend($userBackend);
        }
 
@@ -123,12 +128,12 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
        }
 
        protected function initUserManager() {
-               $this->userManager = new \OCA\User_LDAP\User\Manager(
+               $this->userManager = new Manager(
                        \OC::$server->getConfig(),
-                       new \OCA\User_LDAP\FilesystemHelper(),
-                       new \OCA\User_LDAP\LogWrapper(),
+                       new FilesystemHelper(),
+                       new LogWrapper(),
                        \OC::$server->getAvatarManager(),
-                       new \OCP\Image(),
+                       new Image(),
                        \OC::$server->getDatabaseConnection(),
                        \OC::$server->getUserManager(),
                        \OC::$server->getNotificationManager()
@@ -149,6 +154,11 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestUserAvatar($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
index 616bf410e045d6094bc72e230faf13acc4fb220f..886b0b46f0e1b1925b5175559139c8e85a41046a 100644 (file)
@@ -101,6 +101,11 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
        }
 }
 
+/** @var string $host */
+/** @var int $port */
+/** @var string $adn */
+/** @var string $apwd */
+/** @var string $bdn */
 $test = new IntegrationTestUserDisplayName($host, $port, $adn, $apwd, $bdn);
 $test->init();
 $test->run();
diff --git a/apps/user_ldap/tests/Integration/run-all.sh b/apps/user_ldap/tests/Integration/run-all.sh
new file mode 100755 (executable)
index 0000000..02bab97
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+trigger_notification() {
+    which notify-send 1>/dev/null
+    if [[ $? == 1 ]] ; then
+        return
+    fi
+    export NOTIFY_USER=$SUDO_USER
+    export RESULT_STR=$1
+    # does not work. just pipe result into a non-sudo cmd
+    su "$NOTIFY_USER" -c "notify-send -u normal -t 43200000 -a Nextcloud -i Nextcloud \"LDAP Integration tests $RESULT_STR\""
+}
+
+FILES_ROOT=($(ls -d -p Lib/* | grep -v "/$"))
+FILES_USER=($(ls -d -p Lib/User/* | grep -v "/$"))
+# TODO: Loop through dirs (and subdirs?) once there are more
+TESTFILES=("${FILES_ROOT[@]}" "${FILES_USER[@]}")
+
+TESTCMD="./run-test.sh"
+
+echo "Running " ${#TESTFILES[@]} " tests"
+for TESTFILE in "${TESTFILES[@]}" ; do
+    echo -n "Test: $TESTFILE… "
+       STATE=`$TESTCMD "$TESTFILE" | grep -c "Tests succeeded"`
+       if [ "$STATE" -eq 0 ] ; then
+               echo "failed!"
+               trigger_notification "failed"
+               exit 1
+       fi
+    echo "succeeded"
+done
+
+echo -e "\nAll tests succeeded"
+trigger_notification "succeeded"