diff --git a/tests/acceptance/bootstrap/AuthContext.php b/tests/acceptance/bootstrap/AuthContext.php index d0a256f1b23..dbbe82c8602 100644 --- a/tests/acceptance/bootstrap/AuthContext.php +++ b/tests/acceptance/bootstrap/AuthContext.php @@ -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, diff --git a/tests/acceptance/features/apiAuthApp/tokenUsage.feature b/tests/acceptance/features/apiAuthApp/tokenUsage.feature index f9585f76f61..1a5093054de 100644 --- a/tests/acceptance/features/apiAuthApp/tokenUsage.feature +++ b/tests/acceptance/features/apiAuthApp/tokenUsage.feature @@ -85,4 +85,52 @@ Feature: create auth-app token } } } - """ \ No newline at end of file + """ + + + 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"