Skip to content

Commit

Permalink
improved then steps
Browse files Browse the repository at this point in the history
  • Loading branch information
sushmita56 committed Apr 11, 2022
1 parent b070a9e commit b9dafb3
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 171 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,9 @@ Feature: share resources where the sharee receives the share in multiple ways
| permissions | all |
And user "Carol" has created a share with settings
| path | /parent/child1 |
| shareType | group |
| shareWith | grp2 |
| permissions | read |
| shareType | group |
| shareWith | grp2 |
| permissions | read |
When user "Alice" accepts share "/parent" offered by user "Carol" using the sharing API
And user "Brian" accepts share "<path>" offered by user "Carol" using the sharing API
Then the HTTP status code of responses on all endpoints should be "200"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,25 @@ Feature: share resources where the sharee receives the share in multiple ways
And user "Alice" has created folder "parent"
And user "Alice" has created folder "parent/child"
And user "Alice" has uploaded file with content "Share content" to "parent/child/lorem.txt"
When user "Alice" shares folder "parent" with group "grp" with permissions "read" using the sharing API
And user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
And user "Brian" moves folder "/Shares/parent" to "/Shares/sharedParent" using the WebDAV API
And user "Alice" shares folder "parent" with user "Brian" using the sharing API
And user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
Then as "Brian" folder "Shares/parent" should exist
And user "Alice" has created a share with settings
| path | parent |
| shareType | group |
| shareWith | grp |
| permissions | read |
When user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "<ocs_status_code>"
And user "Brian" should be able to rename folder "/Shares/parent" to "/Shares/sharedParent"
And user "Alice" should be able to share folder "parent" with user "Brian" with permissions "read" using the sharing API
And user "Brian" should be able to accept pending share "/parent" offered by user "Alice"
And as "Brian" folder "Shares/parent" should exist
And as "Brian" folder "Shares/sharedParent" should not exist
And as "Brian" file "Shares/sharedParent/child/lorem.txt" should not exist
Examples:
| ocs_api_version |
| 1 |
| 2 |
| ocs_api_version | ocs_status_code |
| 1 | 100 |
| 2 | 200 |


# Note: after fixing the bug, this scenario is no longer relevant.
# Brian should not get a chance to decline (or accept) the 2nd share of the resource from Alice
Expand All @@ -43,18 +50,24 @@ Feature: share resources where the sharee receives the share in multiple ways
And user "Alice" has created folder "parent"
And user "Alice" has created folder "parent/child"
And user "Alice" has uploaded file with content "Share content" to "parent/child/lorem.txt"
When user "Alice" shares folder "parent" with group "grp" with permissions "read" using the sharing API
And user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
And user "Brian" moves folder "/Shares/parent" to "/Shares/sharedParent" using the WebDAV API
And user "Alice" shares folder "parent" with user "Brian" using the sharing API
And user "Brian" declines share "/parent" offered by user "Alice" using the sharing API
Then as "Brian" folder "Shares/parent" should not exist
And user "Alice" has created a share with settings
| path | parent |
| shareType | group |
| shareWith | grp |
| permissions | read |
When user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "<ocs_status_code>"
And user "Brian" should be able to rename folder "/Shares/parent" to "/Shares/sharedParent"
And user "Alice" should be able to share folder "parent" with user "Brian" with permissions "read" using the sharing API
And user "Brian" should be able to decline pending share "/parent" offered by user "Alice"
And as "Brian" folder "Shares/parent" should not exist
And as "Brian" folder "Shares/sharedParent" should not exist
And as "Brian" file "Shares/sharedParent/child/lorem.txt" should not exist
Examples:
| ocs_api_version |
| 1 |
| 2 |
| ocs_api_version | ocs_status_code |
| 1 | 100 |
| 2 | 200 |


