Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
e8b06f5c
Commit
e8b06f5c
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
added black-box tests for auth, tweaked password login accordingly
parent
6fca75f3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
auth/auth_systems/password.py
+1
-1
1 addition, 1 deletion
auth/auth_systems/password.py
auth/bbtests.py
+0
-5
0 additions, 5 deletions
auth/bbtests.py
auth/tests.py
+44
-1
44 additions, 1 deletion
auth/tests.py
with
45 additions
and
7 deletions
auth/auth_systems/password.py
+
1
−
1
View file @
e8b06f5c
...
...
@@ -112,5 +112,5 @@ def update_status(token, message):
def
send_message
(
user_id
,
user_name
,
user_info
,
subject
,
body
):
if
user_info
.
has_key
(
'
email
'
):
email
=
user_info
[
'
email
'
]
name
=
user_info
.
get
(
'
name
'
,
email
)
name
=
user_name
or
user_info
.
get
(
'
name
'
,
email
)
send_mail
(
subject
,
body
,
settings
.
SERVER_EMAIL
,
[
"
%s <%s>
"
%
(
name
,
email
)],
fail_silently
=
False
)
This diff is collapsed.
Click to expand it.
auth/bbtests.py
deleted
100644 → 0
+
0
−
5
View file @
6fca75f3
"""
Black-box tests for Auth Systems
2010-08-11
"""
This diff is collapsed.
Click to expand it.
auth/tests.py
+
44
−
1
View file @
e8b06f5c
...
...
@@ -7,9 +7,14 @@ import models
from
django.db
import
IntegrityError
,
transaction
from
django.test.client
import
Client
from
django.test
import
TestCase
from
django.core
import
mail
from
auth_systems
import
AUTH_SYSTEMS
class
UserTests
(
unittest
.
TestCase
):
class
User
Model
Tests
(
unittest
.
TestCase
):
def
setUp
(
self
):
pass
...
...
@@ -72,3 +77,41 @@ class UserTests(unittest.TestCase):
u2
=
models
.
User
.
update_or_create
(
user_type
=
auth_system
,
user_id
=
'
foobar_eq
'
,
info
=
{
'
name
'
:
'
Foo Bar Status Update
'
})
self
.
assertEquals
(
u
,
u2
)
import
views
import
auth_systems.password
as
password_views
from
django.core.urlresolvers
import
reverse
# FIXME: login CSRF should make these tests more complicated
# and should be tested for
class
UserBlackboxTests
(
TestCase
):
def
setUp
(
self
):
# create a bogus user
self
.
test_user
=
models
.
User
.
objects
.
create
(
user_type
=
'
password
'
,
user_id
=
'
foobar_user
'
,
name
=
"
Foobar User
"
,
info
=
{
'
password
'
:
'
foobaz
'
,
'
email
'
:
'
foobar-test@adida.net
'
})
def
test_password_login
(
self
):
# get to the login page
login_page_response
=
self
.
client
.
get
(
reverse
(
views
.
start
,
kwargs
=
{
'
system_name
'
:
'
password
'
}),
follow
=
True
)
# log in and follow all redirects
response
=
self
.
client
.
post
(
reverse
(
password_views
.
password_login_view
),
{
'
username
'
:
'
foobar_user
'
,
'
password
'
:
'
foobaz
'
},
follow
=
True
)
self
.
assertContains
(
response
,
"
logged in as
"
)
self
.
assertContains
(
response
,
"
Foobar User
"
)
def
test_logout
(
self
):
response
=
self
.
client
.
post
(
reverse
(
views
.
logout
),
follow
=
True
)
self
.
assertContains
(
response
,
"
not logged in
"
)
self
.
assertNotContains
(
response
,
"
Foobar User
"
)
def
test_email
(
self
):
"""
using the test email backend
"""
self
.
test_user
.
send_message
(
"
testing subject
"
,
"
testing body
"
)
self
.
assertEquals
(
len
(
mail
.
outbox
),
1
)
self
.
assertEquals
(
mail
.
outbox
[
0
].
subject
,
"
testing subject
"
)
self
.
assertEquals
(
mail
.
outbox
[
0
].
to
[
0
],
"
Foobar User <foobar-test@adida.net>
"
)
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