From a4f6e198a135c6c6b5b3e5cb5068813a6db819b4 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 2 Jun 2021 18:01:04 +0200 Subject: [PATCH] Disable testing app only conditionally Signed-off-by: Lukas Reschke --- .../features/bootstrap/Provisioning.php | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index de5a211bfd..179d235b1d 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -417,9 +417,34 @@ trait Provisioning { private function flushDeletedUserList() { $previousUser = $this->currentUser; $this->currentUser = 'admin'; - $this->sendingTo('POST', "/cloud/apps/testing"); + + $fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=disabled"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + $options['headers'] = [ + 'OCS-APIREQUEST' => 'true', + ]; + + $response = $client->get($fullUrl, $options); + $respondedArray = $this->getArrayOfAppsResponded($response); + $isTestingAppEnabled = true; + if (array_key_exists('testing', $respondedArray)) { + $isTestingAppEnabled = false; + } + + if (!$isTestingAppEnabled) { + $this->sendingTo('POST', "/cloud/apps/testing"); + } + $this->sendingTo('POST', "/apps/testing/api/v1/flushDupeUsernames"); - $this->sendingTo('DELETE', "/cloud/apps/testing"); + + if (!$isTestingAppEnabled) { + $this->sendingTo('DELETE', "/cloud/apps/testing"); + } + $this->currentUser = $previousUser; }