forked from EGCETSII/decide_django_2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EGCETSII#42 from Decide-Part-Penyagolosa-1/jesgaml…
…ar-authentication Pruebas realizadas por jesgamlar
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from django.test import TestCase | ||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase | ||
|
||
from selenium import webdriver | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support import expected_conditions as EC, wait | ||
from selenium.webdriver.common.keys import Keys | ||
|
||
|
||
from base.tests import BaseTestCase | ||
|
||
class AdminTestCase(StaticLiveServerTestCase): | ||
|
||
|
||
def setUp(self): | ||
#Load base test functionality for decide | ||
self.base = BaseTestCase() | ||
self.base.setUp() | ||
|
||
options = webdriver.ChromeOptions() | ||
options.headless = True | ||
self.driver = webdriver.Chrome(options=options) | ||
self.accept_next_alert = True | ||
|
||
self.githubEmail = '[email protected]' | ||
super().setUp() | ||
|
||
def tearDown(self): | ||
super().tearDown() | ||
self.driver.quit() | ||
|
||
self.base.tearDown() | ||
|
||
def test_loginAdminSuccess(self): | ||
driver = self.driver | ||
driver.get("http://localhost:8000/admin") | ||
driver.find_element_by_id("id_username").clear() | ||
driver.find_element_by_id("id_username").send_keys("jesus") | ||
driver.find_element_by_id("id_password").clear() | ||
driver.find_element_by_id("id_password").send_keys("practica",Keys.ENTER) | ||
self.assertEqual("Django administration", driver.find_element_by_link_text("Django administration").text) | ||
driver.get("http://localhost:8000/admin/logout") | ||
|
||
def test_loginAuthGithubSuccess(self): | ||
driver = self.driver | ||
driver.get("http://localhost:8000/authentication/accounts/github/login/") | ||
driver.find_element_by_id("login_field").clear() | ||
driver.find_element_by_id("login_field").send_keys("penyagolosa-1-decide") | ||
driver.find_element_by_id("password").clear() | ||
driver.find_element_by_id("password").send_keys("Jornada2022") | ||
driver.find_element_by_id("password").send_keys(Keys.ENTER) | ||
WebDriverWait(driver, 15) | ||
self.assertEqual(driver.current_url, "http://localhost:8000/booth/voting" ) | ||
|
||
def test_loginAuthGithubError(self): | ||
driver = self.driver | ||
driver.get("http://localhost:8000/authentication/accounts/github/login/") | ||
driver.find_element_by_id("login_field").clear() | ||
driver.find_element_by_id("login_field").send_keys("penyagolosa-1-decide") | ||
driver.find_element_by_id("password").clear() | ||
driver.find_element_by_id("password").send_keys("123") | ||
driver.find_element_by_name("commit").click() | ||
self.assertEqual("Incorrect username or password.", driver.find_element_by_xpath("//div[@id='js-flash-container']/div/div").text) | ||
|
||
|