Skip to content

Commit

Permalink
Merge pull request #3854 from deepthinidwannaya/3608-add-admin-user-f…
Browse files Browse the repository at this point in the history
…unctional-test

3608 - Add admin checkbox clicks and test case for an admin to create…
  • Loading branch information
heartsucker authored Oct 10, 2018
2 parents 8dcbfd5 + c1fd4ac commit 890321e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 13 additions & 3 deletions securedrop/tests/functional/journalist_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,16 @@ def _add_user(self, username, is_admin=False, hotp=None):
hotp_secret.send_keys(hotp)

if is_admin:
raise NotImplementedError("Admin's can't be added yet.")
is_admin_checkbox = self.driver.find_element_by_css_selector(
'input[name="is_admin"]'
)
is_admin_checkbox.click()

submit_button = self.driver.find_element_by_css_selector(
'button[type=submit]')
submit_button.click()

def _admin_adds_a_user(self):
def _admin_adds_a_user(self, is_admin=False):
add_user_btn = self.driver.find_element_by_css_selector(
'button#add-user')
add_user_btn.click()
Expand All @@ -257,7 +260,7 @@ def _admin_adds_a_user(self):
username='dellsberg',
password=password,
)
self._add_user(self.new_user['username'])
self._add_user(self.new_user['username'], is_admin=is_admin)

if not hasattr(self, 'accept_languages'):
# Clicking submit on the add user form should redirect to
Expand Down Expand Up @@ -352,6 +355,13 @@ def _new_user_can_log_in(self):
with pytest.raises(NoSuchElementException):
self.driver.find_element_by_id('link-admin-index')

def _new_admin_user_can_log_in(self):
# Test login with mocked token
self._check_login_with_otp('mocked')

# Newly added user who is an admin can visit admin interface
self._admin_visits_admin_interface()

def _edit_account(self):
edit_account_link = self.driver.find_element_by_id(
'link-edit-account')
Expand Down
8 changes: 8 additions & 0 deletions securedrop/tests/functional/test_admin_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ def test_ossec_alert_button(self):
self._admin_visits_admin_interface()
self._admin_visits_system_config_page()
self._admin_can_send_test_alert()

def test_admin_adds_admin_user(self):
self._admin_logs_in()
self._admin_visits_admin_interface()
# Add an admin user
self._admin_adds_a_user(is_admin=True)
self._new_admin_user_can_log_in()
self._admin_can_edit_new_user()

0 comments on commit 890321e

Please sign in to comment.