forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SiteWide ACL: Milestone 1.2 (oppia#3517)
* UI for view role added * UI part done. * Role graph visualization added. * Complete functionality done with changes in config domain being reflected to roles. * tidying up the code. * linting issues fixed. * backend test updated. * requested changes done. * Requested changes done (except for role-graph). * replaced role graph directive with a directive for general static graphs and used it in history tab. * directive name changed to static-graph. changes made. * reverted to using stripped up version of state graph for role graph. * requested changes made. * config revert property made to sync with new role system. * role graph further stripped and test for admin role started. * email actions can now be performed by admins instead of super admins. so made changes in syncing config tab changes to new system. * Test added to check view and update. * test written and storage model made for storing query info. * adding comment for attribute nature of directive. * lint fixes. * test updated. * ADMIN_SHOW_UPDATE_ROLE turned to false. * requested changes made. * requested changes made. * minor changes made. * lint fixes. * requested changes done. * test added for get_by_role. * changed an import and changed show update form to false. * list fixes. * requested changes made. * test added for get_role_changes.
- Loading branch information
1 parent
e8fa9d4
commit 37d3fdd
Showing
28 changed files
with
1,198 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
from core.controllers import base | ||
from core.tests import test_utils | ||
import feconf | ||
|
||
|
||
BOTH_MODERATOR_AND_ADMIN_EMAIL = '[email protected]' | ||
|
@@ -98,3 +99,65 @@ def test_change_about_page_config_property(self): | |
|
||
response = self.testapp.get('/about') | ||
self.assertIn(new_config_value, response.body) | ||
|
||
|
||
class AdminRoleHandlerTest(test_utils.GenericTestBase): | ||
"""Checks the user role handling on the admin page.""" | ||
|
||
def setUp(self): | ||
"""Complete the signup process for self.ADMIN_EMAIL.""" | ||
super(AdminRoleHandlerTest, self).setUp() | ||
self.signup(self.ADMIN_EMAIL, self.ADMIN_USERNAME) | ||
self.set_admins([self.ADMIN_USERNAME]) | ||
|
||
def test_view_and_update_role(self): | ||
user_email = '[email protected]' | ||
user_name = 'user1' | ||
|
||
self.signup(user_email, user_name) | ||
|
||
self.login(self.ADMIN_EMAIL, is_super_admin=True) | ||
# Check normal user has expected role. Viewing by username. | ||
response_dict = self.get_json( | ||
feconf.ADMIN_ROLE_HANDLER_URL, | ||
{'method': 'username', 'username': 'user1'}) | ||
self.assertEqual( | ||
response_dict, {'user1': feconf.ROLE_ID_EXPLORATION_EDITOR}) | ||
|
||
# Check role correctly gets updated. | ||
response = self.testapp.get(feconf.ADMIN_URL) | ||
csrf_token = self.get_csrf_token_from_response(response) | ||
response_dict = self.post_json( | ||
feconf.ADMIN_ROLE_HANDLER_URL, | ||
{'role': feconf.ROLE_ID_MODERATOR, 'username': user_name}, | ||
csrf_token=csrf_token, expect_errors=False, | ||
expected_status_int=200) | ||
self.assertEqual(response_dict, {}) | ||
|
||
# Viewing by role. | ||
response_dict = self.get_json( | ||
feconf.ADMIN_ROLE_HANDLER_URL, | ||
{'method': 'role', 'role': feconf.ROLE_ID_MODERATOR}) | ||
self.assertEqual(response_dict, {'user1': feconf.ROLE_ID_MODERATOR}) | ||
self.logout() | ||
|
||
def test_invalid_username_in_view_and_update_role(self): | ||
username = 'myinvaliduser' | ||
|
||
self.login(self.ADMIN_EMAIL, is_super_admin=True) | ||
|
||
# Trying to view role of non-existent user. | ||
response = self.get_json( | ||
feconf.ADMIN_ROLE_HANDLER_URL, | ||
{'method': 'username', 'username': username}, | ||
expect_errors=True) | ||
self.assertEqual(response['code'], 400) | ||
|
||
# Trying to update role of non-existent user. | ||
response = self.testapp.get(feconf.ADMIN_URL) | ||
csrf_token = self.get_csrf_token_from_response(response) | ||
response = self.post_json( | ||
feconf.ADMIN_ROLE_HANDLER_URL, | ||
{'role': feconf.ROLE_ID_MODERATOR, 'username': username}, | ||
csrf_token=csrf_token, expect_errors=True, | ||
expected_status_int=400) |
Oops, something went wrong.