Files

285 lines
17 KiB
Gherkin
Raw Permalink Normal View History

2023-01-02 17:26:54 +05:45
Feature: download file
As a user
I want to be able to download files
So that I can work wih local copies of files on my client system
Background:
Given user "Alice" has been created with default attributes
2023-01-02 17:26:54 +05:45
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt"
And user "Alice" has uploaded file with content "Welcome this is just an example file for developers." to "/welcome.txt"
@smokeTest
Scenario Outline: download a file
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/textfile0.txt" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "ownCloud test text file 0"
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
@issue-1346
2023-01-02 17:26:54 +05:45
Scenario Outline: download a file with range
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/welcome.txt" with range "bytes=24-50" using the WebDAV API
Then the HTTP status code should be "206"
And the downloaded content should be "example file for developers"
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
Scenario Outline: download a file larger than 4MB (ref: https://github.com/sabre-io/http/pull/119 )
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
And user "Alice" has uploaded file "/file9000000.txt" ending with "text at end of file" of size 9000000 bytes
When user "Alice" downloads file "/file9000000.txt" using the WebDAV API
Then the HTTP status code should be "200"
And the size of the downloaded file should be 9000000 bytes
And the downloaded content should end with "text at end of file"
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
2023-06-05 17:18:44 +05:45
Scenario Outline: get the size of a file
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
And user "Alice" has uploaded file with content "This is a test file" to "test-file.txt"
When user "Alice" gets the size of file "test-file.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the size of the file should be "19"
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
@issue-1316
2023-06-05 17:18:44 +05:45
Scenario Outline: get the content-length response header of a pdf file
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
And user "Alice" has uploaded file "filesForUpload/simple.pdf" to "/simple.pdf"
When user "Alice" downloads file "/simple.pdf" using the WebDAV API
Then the HTTP status code should be "200"
And the following headers should be set
| header | value |
| Content-Length | 9622 |
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
@issue-1316
2023-06-05 17:18:44 +05:45
Scenario Outline: get the content-length response header of an image file
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
And user "Alice" has uploaded file "filesForUpload/testavatar.png" to "/testavatar.png"
When user "Alice" downloads file "/testavatar.png" using the WebDAV API
Then the HTTP status code should be "200"
And the following headers should be set
| header | value |
| Content-Length | 35323 |
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
2023-06-05 17:18:44 +05:45
Scenario Outline: download a file with comma in the filename
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file with content "file with comma in filename" to <file-name>
When user "Alice" downloads file <file-name> using the WebDAV API
2023-01-02 17:26:54 +05:45
Then the HTTP status code should be "200"
And the downloaded content should be "file with comma in filename"
Examples:
| dav-path-version | file-name |
2023-07-12 12:42:32 +05:45
| old | "sample,1.txt" |
| old | ",,,.txt" |
| old | ",,,.," |
| new | "sample,1.txt" |
| new | ",,,.txt" |
| new | ",,,.," |
| spaces | "sample,1.txt" |
| spaces | ",,,.txt" |
| spaces | ",,,.," |
2023-01-02 17:26:54 +05:45
Scenario Outline: download a file with single part ranges
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/welcome.txt" with range "bytes=0-51" using the WebDAV API
Then the HTTP status code should be "206"
And the following headers should be set
| header | value |
| Content-Length | 52 |
| Content-Range | bytes 0-51/52 |
And the downloaded content should be "Welcome this is just an example file for developers."
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
Scenario Outline: download a file with multipart ranges
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/welcome.txt" with range "bytes=0-6, 40-51" using the WebDAV API
Then the HTTP status code should be "206" or "200"
And if the HTTP status code was "206" then the following headers should match these regular expressions
| Content-Length | /\d+/ |
| Content-Type | /^multipart\/byteranges; boundary=[a-zA-Z0-9_.-]*$/ |
And if the HTTP status code was "206" then the downloaded content for multipart byterange should be:
"""
2024-06-06 13:46:15 +02:00
Content-Range: bytes 0-6/52
Content-Type: text/plain;charset=UTF-8
2023-01-02 17:26:54 +05:45
Welcome
2024-06-06 13:46:15 +02:00
Content-Range: bytes 40-51/52
Content-Type: text/plain;charset=UTF-8
2023-01-02 17:26:54 +05:45
developers.
"""
But if the HTTP status code was "200" then the downloaded content should be "Welcome this is just an example file for developers."
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
Scenario Outline: download a file with last byte range out of bounds
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/welcome.txt" with range "bytes=0-55" using the WebDAV API
Then the HTTP status code should be "206"
And the downloaded content should be "Welcome this is just an example file for developers."
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
Scenario Outline: download a range at the end of a file
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/welcome.txt" with range "bytes=-11" using the WebDAV API
Then the HTTP status code should be "206"
And the downloaded content should be "developers."
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
Scenario Outline: download a file with range out of bounds
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/welcome.txt" with range "bytes=55-60" using the WebDAV API
Then the HTTP status code should be "416"
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
Scenario Outline: download hidden files
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
2023-01-02 17:26:54 +05:45
And user "Alice" has created folder "/FOLDER"
And user "Alice" has uploaded the following files with content "hidden file"
| path |
| .hidden_file |
| /FOLDER/.hidden_file |
When user "Alice" downloads the following files using the WebDAV API
| path |
| .hidden_file |
| /FOLDER/.hidden_file |
Then the HTTP status code of responses on all endpoints should be "200"
And the content of the following files for user "Alice" should be "hidden file"
| path |
| .hidden_file |
| /FOLDER/.hidden_file |
Examples:
2023-07-12 12:42:32 +05:45
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
@smokeTest @issue-8361 @skipOnReva
2023-06-05 17:18:44 +05:45
Scenario Outline: downloading a file should serve security headers
2023-07-12 12:42:32 +05:45
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file with content "test file" to "/<file-name>"
When user "Alice" downloads file "/<file-name>" using the WebDAV API
2023-01-02 17:26:54 +05:45
Then the HTTP status code should be "200"
And the following headers should be set
2024-08-19 09:41:15 +02:00
| header | value |
| Content-Disposition | attachment; filename*=UTF-8''<encoded-file-name>; filename="<file-name>" |
| Content-Security-Policy | child-src 'self'; connect-src 'self' blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/ https://marketplace.owncloud.com/; default-src 'none'; font-src 'self' data:; frame-ancestors 'self'; frame-src 'self' blob: https://embed.diagrams.net/; img-src 'self' data: blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/ https://marketplace.owncloud.com/; manifest-src 'self'; media-src 'self'; object-src 'self' blob:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' |
2024-08-19 09:41:15 +02:00
| X-Content-Type-Options | nosniff |
| X-Frame-Options | SAMEORIGIN |
| X-Permitted-Cross-Domain-Policies | none |
| X-Robots-Tag | none |
And the downloaded content should be "test file"
2023-01-02 17:26:54 +05:45
Examples:
| dav-path-version | file-name | encoded-file-name |
| old | textfile.txt | textfile.txt |
| old | comma,.txt | comma%2C.txt |
| old | 'quote'single'.txt | %27quote%27single%27.txt |
| new | textfile.txt | textfile.txt |
| new | comma,.txt | comma%2C.txt |
| new | 'quote'single'.txt | %27quote%27single%27.txt |
| spaces | textfile.txt | textfile.txt |
| spaces | comma,.txt | comma%2C.txt |
| spaces | 'quote'single'.txt | %27quote%27single%27.txt |
@smokeTest @issue-8361 @skipOnReva
Scenario Outline: downloading a file should serve security headers (file with double quotes)
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file with content "test file" to '/"quote"double".txt'
When user "Alice" downloads file '/"quote"double".txt' using the WebDAV API
Then the HTTP status code should be "200"
And the following headers should be set
2024-08-19 09:41:15 +02:00
| header | value |
| Content-Disposition | attachment; filename*=UTF-8''%22quote%22double%22.txt; filename=""quote"double".txt" |
| Content-Security-Policy | child-src 'self'; connect-src 'self' blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/ https://marketplace.owncloud.com/; default-src 'none'; font-src 'self' data:; frame-ancestors 'self'; frame-src 'self' blob: https://embed.diagrams.net/; img-src 'self' data: blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/ https://marketplace.owncloud.com/; manifest-src 'self'; media-src 'self'; object-src 'self' blob:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' |
2024-08-19 09:41:15 +02:00
| X-Content-Type-Options | nosniff |
| X-Frame-Options | SAMEORIGIN |
| X-Permitted-Cross-Domain-Policies | none |
| X-Robots-Tag | none |
And the downloaded content should be "test file"
Examples:
| dav-path-version |
| old |
| new |
| spaces |
2023-01-02 17:26:54 +05:45
Scenario Outline: download a zero byte size file
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/zerobyte.txt" to "/zerobyte.txt"
2023-01-02 17:26:54 +05:45
When user "Alice" downloads file "/zerobyte.txt" using the WebDAV API
Then the HTTP status code should be "200"
And the size of the downloaded file should be 0 bytes
Examples:
| dav-path-version |
| old |
| new |
| spaces |
Scenario Outline: try to download recently deleted file
Given using <dav-path-version> DAV path
When user "Alice" deletes file "textfile0.txt" using the WebDAV API
Then the HTTP status code should be "204"
When user "Alice" tries to download file "textfile0.txt" using the WebDAV API
Then the HTTP status code should be "404"
Examples:
| dav-path-version |
| old |
| new |
| spaces |