Skip to content

Commit

Permalink
added spaces examples for tus upload features
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Feb 1, 2022
1 parent 75979aa commit c16faa6
Show file tree
Hide file tree
Showing 15 changed files with 401 additions and 32 deletions.
15 changes: 13 additions & 2 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use InvalidArgumentException;
use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use DateTime;
Expand Down Expand Up @@ -671,6 +672,7 @@ public static function getMtimeOfFileinPublicLinkShare(
* @param string|null $baseUrl
* @param string|null $resource
* @param string|null $xRequestId
* @param int|null $davPathVersionToUse
*
* @return string
* @throws Exception
Expand All @@ -680,21 +682,30 @@ public static function getMtimeOfResource(
?string $password,
?string $baseUrl,
?string $resource,
?string $xRequestId = ''
?string $xRequestId = '',
?int $davPathVersionToUse = 2
):string {
$response = self::propfind(
$baseUrl,
$user,
$password,
$resource,
["getlastmodified"],
$xRequestId
$xRequestId,
"0",
"files",
$davPathVersionToUse
);
$responseXmlObject = HttpRequestHelper::getResponseXml(
$response,
__METHOD__
);
$xmlpart = $responseXmlObject->xpath("//d:getlastmodified");
Assert::assertArrayHasKey(
0,
$xmlpart,
__METHOD__ . " XML part does not have key 0. Expected a value at index 0 of 'xmlPart' but, found: " . (string) json_encode($xmlpart)
);
$mtime = new DateTime($xmlpart[0]->__toString());
return $mtime->format('U');
}
Expand Down
67 changes: 66 additions & 1 deletion tests/acceptance/features/apiWebdavUploadTUS/checksums.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Feature: checksums
| old | SHA1 8cb2237d0679ca88db6464eac60da96345513964 |
| new | SHA1 8cb2237d0679ca88db6464eac60da96345513964 |

@personalSpace
Examples:
| dav_version | checksum |
| spaces | MD5 827ccb0eea8a706c4c34a16891f84e7b |
| spaces | SHA1 8cb2237d0679ca88db6464eac60da96345513964 |


Scenario Outline: Uploading a file with checksum should return the checksum in the propfind
Given using <dav_version> DAV path
Expand All @@ -35,6 +41,11 @@ Feature: checksums
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |


Scenario Outline: Uploading a file with checksum should return the checksum in the download header
Given using <dav_version> DAV path
Expand All @@ -50,6 +61,11 @@ Feature: checksums
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |


Scenario Outline: Uploading a file with incorrect checksum should not work
Given using <dav_version> DAV path
Expand All @@ -67,6 +83,12 @@ Feature: checksums
| old | SHA1 8cb2237d0679ca88db6464eac60da96345513963 |
| new | SHA1 8cb2237d0679ca88db6464eac60da96345513963 |

@personalSpace
Examples:
| dav_version | incorrect_checksum |
| spaces | MD5 827ccb0eea8a706c4c34a16891f84e7a |
| spaces | SHA1 8cb2237d0679ca88db6464eac60da96345513963 |


Scenario Outline: Uploading a chunked file with correct checksum should work
Given using <dav_version> DAV path
Expand All @@ -83,6 +105,11 @@ Feature: checksums
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |


Scenario Outline: Uploading a chunked file with correct checksum should return the checksum in the propfind
Given using <dav_version> DAV path
Expand All @@ -99,6 +126,11 @@ Feature: checksums
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |


Scenario Outline: Uploading a chunked file with checksum should return the checksum in the download header
Given using <dav_version> DAV path
Expand All @@ -115,6 +147,11 @@ Feature: checksums
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |


Scenario Outline: Uploading second chunk of file with incorrect checksum should not work
Given using <dav_version> DAV path
Expand All @@ -131,6 +168,11 @@ Feature: checksums
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |


Scenario Outline: Uploading a file with correct checksum and overwriting an existing file should return the checksum for new data in the propfind
Given using <dav_version> DAV path
Expand All @@ -153,6 +195,11 @@ Feature: checksums
| old | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |
| new | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |

@personalSpace
Examples:
| dav_version | overwriteChecksum |
| spaces | MD5 5d41402abc4b2a76b9719d911017c592 |
| spaces | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |

Scenario Outline: Uploading a file with correct checksum and overwriting an existing file with invalid checksum should not work
Given using <dav_version> DAV path
Expand All @@ -174,8 +221,14 @@ Feature: checksums
| old | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434a |
| new | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434a |

@personalSpace
Examples:
| dav_version | overwriteInvalidChecksum |
| spaces | MD5 5d41402abc4b2a76b9719d911017c593 |
| spaces | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434a |


Scenario Outline: Overwriting an existing file with new data and checksum should return the checksum of new data in the propfind
Scenario Outline: Overwriting an existing file with new data and checksum should return the checksum of new data in the propfind
Given using <dav_version> DAV path
And user "Alice" has created a new TUS resource on the WebDAV API with these headers:
| Upload-Length | 5 |
Expand All @@ -196,6 +249,12 @@ Scenario Outline: Overwriting an existing file with new data and checksum should
| old | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |
| new | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |

@personalSpace
Examples:
| dav_version | overwriteChecksum |
| spaces | MD5 5d41402abc4b2a76b9719d911017c592 |
| spaces | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |


Scenario Outline: Overwriting an existing file with new data and invalid checksum should not work
Given using <dav_version> DAV path
Expand All @@ -216,3 +275,9 @@ Scenario Outline: Overwriting an existing file with new data and checksum should
| new | MD5 5d41402abc4b2a76b9719d911017c593 |
| old | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434a |
| new | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434a |

@personalSpace
Examples:
| dav_version | overwriteChecksum |
| spaces | MD5 5d41402abc4b2a76b9719d911017c593 |
| spaces | SHA1 aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434a |
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Feature: tests of the creation extension see https://tus.io/protocols/resumable-
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |


Scenario Outline: creating a new resource and upload data in multiple bytes using creation with upload extension
Given using <dav_version> DAV path
Expand All @@ -31,3 +36,8 @@ Feature: tests of the creation extension see https://tus.io/protocols/resumable-
| dav_version |
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Feature: low level tests of the creation extension see https://tus.io/protocols/
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |

Scenario Outline: creating a new upload resource without upload length
Given using <dav_version> DAV path
Expand All @@ -35,3 +39,8 @@ Feature: low level tests of the creation extension see https://tus.io/protocols/
| dav_version |
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Feature: low level tests for upload of chunks
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |



Scenario Outline: finalize file upload after uploading a chunk twice
Given using <dav_version> DAV path
Expand All @@ -37,6 +43,10 @@ Feature: low level tests for upload of chunks
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |

Scenario Outline: send last chunk twice
Given using <dav_version> DAV path
Expand All @@ -54,6 +64,10 @@ Feature: low level tests for upload of chunks
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |

Scenario Outline: start with uploading not at the beginning of the file
Given using <dav_version> DAV path
Expand All @@ -68,3 +82,8 @@ Feature: low level tests for upload of chunks
| dav_version |
| old |
| new |

@personalSpace
Examples:
| dav_version |
| spaces |
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ Feature: OPTIONS request
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |

@personalSpace
Scenario: send OPTIONS request to spaces webDav endpoint using the TUS protocol with valid password and username
When user "Alice" requests these endpoints with "OPTIONS" including body "doesnotmatter" using the password of user "Alice"
| endpoint |
| /remote.php/dav/spaces/%spaceid%/ |
Then the following headers should be set
| header | value |
| Tus-Resumable | 1.0.0 |
| Tus-Version | 1.0.0 |
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |

Scenario: send OPTIONS request to webDav endpoints using the TUS protocol without any authentication
When a user requests these endpoints with "OPTIONS" with body "doesnotmatter" and no authentication about user "Alice"
Expand All @@ -29,6 +40,17 @@ Feature: OPTIONS request
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |

@personalSpace
Scenario: send OPTIONS request to spaces webDav endpoint using the TUS protocol without any authentication
When a user requests these endpoints with "OPTIONS" with body "doesnotmatter" and no authentication about user "Alice"
| endpoint |
| /remote.php/dav/spaces/%spaceid%/ |
Then the following headers should be set
| header | value |
| Tus-Resumable | 1.0.0 |
| Tus-Version | 1.0.0 |
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |

Scenario: send OPTIONS request to webDav endpoints using the TUS protocol with valid username and wrong password
When user "Alice" requests these endpoints with "OPTIONS" including body "doesnotmatter" using password "invalid" about user "Alice"
Expand All @@ -42,6 +64,17 @@ Feature: OPTIONS request
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |

@personalSpace
Scenario: send OPTIONS request to spaces webDav endpoint using the TUS protocol with valid username and wrong password
When user "Alice" requests these endpoints with "OPTIONS" including body "doesnotmatter" using password "invalid" about user "Alice"
| endpoint |
| /remote.php/dav/spaces/%spaceid%/ |
Then the following headers should be set
| header | value |
| Tus-Resumable | 1.0.0 |
| Tus-Version | 1.0.0 |
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |

Scenario: send OPTIONS requests to webDav endpoints using valid password and username of different user
Given user "Brian" has been created with default attributes and without skeleton files
Expand All @@ -55,3 +88,16 @@ Feature: OPTIONS request
| Tus-Version | 1.0.0 |
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |

@personalSpace
Scenario: send OPTIONS requests to spaces webDav endpoints using valid password and username of different user
Given user "Brian" has been created with default attributes and without skeleton files
When user "Brian" requests these endpoints with "OPTIONS" including body "doesnotmatter" using the password of user "Alice"
| endpoint |
| /remote.php/dav/spaces/%spaceid%/ |
Then the following headers should be set
| header | value |
| Tus-Resumable | 1.0.0 |
| Tus-Version | 1.0.0 |
| Tus-Extension | creation,creation-with-upload,checksum,expiration |
| Tus-Checksum-Algorithm | md5,sha1,adler32 |
Loading

0 comments on commit c16faa6

Please sign in to comment.