Scenario Outline: Share receiver renames a group share and receives same resource through user share with additional permissions
Expand All @@ -65,20 +78,26 @@ Feature: share resources where the sharee receives the share in multiple ways
And user "Alice" has created folder "parent"
And user "Alice" has created folder "parent/child"
And user "Alice" has uploaded file with content "Share content" to "parent/child/lorem.txt"
When user "Alice" shares folder "parent" with group "grp" with permissions "read" using the sharing API
And user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
And user "Brian" moves folder "/Shares/parent" to "/Shares/sharedParent" using the WebDAV API
And user "Alice" shares folder "parent" with user "Brian" with permissions "all" using the sharing API
And user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
Then as "Brian" folder "Shares/parent" should exist
And user "Alice" has created a share with settings
| path | parent |
| shareType | group |
| shareWith | grp |
| permissions | read |
When user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "<ocs_status_code>"
And user "Brian" should be able to rename folder "/Shares/parent" to "/Shares/sharedParent"
And user "Alice" should be able to share folder "parent" with user "Brian" with permissions "all" using the sharing API
And user "Brian" should be able to accept pending share "/parent" offered by user "Alice"
And as "Brian" folder "Shares/parent" should exist
And as "Brian" folder "Shares/sharedParent" should not exist
And as "Brian" file "Shares/sharedParent/child/lorem.txt" should not exist
And as "Brian" file "Shares/parent/child/lorem.txt" should exist
And user "Brian" should be able to delete file "Shares/parent/child/lorem.txt"
Examples:
| ocs_api_version |
| 1 |
| 2 |
| ocs_api_version | ocs_status_code |
| 1 | 100 |
| 2 | 200 |


Scenario Outline: Share receiver renames a group share and receives same resource through user share with less permissions
Expand All @@ -89,17 +108,23 @@ Feature: share resources where the sharee receives the share in multiple ways
And user "Alice" has created folder "parent"
And user "Alice" has created folder "parent/child"
And user "Alice" has uploaded file with content "Share content" to "parent/child/lorem.txt"
When user "Alice" shares folder "parent" with group "grp" with permissions "all" using the sharing API
And user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
And user "Brian" moves folder "/Shares/parent" to "/Shares/sharedParent" using the WebDAV API
And user "Alice" shares folder "parent" with user "Brian" with permissions "read" using the sharing API
And user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
Then as "Brian" folder "Shares/parent" should exist
And user "Alice" has created a share with settings
| path | parent |
| shareType | group |
| shareWith | grp |
| permissions | all |
When user "Brian" accepts share "/parent" offered by user "Alice" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "<ocs_status_code>"
And user "Brian" should be able to rename folder "/Shares/parent" to "/Shares/sharedParent"
And user "Alice" should be able to share folder "parent" with user "Brian" with permissions "read" using the sharing API
And user "Brian" should be able to accept pending share "/parent" offered by user "Alice"
And as "Brian" folder "Shares/parent" should exist
And as "Brian" folder "Shares/sharedParent" should not exist
And as "Brian" file "Shares/sharedParent/child/lorem.txt" should not exist
And as "Brian" file "Shares/parent/child/lorem.txt" should exist
And user "Brian" should be able to delete file "Shares/parent/child/lorem.txt"
Examples:
| ocs_api_version |
| 1 |
| 2 |
| ocs_api_version | ocs_status_code |
| 1 | 100 |
| 2 | 200 |
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ Feature: Sharing resources with different case names with the sharee and checkin
| /TEXTFILE.txt |
| /TEXT_FILE.txt |
| /123TEXTFILE.txt |
| /TEXTFILE.xyz.txt |
Then as "Brian" the following files should exist
| /TEXTFILE.xyz.txt |
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on all endpoints should be "200"
And as "Brian" the following files should exist
| path |
| /Shares/textfile.txt |
| /Shares/text_file.txt |
Expand Down Expand Up @@ -84,7 +86,9 @@ Feature: Sharing resources with different case names with the sharee and checkin
| /f_o |
| /123fo |
| /fo.xyz |
Then as "Brian" the following folders should exist
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on all endpoints should be "200"
And as "Brian" the following folders should exist
| path |
| /Shares/FO |
| /Shares/F_O |
Expand Down Expand Up @@ -131,7 +135,9 @@ Feature: Sharing resources with different case names with the sharee and checkin
| /CASE_SENSITIVE |
| /123case_sensitive |
| /CASESENSITIVE.xyz |
Then as "Brian" the following files should exist
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on all endpoints should be "200"
And as "Brian" the following files should exist
| path |
| /Shares/casesensitive.txt |
| /Shares/case_sensitive.txt |
Expand Down Expand Up @@ -177,8 +183,10 @@ Feature: Sharing resources with different case names with the sharee and checkin
| /TEXTFILE.txt |
| /TEXT_FILE.txt |
| /123TEXTFILE.txt |
| /TEXTFILE.xyz.txt |
Then as "Brian" the following files should exist
| /TEXTFILE.xyz.txt |
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on all endpoints should be "200"
And as "Brian" the following files should exist
| path |
| /Shares/textfile.txt |
| /Shares/text_file.txt |
Expand Down Expand Up @@ -223,7 +231,9 @@ Feature: Sharing resources with different case names with the sharee and checkin
| /f_o |
| /123fo |
| /fo.xyz |
Then as "Brian" the following folders should exist
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on all endpoints should be "200"
And as "Brian" the following folders should exist
| path |
| /Shares/FO |
| /Shares/F_O |
Expand Down Expand Up @@ -272,7 +282,9 @@ Feature: Sharing resources with different case names with the sharee and checkin
| /CASE_SENSITIVE |
| /123case_sensitive |
| /CASESENSITIVE.xyz |
Then as "Brian" the following files should exist
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on all endpoints should be "200"
And as "Brian" the following files should exist
| path |
| /Shares/casesensitive.txt |
| /Shares/case_sensitive.txt |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Feature: resources shared with the same name are received with unique names
And user "Carol" accepts share "/foo" offered by user "Alice" using the sharing API
And user "Brian" shares folder "/foo" with user "Carol" using the sharing API
And user "Carol" accepts share "/foo" offered by user "Brian" using the sharing API
Then user "Carol" should see the following elements
Then the OCS status code of responses on all endpoints should be "100"
And the HTTP status code of responses on all endpoints should be "200"
And user "Carol" should see the following elements
| /Shares/foo/ |
| /Shares/foo (2)/ |
33 changes: 31 additions & 2 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@ public function userSharesTheFollowingFilesWithUserUsingTheSharingApi(
$permissions
);
}
$this->pushToLastStatusCodesArrays();
}

