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

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: Consolidate permissions 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
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..77cef050a8736e7f0b13ba4bc63d16d8468e9f25 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'can_cancel_task': False,
+ u'can_terminate_bot': False,
+ u'can_delete_bot': False,
+ u'can_get_configs': False,
+ u'can_put_configs': False,
+ u'can_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'can_cancel_task': True,
+ u'can_terminate_bot': False,
+ u'can_delete_bot': False,
+ u'can_get_configs': True,
+ u'can_put_configs': False,
+ u'can_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'can_cancel_task': True,
+ u'can_terminate_bot': True,
+ u'can_delete_bot': False,
+ u'can_get_configs': True,
+ u'can_put_configs': False,
+ u'can_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'can_cancel_task': True,
+ u'can_terminate_bot': True,
+ u'can_delete_bot': True,
+ u'can_get_configs': True,
+ u'can_put_configs': True,
+ u'can_get_bootstrap_token': True,
+ }
+ self.assertEqual(expected, response.json)
+
def _test_file(self, name):
self.set_as_admin()

Powered by Google App Engine
This is Rietveld 408576698