Skip to content

Commit

Permalink
add test to delete file by id
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Aug 8, 2024
1 parent 04c2b4a commit 0dea182
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ public static function makeDavRequest(
$urlParameter = \http_build_query($urlParameter, '', '&');
$path .= '?' . $urlParameter;
}

$fullUrl = self::sanitizeUrl($baseUrl . "/$davPath" . $path);

if ($authType === 'bearer') {
Expand Down
24 changes: 24 additions & 0 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -2700,6 +2700,30 @@ public function userDeletesFile(string $user, string $resource):void {
$this->pushToLastStatusCodesArrays();
}

/**
* @When user :user deletes file :filename from space :space by file-id using the WebDAV API
*
* @param string $user
* @param string $filename
* @param string $space
*
* @return void
*/
public function deleteFileById(string $user, string $filename, string $space):void {
$resourceId = $this->spacesContext->getFileId($user, $space, $filename);
$requestUrl = $this->getBaseUrl() . "/" . $this->getSpacesDavPath() . "/" . $resourceId;
$password = $this->getPasswordForUser($user);
$response = HttpRequestHelper::sendRequest(
$requestUrl,
null,
'DELETE',
$user,
$password
);
$this->setResponse($response);
$this->pushToLastStatusCodesArrays();
}

/**
* @Given /^user "([^"]*)" has deleted (?:file|folder|entity) "([^"]*)"$/
*
Expand Down
10 changes: 10 additions & 0 deletions tests/acceptance/features/coreApiWebdavDelete/deleteFile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,13 @@ Feature: delete file
When user "Alice" deletes file "/zerobyte.txt" using the WebDAV API
Then the HTTP status code should be "204"
And as "Alice" file "/zerobyte.txt" should not exist


Scenario: delete a file using file-id
Given using spaces DAV path
And user "Alice" has uploaded file with content "special file" to "/textfile.txt"
And as "Alice" file "/textfile.txt" should exist
When user "Alice" deletes file "/textfile.txt" from space "Personal" by file-id using the WebDAV API
Then the HTTP status code should be "204"
And as "Alice" file "/textfile.txt" should not exist

0 comments on commit 0dea182

Please sign in to comment.