From 88aa44a768fdce1e341555392f07e7ba7e477c4f Mon Sep 17 00:00:00 2001 From: Sagar Gurung <46086950+SagarGi@users.noreply.github.com> Date: Fri, 22 Dec 2023 16:28:47 +0545 Subject: [PATCH] [tests-only][full-ci]Added tests for create link share without password (#8040) * Added tests for create link share without password * fix CI failure --- tests/acceptance/config/behat.yml | 2 + ...ected-failures-localAPI-on-OCIS-storage.md | 1 + .../features/apiSharingNg/createLink.feature | 71 +++++++++++++++++++ .../features/bootstrap/SharingNgContext.php | 5 +- 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index e09ee58973..52b9bebbfa 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -262,6 +262,8 @@ default: - FeatureContext: *common_feature_context_params - SpacesContext: - SharingNgContext: + - OcisConfigContext: + extensions: rdx\behatvars\BehatVariablesExtension: ~ diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index c16582c00a..eb3f8aafce 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -260,6 +260,7 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiSharingNg/createLink.feature:147](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L147) - [apiSharingNg/createLink.feature:225](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L225) - [apiSharingNg/createLink.feature:301](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L301) +- [apiSharingNg/createLink.feature:372](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/createLink.feature#L372) - Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/apiSharingNg/createLink.feature b/tests/acceptance/features/apiSharingNg/createLink.feature index cd20282f67..e9644bc3fa 100644 --- a/tests/acceptance/features/apiSharingNg/createLink.feature +++ b/tests/acceptance/features/apiSharingNg/createLink.feature @@ -299,3 +299,74 @@ Feature: Create a share link for a resource | view | | edit | | blocksDownload | + + @env-config + Scenario Outline: create a link share of a file without password + Given the following configs have been set: + | config | value | + | OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD | false | + And user "Alice" has uploaded file with content "other data" to "textfile1.txt" + When user "Alice" creates the following link share using the Graph API: + | resourceType | file | + | resource | textfile1.txt | + | space | Personal | + | role | | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "hasPassword", + "id", + "link" + ], + "properties": { + "hasPassword": { + "type": "boolean", + "enum": [false] + }, + "id": { + "type": "string", + "pattern": "^[a-zA-Z]{15}$" + }, + "link": { + "type": "object", + "required": [ + "@libre.graph.displayName", + "@libre.graph.quickLink", + "preventsDownload", + "type", + "webUrl" + ], + "properties": { + "@libre.graph.displayName": { + "type": "string", + "enum": [""] + }, + "@libre.graph.quickLink": { + "type": "boolean", + "enum": [false] + }, + "preventsDownload": { + "type": "boolean", + "enum": [false] + }, + "type": { + "type": "string", + "enum": [""] + }, + "webUrl": { + "type": "string", + "pattern": "^%base_url%\/s\/[a-zA-Z]{15}$" + } + } + } + } + } + """ + Examples: + | role | + | view | + | edit | + | blocksDownload | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 7a3ea1dd3a..7ec8b9a999 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -141,8 +141,9 @@ class SharingNgContext implements Context { $itemId = $this->spacesContext->getFileId($user, $space, $resource); } - $bodyRows['displayName'] = \array_key_exists('displayName', $bodyRows) ? $bodyRows['displayName'] : null; - $bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows) ? $bodyRows['expirationDateTime'] : null; + $bodyRows['displayName'] = $bodyRows['displayName'] ?? null; + $bodyRows['expirationDateTime'] = $bodyRows['expirationDateTime'] ?? null; + $bodyRows['password'] = $bodyRows['password'] ?? null; $body = [ 'type' => $bodyRows['role'], 'displayName' => $bodyRows['displayName'],