Skip to content

Commit

Permalink
Merge pull request #3162 from nextcloud/ldap-ocs
Browse files Browse the repository at this point in the history
Part 1 of LDAP Backend OCS Api
  • Loading branch information
MorrisJobke authored Jan 26, 2017
2 parents 3be746d + 680fef7 commit feab1e5
Show file tree
Hide file tree
Showing 9 changed files with 545 additions and 19 deletions.
11 changes: 11 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,16 @@ pipeline:
when:
matrix:
TESTS: integration-transfer-ownership-features
integration-ldap-features:
image: nextcloudci/integration-php7.0:integration-php7.0-3
commands:
- ./occ maintenance:install --admin-pass=admin
- ./occ app:enable user_ldap
- cd build/integration
- ./run.sh ldap_features/ldap-ocs.feature
when:
matrix:
TESTS: integration-ldap-features
nodb-codecov:
image: nextcloudci/php7.0:php7.0-7
commands:
Expand Down Expand Up @@ -480,6 +490,7 @@ matrix:
- TESTS: integration-setup-features
- TESTS: integration-filesdrop-features
- TESTS: integration-transfer-ownership-features
- TESTS: integration-ldap-features
- TESTS: jsunit
- TESTS: check-autoloader
- TESTS: app-check-code
Expand Down
10 changes: 10 additions & 0 deletions apps/user_ldap/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@
->actionInclude('user_ldap/ajax/testConfiguration.php');
$this->create('user_ldap_ajax_wizard', 'ajax/wizard.php')
->actionInclude('user_ldap/ajax/wizard.php');

$application = new \OCP\AppFramework\App('user_ldap');
$application->registerRoutes($this, [
'ocs' => [
['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'],
['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'],
['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'],
['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'],
]
]);
28 changes: 12 additions & 16 deletions apps/user_ldap/lib/Command/CreateEmptyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\User_LDAP\Helper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class CreateEmptyConfig extends Command {
Expand All @@ -47,29 +48,24 @@ protected function configure() {
$this
->setName('ldap:create-empty-config')
->setDescription('creates an empty LDAP configuration')
->addOption(
'only-print-prefix',
'p',
InputOption::VALUE_NONE,
'outputs only the prefix'
)
;
}

protected function execute(InputInterface $input, OutputInterface $output) {
$configPrefix = $this->getNewConfigurationPrefix();
$output->writeln("Created new configuration with configID '{$configPrefix}'");

$configPrefix = $this->helper->getNextServerConfigurationPrefix();
$configHolder = new Configuration($configPrefix);
$configHolder->saveConfiguration();
}

protected function getNewConfigurationPrefix() {
$serverConnections = $this->helper->getServerConfigurationPrefixes();

// first connection uses no prefix
if(sizeof($serverConnections) == 0) {
return '';
$prose = '';
if(!$input->getOption('only-print-prefix')) {
$prose = 'Created new configuration with configID ';
}

sort($serverConnections);
$lastKey = array_pop($serverConnections);
$lastNumber = intval(str_replace('s', '', $lastKey));
$nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
return $nextPrefix;
$output->writeln($prose . "{$configPrefix}");
}
}
9 changes: 6 additions & 3 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,12 @@ protected function setRawValue($varName, $value) {
* @return bool
*/
protected function saveValue($varName, $value) {
return \OCP\Config::setAppValue('user_ldap',
$this->configPrefix.$varName,
$value);
\OC::$server->getConfig()->setAppValue(
'user_ldap',
$this->configPrefix.$varName,
$value
);
return true;
}

/**
Expand Down
Loading

0 comments on commit feab1e5

Please sign in to comment.