Skip to content

Commit

Permalink
Add functional test for admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekj117 committed Jun 17, 2020
1 parent c327890 commit 9e43e6c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions securedrop/tests/functional/journalist_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,25 @@ def _add_user(self, username, first_name="", last_name="", is_admin=False, hotp=

self.wait_for(lambda: self.driver.find_element_by_id("check-token"))

def _admin_adds_a_user_with_invalid_username(self):
self.safe_click_by_id("add-user")

self.wait_for(lambda: self.driver.find_element_by_id("username"))

if not hasattr(self, "accept_languages"):
# The add user page has a form with an "ADD USER" button
btns = self.driver.find_elements_by_tag_name("button")
assert "ADD USER" in [el.text for el in btns]

invalid_username = 'deleted'

self.safe_send_keys_by_css_selector('input[name="username"]', invalid_username)

self.safe_click_by_css_selector("button[type=submit]")

error_msg = self.driver.find_element_by_css_selector(".form-validation-error")
assert "Invalid username '{}'".format(invalid_username) in error_msg.text

def _admin_adds_a_user(self, is_admin=False, new_username=""):
self.safe_click_by_id("add-user")

Expand Down
6 changes: 6 additions & 0 deletions securedrop/tests/functional/test_admin_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def test_ossec_alert_button(self):
self._admin_visits_system_config_page()
self._admin_can_send_test_alert()

def test_admin_adds_user_with_invalid_username(self):
self._admin_logs_in()
self._admin_visits_admin_interface()
# Add an user with invalid username
self._admin_adds_a_user_with_invalid_username()

def test_admin_adds_admin_user(self):
self._admin_logs_in()
self._admin_visits_admin_interface()
Expand Down

0 comments on commit 9e43e6c

Please sign in to comment.