diff options
Diffstat (limited to 'build/integration/features/bootstrap')
-rw-r--r-- | build/integration/features/bootstrap/ExternalStorage.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/build/integration/features/bootstrap/ExternalStorage.php b/build/integration/features/bootstrap/ExternalStorage.php index 2a73f22c1b4..b1e4c92810b 100644 --- a/build/integration/features/bootstrap/ExternalStorage.php +++ b/build/integration/features/bootstrap/ExternalStorage.php @@ -48,7 +48,7 @@ trait ExternalStorage { * @param TableNode $fields */ public function loggedInUserCreatesExternalGlobalStorage(TableNode $fields): void { - $this->sendJsonWithRequestToken('POST', '/index.php/apps/files_external/globalstorages', $fields); + $this->sendJsonWithRequestTokenAndBasicAuth('POST', '/index.php/apps/files_external/globalstorages', $fields); $this->theHTTPStatusCodeShouldBe('201'); $this->lastExternalStorageData = json_decode($this->response->getBody(), $asAssociativeArray = true); @@ -62,7 +62,7 @@ trait ExternalStorage { * @param TableNode $fields */ public function loggedInUserUpdatesLastExternalUserglobalStorage(TableNode $fields): void { - $this->sendJsonWithRequestToken('PUT', '/index.php/apps/files_external/userglobalstorages/' . $this->lastExternalStorageData['id'], $fields); + $this->sendJsonWithRequestTokenAndBasicAuth('PUT', '/index.php/apps/files_external/userglobalstorages/' . $this->lastExternalStorageData['id'], $fields); $this->theHTTPStatusCodeShouldBe('200'); $this->lastExternalStorageData = json_decode($this->response->getBody(), $asAssociativeArray = true); @@ -100,4 +100,23 @@ trait ExternalStorage { ]; $this->sendingAToWithRequesttoken($method, $url, $body); } + + private function sendJsonWithRequestTokenAndBasicAuth(string $method, string $url, TableNode $fields): void { + $isFirstField = true; + $fieldsAsJsonString = '{'; + foreach ($fields->getRowsHash() as $key => $value) { + $fieldsAsJsonString .= ($isFirstField ? '' : ',') . '"' . $key . '":' . $value; + $isFirstField = false; + } + $fieldsAsJsonString .= '}'; + + $body = [ + 'headers' => [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Basic ' . base64_encode('admin:admin'), + ], + 'body' => $fieldsAsJsonString, + ]; + $this->sendingAToWithRequesttoken($method, $url, $body); + } } |