diff --git a/.drone.env b/.drone.env index 220ab783..13dc8eed 100644 --- a/.drone.env +++ b/.drone.env @@ -1,5 +1,5 @@ # The version of OCIS to use in pipelines that test against OCIS -OCIS_COMMITID=2a300190cbccb2b4a93b7aa76abe4f204fb393bf +OCIS_COMMITID=c2ab6666a5b9bbba899fdf9486f8d9bae6bc12b4 OCIS_BRANCH=master -OCIS_STABLE_COMMITID=b8149ede7db9d510e1988ca9fdfe51fd44e7d603 +OCIS_STABLE_COMMITID=08c6f41fc8a965b1a1dc83045b673ce1bdfc000e OCIS_STABLE_BRANCH=stable-5.0 diff --git a/.drone.star b/.drone.star index bdf37c86..df7c17df 100644 --- a/.drone.star +++ b/.drone.star @@ -178,7 +178,7 @@ def behattest(): "depends_on": [], "steps":generateSSLCert() + apacheService() + waitForService("apache",443) + runOcis(branch) + \ waitForService("ocis",9200) + databaseService() + waitForService("postgresql",5432) + \ - seleniumService() + waitForService("selenium",4444) + setupMoodle() + runBehatTest() , + seleniumService() + waitForService("selenium",4444) + setupMoodle() + runBehatTest(branch) , "volumes": [ { "name":"www-moodle", @@ -393,7 +393,11 @@ def seleniumService(): } ] -def runBehatTest(): +def runBehatTest(branch): + if branch == "master": + tags = "@ocis" + else: + tags = "@ocis &&~@skipOnStable" return [ { "name":"behat-test", @@ -402,7 +406,7 @@ def runBehatTest(): "commands": [ "update-ca-certificates", "cd /var/www/html/moodle", - "vendor/bin/behat --config /var/www/behatdata/behatrun/behat/behat.yml --tags=@ocis", + 'vendor/bin/behat --config /var/www/behatdata/behatrun/behat/behat.yml --tags="%s"' %tags, ], "volumes":[ { diff --git a/tests/behat/behat_repository_ocis.php b/tests/behat/behat_repository_ocis.php index 2b45a5bb..dbec0b8b 100755 --- a/tests/behat/behat_repository_ocis.php +++ b/tests/behat/behat_repository_ocis.php @@ -379,4 +379,37 @@ public function i_should_see_after_refreshing_the_file_picker(string $text) { $refreshbutton->click(); $this->execute('behat_general::assert_page_contains_text', [$text]); } + + /** + * Step definition for disabling sync of share + * @When user :user disables sync of share :share + * + * @param string $user + * + * @throws Exception + */ + public function user_disables_sync_of_share(string $user) { + $response = $this->graphhelper->disable_share_sync($user); + if ((!in_array($response['statusCode'], [200, 204]))) { + throw new Exception("Error disabling sync of share " . var_dump($response['statusCode'])); + } + } + + /** + * Step definition for enabling sync of share + * @When user :user enables sync of share :share offered by :offeredBy from :space space + * + * @param string $user + * @param string $share + * @param string $offeredby + * @param string $space + * + * @throws Exception + */ + public function user_enables_sync_of_share(string $user, string $share, string $offeredby, string $space) { + $response = $this->graphhelper->enable_share_sync($user, $share, $offeredby, $space); + if ($response['statusCode'] !== 201) { + throw new Exception("Error enabling sync of share"); + } + } } diff --git a/tests/behat/graph_helper.php b/tests/behat/graph_helper.php index 2f67a9ff..324b107c 100644 --- a/tests/behat/graph_helper.php +++ b/tests/behat/graph_helper.php @@ -47,6 +47,17 @@ class graph_helper { */ private const ALTERNATE_USER_PASSWORD = '1234'; + /** + * shares space id + */ + private const SHARES_SPACE_ID = 'a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668'; + + /*** + * array for storing response from share + * @var string $lastcreatedshareid + */ + private string $lastcreatedshareid; + /** * Get a new SabreDAV client * @param string $user @@ -248,10 +259,52 @@ public function send_share_invitation(string $user, string $sharetype, string $s ]; $itemid = $this->get_resource_id($user, $resource, $space); $client = $this->get_client($user); - return $client->request( + $response = $client->request( 'POST', "/graph/v1beta1/drives/$spaceid/items/$itemid/invite", json_encode($body) ); + $resbody = json_decode($response["body"], true); + $this->lastcreatedshareid = $resbody["value"][0]["id"]; + return $response; + } + + /** + * send request to disable sync of share + * @param string $user + * + * @return array + */ + public function disable_share_sync(string $user): array { + $itemid = self::SHARES_SPACE_ID . '!' . $this->lastcreatedshareid; + $client = $this->get_client($user); + return $client->request( + 'DELETE', + "/graph/v1beta1/drives/" . self::SHARES_SPACE_ID . "/items/$itemid", + ); + } + + /** + * send request to enable sync of share + * @param string $user + * @param string $share + * @param string $offeredby + * @param string $space + * + * @return array + */ + public function enable_share_sync(string $user, string $share, string $offeredby, string $space): array { + $itemid = $this->get_resource_id($offeredby, $share, $space); + $body = [ + "remoteItem" => [ + "id" => $itemid, + ], + ]; + $client = $this->get_client($user); + return $client->request( + 'POST', + "/graph/v1beta1/drives/" . self::SHARES_SPACE_ID . "/root/children", + json_encode($body) + ); } } diff --git a/tests/behat/uploadFileToMoodle.feature b/tests/behat/uploadFileToMoodle.feature index 81a81a71..a941f712 100755 --- a/tests/behat/uploadFileToMoodle.feature +++ b/tests/behat/uploadFileToMoodle.feature @@ -103,3 +103,19 @@ Feature: upload the resource in oCIS to moodle Then I should see "Personal" And I should see "Shares" And I should see "ProjectMoodle" + + @skipOnStable @ocis-issue-8961 + Scenario: enable/disable sync of shared resource shared from Personal Space + Given user "Brian" has been created with default attributes + And user "Brian" has uploaded a file inside space "Personal" with content "some content" to "/testfile.txt" + And user "Brian" has sent the following share invitation: + | resource | testfile.txt | + | space | Personal | + | sharee | Admin | + | shareType | user | + When user "Admin" disables sync of share "testfile.txt" + And I click on "//*[@class='fp-filename-field']/p[text()='Shares']" "xpath_element" + Then I should not see "testfile.txt" + When user "Admin" enables sync of share "testfile.txt" offered by "Brian" from "Personal" space + And I refresh the file-picker + Then I should see "testfile.txt"