Skip to content
Snippets Groups Projects
Verified Commit bb15eb84 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[Tests] Add test for logging in with default admin credentials

parent 80ec166a
No related branches found
No related tags found
No related merge requests found
Checking pipeline status
......@@ -2,7 +2,9 @@ import os
import pytest
from django.conf import settings
from django.test.selenium import SeleniumTestCase, SeleniumTestCaseBase
from django.urls import reverse
SeleniumTestCaseBase.external_host = os.environ.get('TEST_HOST', '') or None
SeleniumTestCaseBase.browsers = list(filter(bool, os.environ.get('TEST_SELENIUM_BROWSERS', '').split(',')))
......@@ -23,3 +25,31 @@ class SeleniumTests(SeleniumTestCase):
self.selenium.get(self.live_server_url + '/')
assert 'BiscuIT' in self.selenium.title
self._screenshot('index.png')
@pytest.mark.django_db
def test_login_default_superuser(self):
username = 'admin'
password = 'admin'
# Navigate to configured login page
self.selenium.get(self.live_server_url + reverse(settings.LOGIN_URL))
self._screenshot('login_default_superuser_blank.png')
# Find login form input fields and enter defined credentials
self.selenium.find_element_by_xpath(
'//label[contains(text(), "Username")]/../input'
).send_keys(username)
self.selenium.find_element_by_xpath(
'//label[contains(text(), "Password")]/../input'
).send_keys(password)
self._screenshot('login_default_superuser_filled.png')
# Submit form by clicking django-two-factor-auth's Next button
self.selenium.find_element_by_xpath(
'//button[contains(text(), "Next")]'
).click()
self._screenshot('login_default_superuser_submitted.png')
# Should redirect away from login page and not put up an alert about wrong credentials
assert 'Please enter a correct username and password.' not in self.selenium.page_source
assert reverse(settings.LOGIN_URL) not in self.selenium.current_url
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment