diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-10-24 16:09:06 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-10-25 09:52:35 +0200 |
commit | 4130a4cbd8e5bb4506ac30a19a91b088aa35dd24 (patch) | |
tree | 1649216df56b9a685eec56cd694cef4f7ccbfa50 /apps/user_ldap/lib/Command | |
parent | 6435191a6e96600db9efbad8514d6c2eff1375d1 (diff) | |
download | nextcloud-server-4130a4cbd8e5bb4506ac30a19a91b088aa35dd24.tar.gz nextcloud-server-4130a4cbd8e5bb4506ac30a19a91b088aa35dd24.zip |
Make sure to use AccessFactory to create Access instances and use DI
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib/Command')
-rw-r--r-- | apps/user_ldap/lib/Command/TestConfig.php | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/apps/user_ldap/lib/Command/TestConfig.php b/apps/user_ldap/lib/Command/TestConfig.php index a1a4f14a232..c081b0cb726 100644 --- a/apps/user_ldap/lib/Command/TestConfig.php +++ b/apps/user_ldap/lib/Command/TestConfig.php @@ -29,6 +29,7 @@ namespace OCA\User_LDAP\Command; use OCA\User_LDAP\AccessFactory; use OCA\User_LDAP\Connection; use OCA\User_LDAP\Helper; +use OCA\User_LDAP\ILDAPWrapper; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -40,29 +41,35 @@ class TestConfig extends Command { protected const BINDFAILURE = 2; protected const SEARCHFAILURE = 3; - /** @var AccessFactory */ - protected $accessFactory; + protected AccessFactory $accessFactory; + protected Helper $helper; + protected ILDAPWrapper $ldap; - public function __construct(AccessFactory $accessFactory) { + public function __construct( + AccessFactory $accessFactory, + Helper $helper, + ILDAPWrapper $ldap + ) { $this->accessFactory = $accessFactory; + $this->helper = $helper; + $this->ldap = $ldap; parent::__construct(); } - protected function configure() { + protected function configure(): void { $this ->setName('ldap:test-config') ->setDescription('tests an LDAP configuration') ->addArgument( - 'configID', - InputArgument::REQUIRED, - 'the configuration ID' - ) + 'configID', + InputArgument::REQUIRED, + 'the configuration ID' + ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { - $helper = new Helper(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()); - $availableConfigs = $helper->getServerConfigurationPrefixes(); + $availableConfigs = $this->helper->getServerConfigurationPrefixes(); $configID = $input->getArgument('configID'); if (!in_array($configID, $availableConfigs)) { $output->writeln('Invalid configID'); @@ -94,8 +101,7 @@ class TestConfig extends Command { * Tests the specified connection */ protected function testConfig(string $configID): int { - $lw = new \OCA\User_LDAP\LDAP(); - $connection = new Connection($lw, $configID); + $connection = new Connection($this->ldap, $configID); // Ensure validation is run before we attempt the bind $connection->getConfiguration(); |