diff --git a/tests/integration/features/bootstrap/BoardContext.php b/tests/integration/features/bootstrap/BoardContext.php index de32b077b..995ec1fd7 100644 --- a/tests/integration/features/bootstrap/BoardContext.php +++ b/tests/integration/features/bootstrap/BoardContext.php @@ -57,6 +57,26 @@ class BoardContext implements Context { ]); } + /** + * @When shares the board with group :group + */ + public function sharesTheBoardWithGroup($group, TableNode $permissions = null) { + $defaults = [ + 'permissionEdit' => '0', + 'permissionShare' => '0', + 'permissionManage' => '0' + ]; + $tableRows = isset($permissions) ? $permissions->getRowsHash() : []; + $result = array_merge($defaults, $tableRows); + $this->sendJSONrequest('POST', '/index.php/apps/deck/boards/' . $this->board['id'] . '/acl', [ + 'type' => 1, + 'participant' => $group, + 'permissionEdit' => $result['permissionEdit'] === '1', + 'permissionShare' => $result['permissionShare'] === '1', + 'permissionManage' => $result['permissionManage'] === '1', + ]); + } + /** * @When /^fetching the board list$/ @@ -119,4 +139,16 @@ class BoardContext implements Context { ]; return $this->board['permissions'][$mapping[$permission]]; } + + /** + * @When /^share the file "([^"]*)" with the card$/ + */ + public function shareWithTheCard($file) { + $table = new TableNode([ + ['path', $file], + ['shareType', 12], + ['shareWith', (string)$this->card['id']], + ]); + $this->serverContext->creatingShare($table); + } } diff --git a/tests/integration/features/bootstrap/ServerContext.php b/tests/integration/features/bootstrap/ServerContext.php index 8b5522c84..5116aaa92 100644 --- a/tests/integration/features/bootstrap/ServerContext.php +++ b/tests/integration/features/bootstrap/ServerContext.php @@ -19,6 +19,14 @@ class ServerContext implements Context { public static function addFilesToSkeleton() { } + /** + * @Given /^acting as user "([^"]*)"$/ + */ + public function actingAsUser($user) { + $this->loggingInUsingWebAs($user); + $this->asAn($user); + } + public function getCookieJar(): CookieJar { return $this->cookieJar; } diff --git a/tests/integration/features/sharing.feature b/tests/integration/features/sharing.feature index 3df624e64..73e51ebb0 100644 --- a/tests/integration/features/sharing.feature +++ b/tests/integration/features/sharing.feature @@ -4,16 +4,109 @@ Feature: File sharing Given user "admin" exists And user "user0" exists And user "user1" exists - #And user "user2" exists - #Given group "group0" exists - #And group "group1" exists - #Given user "user1" belongs to group "group1" + And user "user2" exists + And user "user3" exists + Given group "group0" exists + And group "group1" exists + Given user "user2" belongs to group "group1" + Given user "user3" belongs to group "group1" - Scenario: Share a file with a card - Given Logging in using web as "admin" + Scenario: Share a file with a card by the board owner + Given acting as user "user0" And creates a board named "Shared board" with color "fafafa" - And shares the board with user "user1" - Then the HTTP status code should be "200" - Given Logging in using web as "user1" And create a stack named "Stack" And create a card named "Test" + And shares the board with user "user1" + Then the HTTP status code should be "200" + + Given using new dav path + When User "user0" uploads file "../data/test.txt" to "/user0-file.txt" + Then the HTTP status code should be "201" + Given acting as user "user0" + When share the file "/user0-file.txt" with the card + Then the OCS status code should be "100" + And the HTTP status code should be "200" + + And as "user1" the file "/Deck/user0-file.txt" exists + + Scenario: Share a file with a card by another user + Given acting as user "user0" + And creates a board named "Shared board" with color "fafafa" + And create a stack named "Stack" + And create a card named "Test" + And shares the board with user "user1" + | permissionEdit | 1 | + | permissionShare | 1 | + | permissionManage | 1 | + Then the HTTP status code should be "200" + + Given using new dav path + When User "user1" uploads file "../data/test.txt" to "/user1-file.txt" + Then the HTTP status code should be "201" + Given acting as user "user1" + And share the file "/user1-file.txt" with the card + Then the OCS status code should be "100" + And the HTTP status code should be "200" + + And as "user0" the file "/Deck/user1-file.txt" exists + And as "user1" the file "/Deck/user1-file.txt" does not exist + + Scenario: Share a file with a card by another user fails without edit permission + Given acting as user "user0" + And creates a board named "Shared board" with color "fafafa" + And create a stack named "Stack" + And create a card named "Test" + And shares the board with user "user1" + Then the HTTP status code should be "200" + + Given using new dav path + When User "user1" uploads file "../data/test.txt" to "/user1-file.txt" + Then the HTTP status code should be "201" + Given acting as user "user1" + And share the file "/user1-file.txt" with the card + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And as "user0" the file "/Deck/user1-file.txt" does not exist + + Scenario: Share a file with a card by another user through a group + Given acting as user "user0" + And creates a board named "Shared board" with color "fafafa" + And create a stack named "Stack" + And create a card named "Test" + And shares the board with group "group1" + Then the HTTP status code should be "200" + + Given using new dav path + When User "user0" uploads file "../data/test.txt" to "/user0-file2.txt" + Then the HTTP status code should be "201" + Given acting as user "user0" + When share the file "/user0-file2.txt" with the card + Then the OCS status code should be "100" + And the HTTP status code should be "200" + + And as "user2" the file "/Deck/user0-file2.txt" exists + And as "user0" the file "/Deck/user0-file2.txt" does not exist + + Scenario: Remove incoming group share as a user + Given acting as user "user0" + And creates a board named "Shared board" with color "fafafa" + And create a stack named "Stack" + And create a card named "Test" + And shares the board with group "group1" + Then the HTTP status code should be "200" + + Given using new dav path + When User "user0" uploads file "../data/test.txt" to "/user0-file2.txt" + Then the HTTP status code should be "201" + Given acting as user "user0" + When share the file "/user0-file2.txt" with the card + Then the OCS status code should be "100" + And the HTTP status code should be "200" + + And as "user2" the file "/Deck/user0-file2.txt" exists + And as "user3" the file "/Deck/user0-file2.txt" exists + And as "user0" the file "/Deck/user0-file2.txt" does not exist + + Given User "user2" deletes file "/Deck/user0-file2.txt" + And as "user2" the file "/Deck/user0-file2.txt" does not exist + And as "user3" the file "/Deck/user0-file2.txt" exists diff --git a/tests/integration/run.sh b/tests/integration/run.sh index 8268f1d0f..ab9790b26 100755 --- a/tests/integration/run.sh +++ b/tests/integration/run.sh @@ -15,10 +15,8 @@ INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5) if [ "$INSTALLED" == "true" ]; then $OCC app:enable deck else - if [ "$SCENARIO_TO_RUN" != "setup_features/setup.feature" ]; then - echo "Nextcloud instance needs to be installed" >&2 - exit 1 - fi + echo "Nextcloud instance needs to be installed" >&2 + exit 1 fi composer install