Skip to content

Commit 6bf42d8

Browse files
authored
Merge pull request #33056 from owncloud/test-api-comments
Refactor Api comments test
2 parents dad09d9 + a475931 commit 6bf42d8

File tree

10 files changed

+367
-255
lines changed

10 files changed

+367
-255
lines changed

.drone.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,15 @@ matrix:
702702
CHOWN_SERVER: true
703703
OWNCLOUD_LOG: true
704704

705+
- PHP_VERSION: 7.1
706+
TEST_SUITE: api
707+
BEHAT_SUITE: apiComments
708+
DB_TYPE: mariadb
709+
USE_SERVER: true
710+
INSTALL_SERVER: true
711+
CHOWN_SERVER: true
712+
OWNCLOUD_LOG: true
713+
705714
- PHP_VERSION: 7.1
706715
TEST_SUITE: api
707716
BEHAT_SUITE: apiFederation

tests/acceptance/config/behat.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ default:
2323
- FeatureContext: *common_feature_context_params
2424
- CapabilitiesContext:
2525

26+
apiComments:
27+
paths:
28+
- %paths.base%/../features/apiComments
29+
contexts:
30+
- FeatureContext: *common_feature_context_params
31+
2632
apiFederation:
2733
paths:
2834
- %paths.base%/../features/apiFederation
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@api @TestAlsoOnExternalUserBackend @comments-app-required
2+
Feature: Comments
3+
4+
Background:
5+
Given using new DAV path
6+
And user "user0" has been created
7+
8+
@smokeTest
9+
Scenario: Getting info of comments using files endpoint
10+
Given as user "user0"
11+
And the user has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
12+
And the user has commented with content "My first comment" on file "/myFileToComment.txt"
13+
And the user should have the following comments on file "/myFileToComment.txt"
14+
| user0 | My first comment |
15+
When the user gets the following properties of folder "/myFileToComment.txt" using the WebDAV API
16+
| {http://owncloud.org/ns}comments-href |
17+
| {http://owncloud.org/ns}comments-count |
18+
| {http://owncloud.org/ns}comments-unread |
19+
Then the single response should contain a property "{http://owncloud.org/ns}comments-count" with value "1"
20+
And the single response should contain a property "{http://owncloud.org/ns}comments-unread" with value "0"
21+
And the single response should contain a property "{http://owncloud.org/ns}comments-href" with value "a_comment_url"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
@api @TestAlsoOnExternalUserBackend @comments-app-required
2+
Feature: Comments
3+
4+
Background:
5+
Given using new DAV path
6+
And user "user0" has been created
7+
And user "user1" has been created
8+
And as user "user0"
9+
10+
@smokeTest
11+
Scenario Outline: Creating a comment on a file belonging to myself
12+
Given the user has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
13+
When the user comments with content "<comment>" on file "/myFileToComment.txt" using the WebDAV API
14+
Then the user should have the following comments on file "/myFileToComment.txt"
15+
| user0 | <comment> |
16+
Examples:
17+
| comment |
18+
| My first comment |
19+
| 😀 🤖 |
20+
| नेपालि |
21+
22+
Scenario: Creating a comment on a shared file belonging to another user
23+
Given the user has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
24+
And the user has shared file "/myFileToComment.txt" with user "user1"
25+
When user "user1" comments with content "A comment from sharee" on file "/myFileToComment.txt" using the WebDAV API
26+
And the user comments with content "A comment from sharer" on file "/myFileToComment.txt" using the WebDAV API
27+
Then the HTTP status code should be "201"
28+
And user "user1" should have the following comments on file "/myFileToComment.txt"
29+
| user1 | A comment from sharee |
30+
| user0 | A comment from sharer |
31+
32+
Scenario: sharee comments on a group shared file
33+
Given group "grp1" has been created
34+
And user "user1" has been added to group "grp1"
35+
And the user has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
36+
And the user has shared file "/myFileToComment.txt" with group "grp1"
37+
When user "user1" comments with content "Comment from sharee" on file "/myFileToComment.txt" using the WebDAV API
38+
Then the HTTP status code should be "201"
39+
And the user should have the following comments on file "/myFileToComment.txt"
40+
| user1 | Comment from sharee |
41+
42+
Scenario: sharee comments on read-only shared file
43+
Given the user has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
44+
And the user has created a share with settings
45+
| path | /myFileToComment.txt |
46+
| shareType | 0 |
47+
| shareWith | user1 |
48+
| permissions | 1 |
49+
When user "user1" comments with content "Comment from sharee" on file "/myFileToComment.txt" using the WebDAV API
50+
Then the HTTP status code should be "201"
51+
And the user should have the following comments on file "/myFileToComment.txt"
52+
| user1 | Comment from sharee |
53+
54+
Scenario: sharee comments on upload-only shared file
55+
Given the user has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
56+
And the user has created a share with settings
57+
| path | /myFileToComment.txt |
58+
| shareType | 0 |
59+
| shareWith | user1 |
60+
| permissions | 4 |
61+
When user "user1" comments with content "Comment from sharee" on file "/myFileToComment.txt" using the WebDAV API
62+
Then the HTTP status code should be "501"
63+
And the user should have 0 comments on file "/myFileToComment.txt"
64+
65+
Scenario: Creating a comment on a folder belonging to myself
66+
When the user comments with content "My first comment" on folder "/FOLDER" using the WebDAV API
67+
Then the user should have the following comments on folder "/FOLDER"
68+
| user0 | My first comment |
69+
70+
Scenario: Creating a comment on a shared folder belonging to another user
71+
Given the user has created a folder "/FOLDER_TO_SHARE"
72+
And the user has shared folder "/FOLDER_TO_SHARE" with user "user1"
73+
When user "user1" comments with content "A comment from sharee" on folder "/FOLDER_TO_SHARE" using the WebDAV API
74+
And the user comments with content "A comment from sharer" on folder "/FOLDER_TO_SHARE" using the WebDAV API
75+
Then the HTTP status code should be "201"
76+
And user "user1" should have the following comments on file "/FOLDER_TO_SHARE"
77+
| user1 | A comment from sharee |
78+
| user0 | A comment from sharer |
79+
80+
Scenario: sharee comments on a group shared folder
81+
Given group "grp1" has been created
82+
And user "user1" has been added to group "grp1"
83+
And the user has created a folder "/FOLDER_TO_COMMENT"
84+
And the user has shared folder "/FOLDER_TO_COMMENT" with group "grp1"
85+
When user "user1" comments with content "Comment from sharee" on folder "/FOLDER_TO_COMMENT" using the WebDAV API
86+
Then the HTTP status code should be "201"
87+
And the user should have the following comments on folder "/FOLDER_TO_COMMENT"
88+
| user1 | Comment from sharee |
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@api @TestAlsoOnExternalUserBackend @comments-app-required
2+
Feature: Comments
3+
4+
Background:
5+
Given using new DAV path
6+
7+
@smokeTest
8+
Scenario: Deleting my own comments on a file belonging to myself
9+
Given user "user0" has been created
10+
And user "user0" has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
11+
And user "user0" has commented with content "My first comment" on file "/myFileToComment.txt"
12+
When user "user0" deletes the last created comment using the WebDAV API
13+
Then the HTTP status code should be "204"
14+
And user "user0" should have 0 comments on file "/myFileToComment.txt"
15+
16+
Scenario: Deleting a comment on a file belonging to myself having several comments
17+
Given user "user0" has been created
18+
And user "user0" has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
19+
And user "user0" has commented with content "My first comment" on file "/myFileToComment.txt"
20+
And user "user0" has commented with content "My second comment" on file "/myFileToComment.txt"
21+
And user "user0" has commented with content "My third comment" on file "/myFileToComment.txt"
22+
And user "user0" has commented with content "My fourth comment" on file "/myFileToComment.txt"
23+
When user "user0" deletes the last created comment using the WebDAV API
24+
Then the HTTP status code should be "204"
25+
And user "user0" should have 3 comments on file "/myFileToComment.txt"
26+
27+
Scenario: Deleting my own comments on a file shared by somebody else
28+
Given user "user0" has been created
29+
And user "user1" has been created
30+
And user "user0" has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
31+
And user "user0" has shared file "/myFileToComment.txt" with user "user1"
32+
And user "user0" has commented with content "File owner comment" on file "/myFileToComment.txt"
33+
And user "user1" has commented with content "Sharee comment" on file "/myFileToComment.txt"
34+
And user "user1" should have the following comments on file "/myFileToComment.txt"
35+
| user0 | File owner comment |
36+
| user1 | Sharee comment |
37+
When user "user1" deletes the last created comment using the WebDAV API
38+
Then the HTTP status code should be "204"
39+
And user "user1" should have 1 comments on file "/myFileToComment.txt"
40+
41+
Scenario: Deleting my own comments on a folder belonging to myself
42+
Given user "user0" has been created
43+
And user "user0" has created a folder "/FOLDER_TO_COMMENT_AND_DELETE"
44+
And user "user0" has commented with content "My first comment" on folder "/FOLDER_TO_COMMENT_AND_DELETE"
45+
When user "user0" deletes the last created comment using the WebDAV API
46+
Then the HTTP status code should be "204"
47+
And user "user0" should have 0 comments on folder "/FOLDER_TO_COMMENT_AND_DELETE"
48+
49+
Scenario: Deleting a comment on a file belonging to myself having several comments
50+
Given user "user0" has been created
51+
And user "user0" has created a folder "/FOLDER_TO_COMMENT"
52+
And user "user0" has commented with content "My first comment" on folder "/FOLDER_TO_COMMENT"
53+
And user "user0" has commented with content "My second comment" on folder "/FOLDER_TO_COMMENT"
54+
And user "user0" has commented with content "My third comment" on folder "/FOLDER_TO_COMMENT"
55+
And user "user0" has commented with content "My fourth comment" on folder "/FOLDER_TO_COMMENT"
56+
When user "user0" deletes the last created comment using the WebDAV API
57+
Then the HTTP status code should be "204"
58+
And user "user0" should have 3 comments on folder "/FOLDER_TO_COMMENT"
59+
60+
Scenario: Deleting my own comments on a file shared by somebody else
61+
Given user "user0" has been created
62+
And user "user1" has been created
63+
And user "user0" has created a folder "/FOLDER_TO_COMMENT"
64+
And user "user0" has shared folder "/FOLDER_TO_COMMENT" with user "user1"
65+
And user "user0" has commented with content "Folder owner comment" on folder "/FOLDER_TO_COMMENT"
66+
And user "user1" has commented with content "Sharee comment" on folder "/FOLDER_TO_COMMENT"
67+
And user "user1" should have the following comments on folder "/FOLDER_TO_COMMENT"
68+
| user0 | Folder owner comment |
69+
| user1 | Sharee comment |
70+
When user "user1" deletes the last created comment using the WebDAV API
71+
Then the HTTP status code should be "204"
72+
And user "user1" should have 1 comments on folder "/FOLDER_TO_COMMENT"
73+
74+
Scenario: deleting a folder removes existing comments on the folder
75+
Given user "user0" has been created
76+
And user "user0" has created a folder "/FOLDER_TO_DELETE"
77+
When user "user0" comments with content "This should be deleted" on folder "/FOLDER_TO_DELETE" using the WebDAV API
78+
Then user "user0" should have 1 comments on folder "/FOLDER_TO_DELETE"
79+
When user "user0" deletes folder "/FOLDER_TO_DELETE" using the WebDAV API
80+
And user "user0" has created a folder "/FOLDER_TO_DELETE"
81+
Then user "user0" should have 0 comments on folder "/FOLDER_TO_DELETE"
82+
83+
Scenario: deleting a user does not remove the comment
84+
Given user "user0" has been created
85+
And user "user1" has been created
86+
And user "user0" has created a folder "/FOLDER_TO_COMMENT"
87+
And user "user0" has shared folder "/FOLDER_TO_COMMENT" with user "user1"
88+
And user "user1" has commented with content "Comment from sharee" on folder "/FOLDER_TO_COMMENT"
89+
Then user "user0" should have the following comments on folder "/FOLDER_TO_COMMENT"
90+
| user1 | Comment from sharee |
91+
And user "user1" has been deleted
92+
Then user "user0" should have 1 comments on folder "/FOLDER_TO_COMMENT"
93+
And user "user0" should have the following comments on folder "/FOLDER_TO_COMMENT"
94+
| deleted_users | Comment from sharee |
95+
96+
Scenario: deleting a content owner deletes the comment
97+
Given user "user0" has been created
98+
And user "user0" has created a folder "/FOLDER_TO_COMMENT"
99+
And user "user0" has commented with content "Comment from owner" on folder "/FOLDER_TO_COMMENT"
100+
And user "user0" has been deleted
101+
And user "user0" has been created
102+
When user "user0" creates a folder "/FOLDER_TO_COMMENT" using the WebDAV API
103+
Then user "user0" should have 0 comments on folder "/FOLDER_TO_COMMENT"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@api @TestAlsoOnExternalUserBackend @comments-app-required
2+
Feature: Comments
3+
4+
Background:
5+
Given using new DAV path
6+
7+
@smokeTest
8+
Scenario: Edit my own comments on a file belonging to myself
9+
Given user "user0" has been created
10+
And user "user0" has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
11+
And user "user0" has commented with content "File owner comment" on file "/myFileToComment.txt"
12+
When user "user0" edits the last created comment with content "My edited comment" using the WebDAV API
13+
Then the HTTP status code should be "207"
14+
And user "user0" should have the following comments on file "/myFileToComment.txt"
15+
| user0 | My edited comment |
16+
17+
Scenario: Edit my own comments on a file shared by someone with me
18+
Given user "user0" has been created
19+
And user "user1" has been created
20+
And user "user0" has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
21+
And user "user0" has shared file "/myFileToComment.txt" with user "user1"
22+
And user "user1" has commented with content "Sharee comment" on file "/myFileToComment.txt"
23+
When user "user1" edits the last created comment with content "My edited comment" using the WebDAV API
24+
Then the HTTP status code should be "207"
25+
And user "user1" should have the following comments on file "/myFileToComment.txt"
26+
| user1 | My edited comment |
27+
28+
Scenario: Editing comments of other users should not be possible
29+
Given user "user0" has been created
30+
And user "user1" has been created
31+
And user "user0" has uploaded file "data/textfile.txt" to "/myFileToComment.txt"
32+
And user "user0" has shared file "/myFileToComment.txt" with user "user1"
33+
And user "user1" has commented with content "Sharee comment" on file "/myFileToComment.txt"
34+
And user "user0" should have the following comments on file "/myFileToComment.txt"
35+
| user1 | Sharee comment |
36+
When user "user0" edits the last created comment with content "User1 edited comment" using the WebDAV API
37+
Then the HTTP status code should be "403"
38+
And user "user0" should have the following comments on file "/myFileToComment.txt"
39+
| user1 | Sharee comment |
40+
41+
Scenario: Edit my own comments on a folder belonging to myself
42+
Given user "user0" has been created
43+
And user "user0" has created a folder "/FOLDER_TO_COMMENT"
44+
And user "user0" has commented with content "Folder owner comment" on folder "/FOLDER_TO_COMMENT"
45+
When user "user0" edits the last created comment with content "My edited comment" using the WebDAV API
46+
Then the HTTP status code should be "207"
47+
And user "user0" should have the following comments on folder "/FOLDER_TO_COMMENT"
48+
| user0 | My edited comment |

0 commit comments

Comments
 (0)