Skip to content

Commit

Permalink
added tests for reading content of a file by fileId using WebDav API
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya committed Aug 7, 2023
1 parent 8f70e63 commit e48828b
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
92 changes: 92 additions & 0 deletions tests/acceptance/features/apiContract/accessFileByFileId.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
@api
Feature: accessing files using file id
As a user
I want to access the files using file id
So that I can read or make changes on the file

Background:
Given using spaces DAV path
And user "Alice" has been created with default attributes and without skeleton files


Scenario Outline: get content of a file
Given user "Alice" has uploaded file with content "some data" to "/textfile.txt"
When user "Alice" gets the content of file "/textfile.txt" with URL "<destination-url>" using WebDav API
Then the HTTP status code should be "200"
And the content of the file should be "some data"
Examples:
| destination-url |
| /remote.php/dav/spaces/ |
| /dav/spaces/ |


Scenario Outline: get content of a file inside a folder
Given user "Alice" has created folder "uploadFolder"
And user "Alice" has uploaded file with content "some data" to "uploadFolder/textfile.txt"
When user "Alice" gets the content of file "uploadFolder/textfile.txt" with URL "<destination-url>" using WebDav API
Then the HTTP status code should be "200"
And the content of the file should be "some data"
Examples:
| destination-url |
| /remote.php/dav/spaces/ |
| /dav/spaces/ |



Scenario Outline: get content a file inside a project space
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "new-space" with content "some data" to "textfile.txt"
When user "Alice" gets the content of file "textfile.txt" inside space "new-space" with URL "<destination-url>" using WebDav API
Then the HTTP status code should be "200"
And the content of the file should be "some data"
Examples:
| destination-url |
| /remote.php/dav/spaces/ |
| /dav/spaces/ |


Scenario Outline: sharee gets content of a file shared by sharer
Given user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has uploaded file with content "some data" to "/textfile.txt"
And user "Alice" has shared file "/textfile.txt" with user "Brian"
And user "Brian" has accepted share "/textfile.txt" offered by user "Alice"
When user "Brian" gets the content of file "/textfile.txt" shared by user "Alice" with URL "<destination-url>" using WebDav API
Then the HTTP status code should be "200"
And the content of the file should be "some data"
Examples:
| destination-url |
| /remote.php/dav/spaces/ |
| /dav/spaces/ |


Scenario Outline: sharee gets content of a file inside a shared folder
Given user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has created folder "uploadFolder"
And user "Alice" has uploaded file with content "some data" to "uploadFolder/textfile.txt"
And user "Alice" has shared folder "/uploadFolder" with user "Brian"
And user "Brian" has accepted share "/uploadFolder" offered by user "Alice"
When user "Brian" gets the content of file "/uploadFolder/textfile.txt" shared by user "Alice" with URL "<destination-url>" using WebDav API
Then the HTTP status code should be "200"
And the content of the file should be "some data"
Examples:
| destination-url |
| /remote.php/dav/spaces/ |
| /dav/spaces/ |


Scenario Outline: sharee gets content of a file inside a shared space
Given user "Brian" has been created with default attributes and without skeleton files
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "new-space" with content "some data" to "textfile.txt"
And user "Alice" has shared a space "new-space" with settings:
| shareWith | Brian |
| role | editor |
When user "Brian" gets the content of file "/textfile.txt" inside space "new-space" shared by user "Alice" with URL "<destination-url>" using WebDav API
Then the HTTP status code should be "200"
And the content of the file should be "some data"
Examples:
| destination-url |
| /remote.php/dav/spaces/ |
| /dav/spaces/ |
53 changes: 53 additions & 0 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3329,4 +3329,57 @@ public function userDownloadsTheSpaceUsingTheWebdavApi(string $user, string $spa
)
);
}

/**
* @When user :user gets the content of file :fileName with URL :destinationUrl using WebDav API
* @When user :user gets the content of file :fileName inside space :spaceName with URL :destinationUrl using WebDav API
* @When user :user gets the content of file :fileName shared by user :sharer with URL :destinationUrl using WebDav API
* @When user :user gets the content of file :fileName inside space :spaceName shared by user :sharer with URL :destinationUrl using WebDav API
*
* @param string $user
* @param string $fileName
* @param string $destinationUrl
* @param string|null $spaceName
* @param string|null $sharer
*
* @return void
*/
public function userGetsTheContentOfFileUsingWebDavAPI(
string $user,
string $fileName,
string $destinationUrl,
?string $spaceName = null,
?string $sharer = null
): void {
$user = $sharer ?? $user;
$user = $this->featureContext->getActualUsername($user);

if ($spaceName === null) {
$fileId = $this->featureContext->getFileIdForPath($user, $fileName);
} else {
$fileId = $this->getFileId($user, $spaceName, $fileName);
}

$fullUrl = $this->featureContext->getBaseUrl() . $destinationUrl . $fileId;
$this->featureContext->setResponse(
HttpRequestHelper::sendRequest(
$fullUrl,
'',
'GET',
$user,
$this->featureContext->getPasswordForUser($user)
)
);
}

/**
* @Then the content of the file should be :expectedContent
*
* @param string $expectedContent
*
* @return void
*/
public function theContentOfTheFileShouldBe(string $expectedContent): void {
$this->featureContext->checkDownloadedContentMatches($expectedContent);
}
}

0 comments on commit e48828b

Please sign in to comment.