Merge pull request #11185 from owncloud/test/access-resource-using-token

[tests-only][full-ci] add test to access resource of another user using impersonation token.
This commit is contained in:
Prashant Gurung authored and GitHub committed 2025-04-11 17:24:37 +05:45
commit f2885d8781
2 files changed
+51 -2

No files matched your search

+2 -1
View File
@@ -556,6 +556,7 @@ class AuthContext implements Context {
/**
* @When user :asUser requests these endpoints with :method using the password of user :ofUser
* @When user :asUser requests these endpoints with :method using the auth-app token of user :ofUser
*
* @param string $asUser
* @param string $method
@@ -565,7 +566,7 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser(
public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOrAuthAppTokenOfUser(
string $asUser,
string $method,
string $ofUser,
@@ -85,4 +85,52 @@ Feature: create auth-app token
}
}
}
"""
"""
Scenario: admin tries to access resource of another user using auth-app token
Given user "Alice" has created auth-app token with expiration time "72h" using the auth-app API
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt"
When user "Admin" requests these endpoints with "PROPFIND" using the auth-app token of user "Alice"
| endpoint |
| /webdav/textfile.txt |
| /dav/files/%username%/textfile.txt |
| /dav/spaces/%spaceid%/textfile.txt |
Then the HTTP status code of responses on all endpoints should be "401"
Scenario: non-admin user tries to access resource of another user using auth-app token
Given user "Alice" has created auth-app token with expiration time "72h" using the auth-app API
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt"
And user "Brian" has been created with default attributes
When user "Brian" requests these endpoints with "PROPFIND" using the auth-app token of user "Alice"
| endpoint |
| /webdav/textfile.txt |
| /dav/files/%username%/textfile.txt |
| /dav/spaces/%spaceid%/textfile.txt |
Then the HTTP status code of responses on all endpoints should be "401"
@env-config
Scenario: admin tries to access resource of another user using impersonation token
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true"
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt"
When user "Admin" requests these endpoints with "PROPFIND" using the auth-app token of user "Alice"
| endpoint |
| /webdav/textfile.txt |
| /dav/files/%username%/textfile.txt |
| /dav/spaces/%spaceid%/textfile.txt |
Then the HTTP status code of responses on all endpoints should be "401"
@env-config
Scenario: non-admin user tries to access resource of another user using impersonation token
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true"
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt"
And user "Brian" has been created with default attributes
When user "Brian" requests these endpoints with "PROPFIND" using the auth-app token of user "Alice"
| endpoint |
| /webdav/textfile.txt |
| /dav/files/%username%/textfile.txt |
| /dav/spaces/%spaceid%/textfile.txt |
Then the HTTP status code of responses on all endpoints should be "401"