diff --git a/apps/testing/appinfo/routes.php b/apps/testing/appinfo/routes.php index 0ab6b42d55..a6324a2d1f 100644 --- a/apps/testing/appinfo/routes.php +++ b/apps/testing/appinfo/routes.php @@ -48,6 +48,11 @@ return [ 'url' => '/api/v1/app/{appid}/{configkey}', 'verb' => 'DELETE', ], + [ + 'name' => 'FlushUsedUserNames#executeFlush', + 'url' => '/api/v1/flushDupeUsernames', + 'verb' => 'POST', + ], [ 'name' => 'Locking#isLockingEnabled', 'url' => '/api/v1/lockprovisioning', diff --git a/apps/testing/composer/composer/autoload_classmap.php b/apps/testing/composer/composer/autoload_classmap.php index 96bc2b7b68..507e574531 100644 --- a/apps/testing/composer/composer/autoload_classmap.php +++ b/apps/testing/composer/composer/autoload_classmap.php @@ -10,6 +10,7 @@ return array( 'OCA\\Testing\\AlternativeHomeUserBackend' => $baseDir . '/../lib/AlternativeHomeUserBackend.php', 'OCA\\Testing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', 'OCA\\Testing\\Controller\\ConfigController' => $baseDir . '/../lib/Controller/ConfigController.php', + 'OCA\\Testing\\Controller\\FlushUsedUserNamesController' => $baseDir . '/../lib/Controller/FlushUsedUserNamesController.php', 'OCA\\Testing\\Controller\\LockingController' => $baseDir . '/../lib/Controller/LockingController.php', 'OCA\\Testing\\Controller\\RateLimitTestController' => $baseDir . '/../lib/Controller/RateLimitTestController.php', 'OCA\\Testing\\Locking\\FakeDBLockingProvider' => $baseDir . '/../lib/Locking/FakeDBLockingProvider.php', diff --git a/apps/testing/composer/composer/autoload_static.php b/apps/testing/composer/composer/autoload_static.php index 15b4617183..f17ea253a6 100644 --- a/apps/testing/composer/composer/autoload_static.php +++ b/apps/testing/composer/composer/autoload_static.php @@ -25,6 +25,7 @@ class ComposerStaticInitTesting 'OCA\\Testing\\AlternativeHomeUserBackend' => __DIR__ . '/..' . '/../lib/AlternativeHomeUserBackend.php', 'OCA\\Testing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', 'OCA\\Testing\\Controller\\ConfigController' => __DIR__ . '/..' . '/../lib/Controller/ConfigController.php', + 'OCA\\Testing\\Controller\\FlushUsedUserNamesController' => __DIR__ . '/..' . '/../lib/Controller/FlushUsedUserNamesController.php', 'OCA\\Testing\\Controller\\LockingController' => __DIR__ . '/..' . '/../lib/Controller/LockingController.php', 'OCA\\Testing\\Controller\\RateLimitTestController' => __DIR__ . '/..' . '/../lib/Controller/RateLimitTestController.php', 'OCA\\Testing\\Locking\\FakeDBLockingProvider' => __DIR__ . '/..' . '/../lib/Locking/FakeDBLockingProvider.php', diff --git a/apps/testing/lib/Controller/FlushUsedUserNamesController.php b/apps/testing/lib/Controller/FlushUsedUserNamesController.php new file mode 100644 index 0000000000..3faa9d300d --- /dev/null +++ b/apps/testing/lib/Controller/FlushUsedUserNamesController.php @@ -0,0 +1,55 @@ + + * + * @author Lukas Reschke + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Testing\Controller; + +use OC\User\UsernameDuplicationPreventionManager; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\OCSController; +use OCP\IRequest; + +class FlushUsedUserNamesController extends OCSController { + + /** @var UsernameDuplicationPreventionManager */ + private $usernameDuplicationPreventionManager; + + /** + * @param string $appName + * @param IRequest $request + * @param UsernameDuplicationPreventionManager $usernameDuplicationPreventionManager + */ + public function __construct($appName, + IRequest $request, + UsernameDuplicationPreventionManager $usernameDuplicationPreventionManager) { + parent::__construct($appName, $request); + $this->usernameDuplicationPreventionManager = $usernameDuplicationPreventionManager; + } + + public function executeFlush() : DataResponse { + $this->usernameDuplicationPreventionManager->cleanUp(); + return new DataResponse(); + } +} diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index d613986df6..de5a211bfd 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -414,6 +414,15 @@ trait Provisioning { $this->response = $client->put($fullUrl, $options); } + private function flushDeletedUserList() { + $previousUser = $this->currentUser; + $this->currentUser = 'admin'; + $this->sendingTo('POST', "/cloud/apps/testing"); + $this->sendingTo('POST', "/apps/testing/api/v1/flushDupeUsernames"); + $this->sendingTo('DELETE', "/cloud/apps/testing"); + $this->currentUser = $previousUser; + } + /** * @When /^Deleting the user "([^"]*)"$/ * @param string $user @@ -908,6 +917,8 @@ trait Provisioning { * @AfterScenario */ public function cleanupUsers() { + $this->flushDeletedUserList(); + $previousServer = $this->currentServer; $this->usingServer('LOCAL'); foreach ($this->createdUsers as $user) {