Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2218)

Unified Diff: appengine/swarming/handlers_endpoints_test.py

Issue 2272193004: Add endpoint for permissions (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@migrate-botlist
Patch Set: Address comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/handlers_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/handlers_endpoints_test.py
diff --git a/appengine/swarming/handlers_endpoints_test.py b/appengine/swarming/handlers_endpoints_test.py
index 2b58c11b98fc810ffe3b9aeb2450e17cf4b9fc33..c209537daf34215ff328662e8a08dfacc56c3971 100755
--- a/appengine/swarming/handlers_endpoints_test.py
+++ b/appengine/swarming/handlers_endpoints_test.py
@@ -70,6 +70,62 @@ class ServerApiTest(BaseTest):
response = self.call_api('details')
self.assertEqual({'server_version': utils.get_app_version()}, response.json)
+ def test_public_permissions(self):
+ """Asserts that permissions respond correctly to an unauthed user."""
+ self.set_as_anonymous()
+ response = self.call_api('permissions')
+ expected = {
+ u'cancel_task': False,
+ u'terminate_bot': False,
+ u'delete_bot': False,
+ u'get_configs': False,
+ u'put_configs': False,
+ u'get_bootstrap_token': False,
+ }
+ self.assertEqual(expected, response.json)
+
+ def test_user_permissions(self):
+ """Asserts that permissions respond correctly to a basic user."""
+ self.set_as_user()
+ response = self.call_api('permissions')
+ expected = {
+ u'cancel_task': True,
+ u'terminate_bot': False,
+ u'delete_bot': False,
+ u'get_configs': True,
+ u'put_configs': False,
+ u'get_bootstrap_token': False,
+ }
+ self.assertEqual(expected, response.json)
+
+ def test_privileged_user_permissions(self):
+ """Asserts that permissions respond correctly to a privileged user."""
+ self.set_as_privileged_user()
+ response = self.call_api('permissions')
+ expected = {
+ u'cancel_task': True,
+ u'terminate_bot': True,
+ u'delete_bot': False,
+ u'get_configs': True,
+ u'put_configs': False,
+ u'get_bootstrap_token': False,
+ }
+ self.assertEqual(expected, response.json)
+
+ def test_admin_permissions(self):
+ """Asserts that permissions respond correctly to an admin."""
+ self.set_as_admin()
+ response = self.call_api('permissions')
+ expected = {
+ u'cancel_task': True,
+ u'terminate_bot': True,
+ u'delete_bot': True,
+ u'get_configs': True,
+ u'put_configs': True,
+ u'get_bootstrap_token': True,
+ }
+ self.assertEqual(expected, response.json)
+
def _test_file(self, name):
self.set_as_admin()
« no previous file with comments | « appengine/swarming/handlers_endpoints.py ('k') | appengine/swarming/handlers_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698