test_auth.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from sentry.testutils import AcceptanceTestCase
  2. class AuthTest(AcceptanceTestCase):
  3. def enter_auth(self, username, password):
  4. self.browser.get("/auth/login/")
  5. self.browser.driver.execute_script(
  6. "document.addEventListener('invalid', function(e) { e.preventDefault(); }, true);"
  7. )
  8. self.browser.find_element_by_id("id_username").send_keys(username)
  9. self.browser.find_element_by_id("id_password").send_keys(password)
  10. self.browser.find_element_by_xpath("//button[contains(text(), 'Continue')]").click()
  11. def test_renders(self):
  12. self.browser.get("/auth/login/")
  13. self.browser.snapshot(name="login")
  14. def test_no_credentials(self):
  15. self.enter_auth("", "")
  16. self.browser.snapshot(name="login fields required")
  17. def test_invalid_credentials(self):
  18. self.enter_auth("bad-username", "bad-username")
  19. self.browser.snapshot(name="login fields invalid")
  20. def test_success(self):
  21. email = "dummy@example.com"
  22. password = "dummy"
  23. user = self.create_user(email=email)
  24. user.set_password(password)
  25. user.save()
  26. self.enter_auth(email, password)
  27. self.browser.wait_until_not(".loading")
  28. self.browser.snapshot(name="login success")