aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2024-11-28 11:12:29 +0100
committerLouis Chemineau <louis@chmn.me>2024-11-28 11:12:29 +0100
commitd6fa2100e1cda004dd7b0b682b7e465d9fa830fa (patch)
tree53ff31373fde2ebe2d120aeabb0d230af2323447 /build
parent512f3caf570304e9714e4dcca9036c6cec8f4efb (diff)
downloadnextcloud-server-d6fa2100e1cda004dd7b0b682b7e465d9fa830fa.tar.gz
nextcloud-server-d6fa2100e1cda004dd7b0b682b7e465d9fa830fa.zip
test(ExternalStorage): Send basic auth during integrations tests
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'build')
-rw-r--r--build/integration/features/bootstrap/ExternalStorage.php23
-rw-r--r--build/integration/files_features/external-storage.feature34
2 files changed, 38 insertions, 19 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);
+ }
}
diff --git a/build/integration/files_features/external-storage.feature b/build/integration/files_features/external-storage.feature
index d313cfb3287..77abeb6c5a4 100644
--- a/build/integration/files_features/external-storage.feature
+++ b/build/integration/files_features/external-storage.feature
@@ -17,14 +17,14 @@ Feature: external-storage
And As an "user1"
And accepting last share
When creating a share with
- | path | foo |
- | shareType | 3 |
+ | path | foo |
+ | shareType | 3 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
- | id | A_NUMBER |
- | url | AN_URL |
- | token | A_TOKEN |
+ | id | A_NUMBER |
+ | url | AN_URL |
+ | token | A_TOKEN |
| mimetype | httpd/unix-directory |
Scenario: Shares don't overwrite external storage
@@ -69,9 +69,9 @@ Feature: external-storage
Scenario: Save an external storage with password provided by user
Given Logging in using web as "admin"
And logged in user creates external global storage
- | mountPoint | "ExternalStorageTest" |
- | backend | "owncloud" |
- | authMechanism | "password::userprovided" |
+ | mountPoint | "ExternalStorageTest" |
+ | backend | "owncloud" |
+ | authMechanism | "password::userprovided" |
| backendOptions | {"host":"http://localhost:8080","secure":false} |
And fields of last external storage match with
| status | 2 |
@@ -83,9 +83,9 @@ Feature: external-storage
Scenario: Save an external storage again with an unmodified password provided by user
Given Logging in using web as "admin"
And logged in user creates external global storage
- | mountPoint | "ExternalStorageTest" |
- | backend | "owncloud" |
- | authMechanism | "password::userprovided" |
+ | mountPoint | "ExternalStorageTest" |
+ | backend | "owncloud" |
+ | authMechanism | "password::userprovided" |
| backendOptions | {"host":"http://localhost:8080","secure":false} |
And fields of last external storage match with
| status | 2 |
@@ -99,9 +99,9 @@ Feature: external-storage
Scenario: Save an external storage with global credentials provided by user
Given Logging in using web as "admin"
And logged in user creates external global storage
- | mountPoint | "ExternalStorageTest" |
- | backend | "owncloud" |
- | authMechanism | "password::global::user" |
+ | mountPoint | "ExternalStorageTest" |
+ | backend | "owncloud" |
+ | authMechanism | "password::global::user" |
| backendOptions | {"host":"http://localhost:8080","secure":false} |
And fields of last external storage match with
| status | 2 |
@@ -113,9 +113,9 @@ Feature: external-storage
Scenario: Save an external storage again with unmodified global credentials provided by user
Given Logging in using web as "admin"
And logged in user creates external global storage
- | mountPoint | "ExternalStorageTest" |
- | backend | "owncloud" |
- | authMechanism | "password::global::user" |
+ | mountPoint | "ExternalStorageTest" |
+ | backend | "owncloud" |
+ | authMechanism | "password::global::user" |
| backendOptions | {"host":"http://localhost:8080","secure":false} |
And fields of last external storage match with
| status | 2 |