Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
39b55537
Kaydet (Commit)
39b55537
authored
Agu 18, 2015
tarafından
David Gibbons
Kaydeden (comit)
Tim Graham
Agu 18, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added two more tests for user-entered passwords when creating a superuser.
üst
b04544e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
test_management.py
tests/auth_tests/test_management.py
+66
-0
No files found.
tests/auth_tests/test_management.py
Dosyayı görüntüle @
39b55537
...
...
@@ -498,6 +498,72 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
test
(
self
)
def
test_validation_mismatched_passwords
(
self
):
"""
Creation should fail if the user enters mismatched passwords.
"""
new_io
=
six
.
StringIO
()
# The first two passwords do not match, but the second two do match and
# are valid.
entered_passwords
=
[
"password"
,
"not password"
,
"password2"
,
"password2"
]
def
mismatched_passwords_then_matched
():
return
entered_passwords
.
pop
(
0
)
@mock_inputs
({
'password'
:
mismatched_passwords_then_matched
,
'username'
:
'joe1234567890'
,
})
def
test
(
self
):
call_command
(
"createsuperuser"
,
interactive
=
True
,
stdin
=
MockTTY
(),
stdout
=
new_io
,
stderr
=
new_io
,
)
self
.
assertEqual
(
new_io
.
getvalue
()
.
strip
(),
"Error: Your passwords didn't match.
\n
"
"Superuser created successfully."
)
test
(
self
)
def
test_validation_blank_password_entered
(
self
):
"""
Creation should fail if the user enters blank passwords.
"""
new_io
=
six
.
StringIO
()
# The first two passwords are empty strings, but the second two are
# valid.
entered_passwords
=
[
""
,
""
,
"password2"
,
"password2"
]
def
blank_passwords_then_valid
():
return
entered_passwords
.
pop
(
0
)
@mock_inputs
({
'password'
:
blank_passwords_then_valid
,
'username'
:
'joe1234567890'
,
})
def
test
(
self
):
call_command
(
"createsuperuser"
,
interactive
=
True
,
stdin
=
MockTTY
(),
stdout
=
new_io
,
stderr
=
new_io
,
)
self
.
assertEqual
(
new_io
.
getvalue
()
.
strip
(),
"Error: Blank passwords aren't allowed.
\n
"
"Superuser created successfully."
)
test
(
self
)
class
CustomUserModelValidationTestCase
(
SimpleTestCase
):
@override_settings
(
AUTH_USER_MODEL
=
'auth.CustomUserNonListRequiredFields'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment