Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
bb15eb84
Verified
Commit
bb15eb84
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
[Tests] Add test for logging in with default admin credentials
parent
80ec166a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Checking pipeline status
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biscuit/core/tests/browser/test_selenium.py
+30
-0
30 additions, 0 deletions
biscuit/core/tests/browser/test_selenium.py
with
30 additions
and
0 deletions
biscuit/core/tests/browser/test_selenium.py
+
30
−
0
View file @
bb15eb84
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment