test_auth.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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
  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. def test_no_credentials(self):
  19. self.enter_auth("", "")
  20. def test_invalid_credentials(self):
  21. self.enter_auth("bad-username", "bad-username")
  22. def test_success(self):
  23. email = "dummy@example.com"
  24. password = "dummy"
  25. user = self.create_user(email=email)
  26. user.set_password(password)
  27. user.save()
  28. self.enter_auth(email, password)
  29. self.browser.wait_until_not(".loading")