Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ protected function initConnection() {

/**
* initializes an LDAP user manager instance
* @return Manager
*/
protected function initUserManager() {
$this->userManager = new Manager(
Expand All @@ -115,7 +114,8 @@ protected function initUserManager() {
\OC::$server->getAvatarManager(),
new \OCP\Image(),
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager()
\OC::$server->getUserManager(),
\OC::$server->getNotificationManager()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ protected function initConnection() {
}
}

/** @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();
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function init() {
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,7 +65,7 @@ protected function initConnection() {
protected function case1() {
try {
$this->connection->getConnectionResource();
} catch (\OC\ServerNotAvailableException $e) {
} catch (ServerNotAvailableException $e) {
return false;
}
return true;
Expand All @@ -85,7 +86,7 @@ protected function case2() {
'ldap_backup_port' => '32123',
]);
$this->connection->getConnectionResource();
} catch (\OC\ServerNotAvailableException $e) {
} catch (ServerNotAvailableException $e) {
return true;
}
return false;
Expand All @@ -106,13 +107,18 @@ protected function case3() {
'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();
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
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.
Expand Down Expand Up @@ -68,6 +71,11 @@ protected function case1() {

}

/** @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();
16 changes: 11 additions & 5 deletions apps/user_ldap/tests/Integration/Lib/IntegrationTestConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -68,7 +69,7 @@ protected function case1() {
]);
try {
$this->connection->getConnectionResource();
} catch (\OC\ServerNotAvailableException $e) {
} catch (ServerNotAvailableException $e) {
return true;
}
return false;
Expand All @@ -87,7 +88,7 @@ protected function case2() {
]);
try {
$this->connection->getConnectionResource();
} catch (\OC\ServerNotAvailableException $e) {
} catch (ServerNotAvailableException $e) {
return false;
}
return true;
Expand All @@ -106,7 +107,7 @@ protected function case3() {
]);
try {
$this->connection->getConnectionResource();
} catch (\OC\ServerNotAvailableException $e) {
} catch (ServerNotAvailableException $e) {
return false;
}
return true;
Expand All @@ -125,7 +126,7 @@ protected function case4() {
]);
try {
$this->connection->getConnectionResource();
} catch (\OC\ServerNotAvailableException $e) {
} catch (ServerNotAvailableException $e) {
return false;
}
return true;
Expand All @@ -144,7 +145,7 @@ protected function case5() {
]);
try {
$this->connection->getConnectionResource();
} catch (\OC\ServerNotAvailableException $e) {
} catch (ServerNotAvailableException $e) {
return false;
}
return true;
Expand All @@ -161,6 +162,11 @@ protected function case6() {
}
}

/** @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();
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ protected function case2() {
}
}

/** @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();
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function init() {
$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());
}

/**
Expand All @@ -74,6 +74,11 @@ protected function case2() {

}

/** @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();
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function init() {
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());
}

/**
Expand Down Expand Up @@ -76,6 +76,11 @@ protected function case1() {
}
}

/** @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();
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@

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';

Expand All @@ -48,7 +51,7 @@ public function init() {
$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());
}

/**
Expand All @@ -68,12 +71,13 @@ protected function initConnection() {
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()
);
}

Expand Down Expand Up @@ -169,6 +173,11 @@ protected function case3() {
}
}

/** @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();
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@

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';

Expand All @@ -45,7 +50,7 @@ public function init() {
$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);
}

Expand Down Expand Up @@ -123,12 +128,12 @@ private function setJpegPhotoAttribute($dn, $image) {
}

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()
Expand All @@ -149,6 +154,11 @@ protected function initConnection() {
}
}

/** @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();
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ protected function initConnection() {
}
}

/** @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();
34 changes: 34 additions & 0 deletions apps/user_ldap/tests/Integration/run-all.sh
Original file line number Diff line number Diff line change
@@ -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"