test_auth.py 1.4 KB

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