/**
Expand Down Expand Up @@ -1944,7 +1945,7 @@ public function asLastShareInfoAboutUserSharingWithUserShouldInclude(

/**
* @Then /^the info about the last share by user "([^"]*)" with (?:user|group) "([^"]*)" should include$/
*
*
* @param string $sharer
* @param string $sharee
* @param TableNode $table
Expand Down Expand Up @@ -3056,6 +3057,7 @@ public function userReactsToTheFollowingSharesOfferedBy(string $user, string $ac
$offeredBy
);
}
$this->pushToLastStatusCodesArrays();
}

/**
Expand Down Expand Up @@ -3105,7 +3107,7 @@ public function userHasReactedToShareOfferedBy(string $user, string $action, str
if ($action === 'declined') {
$actionText = 'decline';
}
if ($action === 'accepted') {
if ($action === 'accepted') {
$actionText = 'accept';
}
$this->theHTTPStatusCodeShouldBe(
Expand Down Expand Up @@ -3150,6 +3152,33 @@ public function userHasAcceptedThePendingShareOfferedBy(string $user, string $sh
$this->ocsContext->assertOCSResponseIndicatesSuccess();
}

/**
* @Then /^user "([^"]*)" should be able to (decline|accept) pending share "([^"]*)" offered by user "([^"]*)"$/
*
* @param string $user
* @param string $action
* @param string $share
* @param string $offeredBy
*
* @return void
* @throws Exception
*/
public function userShouldBeAbleToAcceptShareOfferedBy(
string $user,
string $action,
string $share,
string $offeredBy
)
{
if ($action === 'accept') {
$this->userHasAcceptedThePendingShareOfferedBy($user, $share, $offeredBy);
}
else if ($action === 'decline')
{
$this->userHasReactedToShareOfferedBy($user, 'declined', $share, $offeredBy);
}
}

/**
*
* @Then /^the sharing API should report to user "([^"]*)" that these shares are in the (pending|accepted|declined) state$/
Expand Down

0 comments on commit b9dafb3

Please sign in to comment.