Skip to content

Commit 2a233b1

Browse files
committed
test(Sharing): Integration test for no expiration set date for share
- Verify that explicitly sending empty `expireDate` param to server overwrite default and sets not expiry date, if non is enforced. - Update tests to avoid converting empty string to date. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent c378f4e commit 2a233b1

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

build/integration/features/bootstrap/Sharing.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public function asCreatingAShareWith($user, $body) {
5454
$fd = $body->getRowsHash();
5555
if (array_key_exists('expireDate', $fd)) {
5656
$dateModification = $fd['expireDate'];
57-
$fd['expireDate'] = date('Y-m-d', strtotime($dateModification));
57+
if (!empty($dateModification)) {
58+
$fd['expireDate'] = date('Y-m-d', strtotime($dateModification));
59+
}
5860
}
5961
$options['form_params'] = $fd;
6062
}
@@ -301,7 +303,9 @@ public function createShare($user,
301303
public function isFieldInResponse($field, $contentExpected) {
302304
$data = simplexml_load_string($this->response->getBody())->data[0];
303305
if ((string)$field == 'expiration') {
304-
$contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00";
306+
if(!empty($contentExpected)) {
307+
$contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00";
308+
}
305309
}
306310
if (count($data->element) > 0) {
307311
foreach ($data as $element) {

build/integration/sharing_features/sharing-v1.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,24 @@ Feature: sharing
229229
| url | AN_URL |
230230
| mimetype | httpd/unix-directory |
231231

232+
Scenario: Creating a new share with expiration date removed, when default expiration is set
233+
Given user "user0" exists
234+
And user "user1" exists
235+
And parameter "shareapi_default_expire_date" of app "core" is set to "yes"
236+
And As an "user0"
237+
When creating a share with
238+
| path | welcome.txt |
239+
| shareWith | user1 |
240+
| shareType | 0 |
241+
| expireDate | |
242+
Then the OCS status code should be "100"
243+
And the HTTP status code should be "200"
244+
And Getting info of last share
245+
Then the OCS status code should be "100"
246+
And the HTTP status code should be "200"
247+
And Share fields of last share match with
248+
| expiration ||
249+
232250
Scenario: Creating a new public share, updating its password and getting its info
233251
Given user "user0" exists
234252
And As an "user0"

0 commit comments

Comments
 (0)