Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webDAV acceptance tests for upload-download-propfind of unusual file names #32010

Merged
merged 1 commit into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions tests/acceptance/features/apiWebdav/webdav-related.feature
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ Feature: webdav-related
| old |
| new |

Scenario Outline: download a file
Given using <dav_version> DAV path
And user "user0" has been created
When user "user0" downloads the file "/textfile0.txt" using the API
Then the downloaded content should be "ownCloud test text file" plus end-of-line
Examples:
| dav_version |
| old |
| new |

Scenario Outline: download a file with range
Given using <dav_version> DAV path
And user "user0" has been created
Expand All @@ -175,6 +185,110 @@ Feature: webdav-related
| old |
| new |

Scenario Outline: upload a file and check download content
Given using <dav_version> DAV path
And user "user0" has been created
When user "user0" uploads file with content "uploaded content" to "<file_name>" using the API
Then the content of file "<file_name>" for user "user0" should be "uploaded content"
Examples:
| dav_version | file_name |
| old | /upload.txt |
| old | /strängé file.txt |
| old | /C++ file.cpp |
| old | /नेपाली.txt |
| old | /file #2.txt |
| old | /file ?2.txt |
| new | /upload.txt |
| new | /strängé file.txt |
| new | /C++ file.cpp |
| new | /नेपाली.txt |
| new | /file #2.txt |
| new | /file ?2.txt |

Scenario Outline: create a folder
Given using <dav_version> DAV path
And user "user0" has been created
When user "user0" creates a folder "<folder_name>" using the API
Then as "user0" the folder "<folder_name>" should exist
Examples:
| dav_version | folder_name |
| old | /upload |
| old | /strängé folder |
| old | /C++ folder.cpp |
| old | /नेपाली |
| old | /folder #2 |
| old | /folder ?2 |
| new | /upload |
| new | /strängé folder |
| new | /C++ folder.cpp |
| new | /नेपाली |
| new | /folder #2 |
| new | /folder ?2 |

Scenario Outline: upload a file into a folder and check download content
Given using <dav_version> DAV path
And user "user0" has been created
And user "user0" has created a folder "<folder_name>"
When user "user0" uploads file with content "uploaded content" to "<folder_name>/<file_name>" using the API
Then the content of file "<folder_name>/<file_name>" for user "user0" should be "uploaded content"
Examples:
| dav_version | folder_name | file_name |
| old | /upload | abc.txt |
| old | /strängé folder | strängé file.txt |
| old | /C++ folder | C++ file.cpp |
| old | /नेपाली | नेपाली |
| old | /folder #2.txt | file #2.txt |
| old | /folder ?2.txt | file ?2.txt |
| new | /upload | abc.txt |
| new | /strängé folder (duplicate #2 &) | strängé file (duplicate #2 &) |
| new | /C++ folder | C++ file.cpp |
| new | /नेपाली | नेपाली |
| new | /folder #2.txt | file #2.txt |
| new | /folder ?2.txt | file ?2.txt |

Scenario Outline: Do a PROPFIND of various file names
Given using <dav_version> DAV path
And user "user0" has been created
And user "user0" has uploaded file with content "uploaded content" to "<file_name>"
When user "user0" gets the properties of file "<file_name>" using the API
Then the properties response should contain an etag
Examples:
| dav_version | file_name |
| old | /upload.txt |
| old | /strängé file.txt |
| old | /C++ file.cpp |
| old | /नेपाली.txt |
| old | /file #2.txt |
| old | /file ?2.txt |
| new | /upload.txt |
| new | /strängé file.txt |
| new | /C++ file.cpp |
| new | /नेपाली.txt |
| new | /file #2.txt |
| new | /file ?2.txt |

Scenario Outline: Do a PROPFIND of various folder/file names
Given using <dav_version> DAV path
And user "user0" has been created
And user "user0" has created a folder "<folder_name>"
And user "user0" has uploaded file with content "uploaded content" to "<folder_name>/<file_name>"
When user "user0" gets the properties of file "<folder_name>/<file_name>" using the API
Then the properties response should contain an etag
Examples:
| dav_version | folder_name | file_name |
| old | /upload | abc.txt |
| old | /strängé folder | strängé file.txt |
| old | /C++ folder | C++ file.cpp |
| old | /नेपाली | नेपाली |
| old | /folder #2.txt | file #2.txt |
| old | /folder ?2.txt | file ?2.txt |
| new | /upload | abc.txt |
| new | /strängé folder (duplicate #2 &) | strängé file (duplicate #2 &) |
| new | /C++ folder | C++ file.cpp |
| new | /नेपाली | नेपाली |
| new | /folder #2.txt | file #2.txt |
| new | /folder ?2.txt | file ?2.txt |

Scenario Outline: Retrieving folder quota when no quota is set
Given using <dav_version> DAV path
And user "user0" has been created
Expand Down
51 changes: 50 additions & 1 deletion tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,19 @@ public function downloadedContentShouldBe($content) {
);
}

/**
* @Then /^the downloaded content should be "([^"]*)" plus end-of-line$/
*
* @param string $fileName
* @param string $user
* @param string $content
*
* @return void
*/
public function downloadedContentShouldBePlusEndOfLine($content) {
$this->downloadedContentShouldBe($content . "\n");
}

/**
* @Then /^the content of file "([^"]*)" should be "([^"]*)"$/
*
Expand Down Expand Up @@ -575,6 +588,22 @@ public function downloadedContentShouldStartWith($start) {
}
}

/**
* @When /^user "([^"]*)" gets the properties of (?:file|folder|entry) "([^"]*)" using the API$/
*
* @param string $user
* @param string $path
*
* @return void
*/
public function userGetsThePropertiesOfFolder(
$user, $path
) {
$this->response = $this->listFolder(
$user, $path, 0, []
);
}

/**
* @When /^user "([^"]*)" gets the following properties of (?:file|folder|entry) "([^"]*)" using the API$/
*
Expand Down Expand Up @@ -699,13 +728,33 @@ public function asTheFileOrFolderShouldNotExist($user, $entry, $path) {
*/
public function asTheFileOrFolderShouldExist($user, $entry, $path) {
$this->response = $this->listFolder($user, $path, 0);
if (!\is_array($this->response) || !isset($this->response['{DAV:}getetag'])) {
try {
$this->thePropertiesResponseShouldContainAnEtag();
} catch (\Exception $e) {
throw new \Exception(
$entry . ' "' . $path . '" expected to exist but not found'
);
}
}

/**
* @Then /^the properties response should contain an etag$/
*
* @param string $user
* @param string $entry
* @param string $path
*
* @return void
* @throws \Exception
*/
public function thePropertiesResponseShouldContainAnEtag() {
if (!\is_array($this->response) || !isset($this->response['{DAV:}getetag'])) {
throw new \Exception(
"getetag not found in response"
);
}
}

/**
* @Then the single response should contain a property :key with value :value
*
Expand Down