From 44da5fe1ab2d74d6eb09b11e40e763b3b5c88c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Bertol=C3=ADn?= Date: Fri, 19 Feb 2016 14:13:19 +0000 Subject: [PATCH] Adding new tests for federation sharing --- .../features/bootstrap/FederationContext.php | 33 +++++- .../features/bootstrap/Sharing.php | 11 ++ .../federation_features/federated.feature | 104 ++++++++++++++++++ 3 files changed, 147 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/FederationContext.php b/build/integration/features/bootstrap/FederationContext.php index 279b5206de..5a7c2dd2ff 100644 --- a/build/integration/features/bootstrap/FederationContext.php +++ b/build/integration/features/bootstrap/FederationContext.php @@ -20,8 +20,39 @@ class FederationContext implements Context, SnippetAcceptingContext { * @When /^User "([^"]*)" from server "([^"]*)" shares "([^"]*)" with user "([^"]*)" from server "([^"]*)"$/ */ public function federateSharing($userLocal, $serverLocal, $pathLocal, $userRemote, $serverRemote){ - $shareWith = "$userRemote@" . substr($this->remoteBaseUrl, 0, -4); + if ($serverRemote == "REMOTE"){ + $shareWith = "$userRemote@" . substr($this->remoteBaseUrl, 0, -4); + } elseif ($serverRemote == "LOCAL") { + $shareWith = "$userRemote@" . substr($this->localBaseUrl, 0, -4); + } $this->createShare($userLocal, $pathLocal, 6, $shareWith, null, null, null); } + /** + * @When /^User "([^"]*)" from server "([^"]*)" accepts last pending share$/ + */ + public function acceptLastPendingShare($user, $server){ + $this->usingServer($server); + $this->asAn($user); + $this->sendingToWith('GET', "/apps/files_sharing/api/v1/remote_shares/pending", null); + $this->theHTTPStatusCodeShouldBe('200'); + $this->theOCSStatusCodeShouldBe('100'); + $share_id = $this->response->xml()->data[0]->element[0]->id; + $this->sendingToWith('POST', "/apps/files_sharing/api/v1/remote_shares/pending/{$share_id}", null); + $this->theHTTPStatusCodeShouldBe('200'); + $this->theOCSStatusCodeShouldBe('100'); + } + + /** + * @param string $app + * @param string $parameter + * @param string $value + */ + protected function modifyServerConfig($app, $parameter, $value) { + $body = new \Behat\Gherkin\Node\TableNode([['value', $value]]); + $this->sendingToWith('post', "/apps/testing/api/v1/app/{$app}/{$parameter}", $body); + $this->theHTTPStatusCodeShouldBe('200'); + $this->theOCSStatusCodeShouldBe('100'); + } + } diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php index da2e9ca109..c9dcc505b4 100644 --- a/build/integration/features/bootstrap/Sharing.php +++ b/build/integration/features/bootstrap/Sharing.php @@ -225,6 +225,9 @@ trait Sharing{ elseif ((string)$element->$field == $contentExpected){ return True; } + else{ + print($element->$field); + } } return False; @@ -374,6 +377,14 @@ trait Sharing{ $fd = $body->getRowsHash(); foreach($fd as $field => $value) { + if (substr($field, 0, 10 ) === "share_with"){ + $value = str_replace("REMOTE", substr($this->remoteBaseUrl, 0, -5), $value); + $value = str_replace("LOCAL", substr($this->localBaseUrl, 0, -5), $value); + } + if (substr($field, 0, 6 ) === "remote"){ + $value = str_replace("REMOTE", substr($this->remoteBaseUrl, 0, -4), $value); + $value = str_replace("LOCAL", substr($this->localBaseUrl, 0, -4), $value); + } if (!$this->isFieldInResponse($field, $value)){ PHPUnit_Framework_Assert::fail("$field" . " doesn't have value " . "$value"); } diff --git a/build/integration/federation_features/federated.feature b/build/integration/federation_features/federated.feature index 5437d01dee..8cb47a48f0 100644 --- a/build/integration/federation_features/federated.feature +++ b/build/integration/federation_features/federated.feature @@ -10,6 +10,110 @@ Feature: federated When User "user0" from server "LOCAL" shares "/textfile0.txt" with user "user1" from server "REMOTE" Then the OCS status code should be "100" And the HTTP status code should be "200" + And Share fields of last share match with + | id | A_NUMBER | + | item_type | file | + | item_source | A_NUMBER | + | share_type | 6 | + | file_source | A_NUMBER | + | path | /textfile0.txt | + | permissions | 19 | + | stime | A_NUMBER | + | storage | A_NUMBER | + | mail_send | 0 | + | uid_owner | user0 | + | storage_id | home::user0 | + | file_parent | A_NUMBER | + | displayname_owner | user0 | + | share_with | user1@REMOTE | + | share_with_displayname | user1@REMOTE | + + Scenario: Federate share a file with local server + Given Using server "LOCAL" + And user "user0" exists + And Using server "REMOTE" + And user "user1" exists + When User "user1" from server "REMOTE" shares "/textfile0.txt" with user "user0" from server "LOCAL" + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And Share fields of last share match with + | id | A_NUMBER | + | item_type | file | + | item_source | A_NUMBER | + | share_type | 6 | + | file_source | A_NUMBER | + | path | /textfile0.txt | + | permissions | 19 | + | stime | A_NUMBER | + | storage | A_NUMBER | + | mail_send | 0 | + | uid_owner | user1 | + | storage_id | home::user1 | + | file_parent | A_NUMBER | + | displayname_owner | user1 | + | share_with | user0@LOCAL | + | share_with_displayname | user0@LOCAL | + + Scenario: Remote sharee can see the pending share + Given Using server "REMOTE" + And user "user1" exists + And Using server "LOCAL" + And user "user0" exists + And User "user0" from server "LOCAL" shares "/textfile0.txt" with user "user1" from server "REMOTE" + And Using server "REMOTE" + And As an "user1" + When sending "GET" to "/apps/files_sharing/api/v1/remote_shares/pending" + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And Share fields of last share match with + | id | A_NUMBER | + | remote | LOCAL | + | remote_id | A_NUMBER | + | share_token | A_TOKEN | + | name | /textfile0.txt | + | owner | user0 | + | user | user1 | + | mountpoint | {{TemporaryMountPointName#/textfile0.txt}} | + | accepted | 0 | + + Scenario: accept a pending remote share + Given Using server "REMOTE" + And user "user1" exists + And Using server "LOCAL" + And user "user0" exists + And User "user0" from server "LOCAL" shares "/textfile0.txt" with user "user1" from server "REMOTE" + When User "user1" from server "REMOTE" accepts last pending share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + + Scenario: Federate reshare a file + Given Using server "REMOTE" + And user "user1" exists + And Using server "LOCAL" + And user "user0" exists + And User "user0" from server "LOCAL" shares "/textfile0.txt" with user "user1" from server "REMOTE" + And User "user1" from server "REMOTE" accepts last pending share + And Using server "REMOTE" + And As an "user1" + When User "user1" from server "REMOTE" shares "/textfile0 (2).txt" with user "user0" from server "LOCAL" + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And Share fields of last share match with + | id | A_NUMBER | + | item_type | file | + | item_source | A_NUMBER | + | share_type | 6 | + | file_source | A_NUMBER | + | path | /textfile0 (2).txt | + | permissions | 19 | + | stime | A_NUMBER | + | storage | A_NUMBER | + | mail_send | 0 | + | uid_owner | user1 | + | file_parent | A_NUMBER | + | displayname_owner | user1 | + | share_with | user0@LOCAL | + | share_with_displayname | user0@LOCAL |