[test-only] add test for uploading with Tus using CORS (#8508)

* add test for uploading with Tus using CORS

* fix
This commit is contained in:
Viktor Scharf
2024-02-23 11:47:52 +01:00
committed by GitHub
parent 3cea035d6d
commit ad7cf8f77a
4 changed files with 70 additions and 7 deletions
@@ -116,27 +116,31 @@ class TUSContext implements Context {
* @param string $offset
* @param string $data
* @param string $checksum
* @param array|null $extraHeaders
*
* @return ResponseInterface
*
* @throws GuzzleException
* @throws JsonException
*/
public function sendsAChunkToTUSLocationWithOffsetAndData(string $user, string $offset, string $data, string $checksum = ''): ResponseInterface {
public function sendsAChunkToTUSLocationWithOffsetAndData(string $user, string $offset, string $data, string $checksum = '', ?array $extraHeaders = null): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$password = $this->featureContext->getUserPassword($user);
$headers = [
'Content-Type' => 'application/offset+octet-stream',
'Tus-Resumable' => '1.0.0',
'Upload-Checksum' => $checksum,
'Upload-Offset' => $offset
];
$headers = empty($extraHeaders) ? $headers : array_merge($headers, $extraHeaders);
return HttpRequestHelper::sendRequest(
$this->resourceLocation,
$this->featureContext->getStepLineRef(),
'PATCH',
$user,
$password,
[
'Content-Type' => 'application/offset+octet-stream',
'Tus-Resumable' => '1.0.0',
'Upload-Checksum' => $checksum,
'Upload-Offset' => $offset
],
$headers,
$data
);
}