Add regex routes requirement to providerId

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ 2021-12-10 08:16:06 +01:00 committed by blizzz (Rebase PR Action)
parent 66759ce3eb
commit 24a632588c
11 changed files with 61 additions and 56 deletions

View file

@ -80,6 +80,9 @@ return [
'verb' => 'GET',
'defaults' => [
'providerId' => 1
],
'requirements' => [
'providerId' => '\d+'
]
],
[
@ -88,6 +91,9 @@ return [
'verb' => 'POST',
'defaults' => [
'providerId' => 1
],
'requirements' => [
'providerId' => '\d+'
]
],
[
@ -100,7 +106,10 @@ return [
'url' => '/settings/providerSettings/{providerId}',
'verb' => 'DELETE',
'defaults' => [
'providerId' => '1'
'providerId' => 1
],
'requirements' => [
'providerId' => '\d+'
]
],
[

View file

@ -45,7 +45,8 @@ class ConfigurationsMapper extends QBMapper {
public function deleteById(int $id): void {
$entity = new ConfigurationsEntity();
$entity->setId($id);;
$entity->setId($id);
;
$this->delete($entity);
}
@ -98,5 +99,4 @@ class ConfigurationsMapper extends QBMapper {
$newEntity->importConfiguration([]);
return $this->insert($newEntity)->getId();
}
}

View file

@ -16,7 +16,6 @@ use OCP\Migration\SimpleMigrationStep;
* Auto-generated migration step: Please modify to your needs!
*/
class Version5000Date20211025124248 extends SimpleMigrationStep {
private const IDP_CONFIG_KEYS = [
'general-idp0_display_name',
'general-uid_mapping',

View file

@ -107,7 +107,7 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
* @param string $uid
* @param array $attributes
*/
public function createUserIfNotExists($uid, array $attributes = array()) {
public function createUserIfNotExists($uid, array $attributes = []) {
if (!$this->userExistsInDatabase($uid)) {
$values = [
'uid' => $uid,
@ -143,7 +143,6 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
$qb->execute();
$this->initializeHomeDir($uid);
}
}
@ -549,8 +548,7 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
/**
* @throws \OCP\DB\Exception
*/
private function getAttributeKeys($name)
{
private function getAttributeKeys($name) {
$settings = $this->settings->get($this->settings->getProviderId());
$keys = explode(' ', $settings[$name] ?? $this->config->getAppValue('user_saml', $name, ''));
@ -588,7 +586,7 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
private function getAttributeArrayValue($name, array $attributes) {
$keys = $this->getAttributeKeys($name);
$value = array();
$value = [];
foreach ($keys as $key) {
if (isset($attributes[$key])) {
if (is_array($attributes[$key])) {

View file

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Arthur Schiwon <blizzz@arthur-schiwon.de>

View file

@ -94,7 +94,6 @@ class FeatureContext implements Context {
*/
public function theSettingIsSetTo($settingName,
$value) {
if (in_array($settingName, [
'type',
'general-require_provisioned_account',

View file

@ -66,5 +66,4 @@ class GetMetadataTest extends \Test\TestCase {
$this->invokePrivate($this->GetMetadata, 'execute', [$inputInterface, $outputInterface]);
}
}

View file

@ -62,7 +62,7 @@ class AdminTest extends \Test\TestCase {
$this->l10n
->expects($this->any())
->method('t')
->will($this->returnCallback(function($text, $parameters = array()) {
->will($this->returnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);
}));