Skip to content

Commit

Permalink
send X-Request-Id in header of every request (#7085)
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya authored Sep 6, 2023
1 parent 8016d44 commit 0aa41d9
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 65 deletions.
2 changes: 1 addition & 1 deletion tests/TestHelpers/EmailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static function getBodyOfLastEmail(
$endTime = $currentTime + $waitTimeSec;
$mailBox = self::getMailBoxFromEmail($emailAddress);
while ($currentTime <= $endTime) {
$mailboxResponse = self::getMailboxInformation($mailBox);
$mailboxResponse = self::getMailboxInformation($mailBox, $xRequestId);
if (!empty($mailboxResponse) && \sizeof($mailboxResponse) >= $emailNumber) {
$mailboxId = $mailboxResponse[\sizeof($mailboxResponse) - $emailNumber]->id;
$response = self::getBodyOfAnEmailById($mailBox, $mailboxId, $xRequestId);
Expand Down
6 changes: 4 additions & 2 deletions tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ public static function deleteSpace(
* @param string $user
* @param string $password
* @param string $spaceId
* @param string $xRequestId
*
* @return ResponseInterface
* @throws GuzzleException
Expand All @@ -1000,13 +1001,14 @@ public static function restoreSpace(
string $baseUrl,
string $user,
string $password,
string $spaceId
string $spaceId,
string $xRequestId
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'drives/' . $spaceId);
$header = ["restore" => true];
$body = '{}';

return HttpRequestHelper::sendRequest($url, '', 'PATCH', $user, $password, $header, $body);
return HttpRequestHelper::sendRequest($url, $xRequestId, 'PATCH', $user, $password, $header, $body);
}

/**
Expand Down
1 change: 0 additions & 1 deletion tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ public static function propfind(
throw new InvalidArgumentException('Invalid depth value ' . $folderDepth);
}
$headers['Depth'] = $folderDepth;
$headers['X-Request-Id'] = WebDavHelper::generateUUIDv4();
return self::makeDavRequest(
$baseUrl,
$user,
Expand Down
6 changes: 3 additions & 3 deletions tests/acceptance/features/apiContract/copy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Copy test
When user "Alice" copies file "testfile.txt" from space "new-space" to "/new/testfile.txt" inside space "new-space" using the WebDAV API
Then the HTTP status code should be "201"
And the following headers should match these regular expressions
| Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ |
| Access-Control-Allow-Origin | /^[*]{1}$/ |
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ |
| Access-Control-Allow-Origin | /^[*]{1}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |

4 changes: 2 additions & 2 deletions tests/acceptance/features/apiContract/propfind.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Propfind test
When user "Alice" sends PROPFIND request to space "new-space" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "PROPFIND" response should contain a space "new-space" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:new-space |
Expand All @@ -36,7 +36,7 @@ Feature: Propfind test
When user "Brian" sends PROPFIND request to space "new-space" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "PROPFIND" response should contain a space "new-space" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:new-space |
Expand Down
6 changes: 3 additions & 3 deletions tests/acceptance/features/apiContract/sharesReport.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: REPORT request to Shares space
When user "Brian" searches for "SubFolder1" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:SubFolder1 |
Expand All @@ -42,7 +42,7 @@ Feature: REPORT request to Shares space
When user "Brian" searches for "frodo.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:SubFolder1/subFOLDER2/frodo.txt |
Expand All @@ -63,7 +63,7 @@ Feature: REPORT request to Shares space
When user "Brian" searches for "folderMain" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the search result should contain "0" entries
Examples:
| dav-path-version |
Expand Down
9 changes: 5 additions & 4 deletions tests/acceptance/features/apiContract/spacesReport.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: REPORT request to project space
And the search result of user "Alice" should contain only these entries:
| /testFile.txt |
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:testFile.txt |
Expand All @@ -41,7 +41,7 @@ Feature: REPORT request to project space
And the search result of user "Alice" should contain only these entries:
| /folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt |
Expand All @@ -60,7 +60,7 @@ Feature: REPORT request to project space
And the search result of user "Alice" should contain only these entries:
| /folderMain |
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:folderMain |
Expand All @@ -79,7 +79,8 @@ Feature: REPORT request to project space
And the search result of user "Alice" should contain only these entries:
| /folderMain/sub-folder |
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
Then the HTTP status code should be "207"
And the "REPORT" response to user "Alice" should contain a mountpoint "findData" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:folderMain/sub-folder |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: Report test
When user "Brian" searches for "SubFolder1" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:SubFolder1 |
Expand All @@ -49,7 +49,7 @@ Feature: Report test
When user "Brian" searches for "insideTheFolder.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:SubFolder1/subFOLDER2/insideTheFolder.txt |
Expand All @@ -69,5 +69,5 @@ Feature: Report test
When user "Brian" searches for "folderMain" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-f0-9!\-]{36}$/ |
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
And the search result should contain "0" entries
4 changes: 2 additions & 2 deletions tests/acceptance/features/bootstrap/ArchiverContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function downloadArchive(
$queryString = $this->getArchiverQueryString($owner, $resource, $addressType);
return HttpRequestHelper::get(
$this->featureContext->getBaseUrl() . '/archiver?' . $queryString,
'',
$this->featureContext->getStepLineRef(),
$downloader,
$this->featureContext->getPasswordForUser($downloader),
$headers
Expand Down Expand Up @@ -199,7 +199,7 @@ public function userDownloadsTheArchiveOfTheseItems(
$this->featureContext->setResponse(
HttpRequestHelper::get(
$this->featureContext->getBaseUrl() . '/archiver?' . $queryString,
'',
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
)
Expand Down
8 changes: 5 additions & 3 deletions tests/acceptance/features/bootstrap/NotificationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@ public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfPr
GraphHelper::getMySpaces(
$this->featureContext->getBaseUrl(),
$user,
$this->featureContext->getPasswordForUser($user)
$this->featureContext->getPasswordForUser($user),
'',
$this->featureContext->getStepLineRef()
)
);
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
Expand Down Expand Up @@ -541,7 +543,7 @@ public function userCreatesDeprovisioningNotification(
$user ? $this->featureContext->getPasswordForUser($user) : $this->featureContext->getAdminPassword(),
'POST',
$this->globalNotificationEndpointPath,
'',
$this->featureContext->getStepLineRef(),
json_encode($payload),
2
);
Expand Down Expand Up @@ -608,7 +610,7 @@ public function userDeletesDeprovisioningNotification(?string $user = null):void
$user ? $this->featureContext->getPasswordForUser($user) : $this->featureContext->getAdminPassword(),
'DELETE',
$this->globalNotificationEndpointPath,
'',
$this->featureContext->getStepLineRef(),
json_encode($payload),
2
);
Expand Down
3 changes: 1 addition & 2 deletions tests/acceptance/features/bootstrap/SearchContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function userSearchesUsingWebDavAPI(
$user = $this->featureContext->getActualUsername($user);
$baseUrl = $this->featureContext->getBaseUrl();
$password = $this->featureContext->getPasswordForUser($user);
$headers['X-Request-Id'] = WebDavHelper::generateUUIDv4();
$body
= "<?xml version='1.0' encoding='utf-8' ?>\n" .
" <oc:search-files xmlns:a='DAV:' xmlns:oc='http://owncloud.org/ns' >\n" .
Expand Down Expand Up @@ -103,7 +102,7 @@ public function userSearchesUsingWebDavAPI(
$password,
"REPORT",
"/",
$headers,
null,
$this->featureContext->getStepLineRef(),
$body,
$this->featureContext->getDavPathVersion()
Expand Down
12 changes: 6 additions & 6 deletions tests/acceptance/features/bootstrap/SettingsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function before(BeforeScenarioScope $scope): void {
public function getAllExistingRoles(string $user): void {
$fullUrl = $this->baseUrl . $this->settingsUrl . "roles-list";
$this->featureContext->setResponse(
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), "{}")
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), "{}", $this->featureContext->getStepLineRef())
);
}

Expand All @@ -77,7 +77,7 @@ public function sendRequestToAssignRoleToUser(string $user, string $userId, stri
$body = json_encode(["account_uuid" => $userId, "role_id" => $roleId], JSON_THROW_ON_ERROR);

$this->featureContext->setResponse(
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body)
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body, $this->featureContext->getStepLineRef())
);
}

Expand All @@ -93,7 +93,7 @@ public function sendRequestToAssignRoleToUser(string $user, string $userId, stri
public function sendRequestAssignmentsList(string $user, string $userId): ResponseInterface {
$fullUrl = $this->baseUrl . $this->settingsUrl . "assignments-list";
$body = json_encode(["account_uuid" => $userId], JSON_THROW_ON_ERROR);
return $this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body);
return $this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body, $this->featureContext->getStepLineRef());
}

/**
Expand Down Expand Up @@ -271,7 +271,7 @@ public function theSettingApiResponseShouldHaveTheRole(string $role): void {
public function sendRequestGetBundlesList(string $user): void {
$fullUrl = $this->baseUrl . $this->settingsUrl . "bundles-list";
$this->featureContext->setResponse(
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), '{}')
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), '{}', $this->featureContext->getStepLineRef())
);

$this->featureContext->theHTTPStatusCodeShouldBe(
Expand Down Expand Up @@ -312,7 +312,7 @@ public function sendRequestGetSettingsValuesList(string $user): void {
$fullUrl = $this->baseUrl . $this->settingsUrl . "values-list";
$body = json_encode(["account_uuid" => "me"], JSON_THROW_ON_ERROR);
$this->featureContext->setResponse(
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body)
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body, $this->featureContext->getStepLineRef())
);

Assert::assertEquals(
Expand Down Expand Up @@ -392,7 +392,7 @@ public function sendRequestToSwitchSystemLanguage(string $user, string $language
);

$this->featureContext->setResponse(
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body)
$this->spacesContext->sendPostRequestToUrl($fullUrl, $user, $this->featureContext->getPasswordForUser($user), $body, $this->featureContext->getStepLineRef())
);
}

Expand Down
Loading

0 comments on commit 0aa41d9

Please sign in to comment.