Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
d4446b6b
Commit
d4446b6b
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
unit test showing security issue
parent
3876fca6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!127
v0.10.2 into master
,
!126
security issue solved using external middleware
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/view/test_doctor.py
+27
-7
27 additions, 7 deletions
smash/web/tests/view/test_doctor.py
with
27 additions
and
7 deletions
smash/web/tests/view/test_doctor.py
+
27
−
7
View file @
d4446b6b
...
...
@@ -30,6 +30,32 @@ class DoctorViewTests(LoggedInTestCase):
location
=
create_location
()
count
=
Worker
.
objects
.
all
().
count
()
form_data
=
self
.
create_add_worker_form_data
(
language
,
location
)
response
=
self
.
client
.
post
(
reverse
(
'
web.views.doctor_add
'
),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
302
)
new_count
=
Worker
.
objects
.
all
().
count
()
self
.
assertEqual
(
count
+
1
,
new_count
)
def
test_security_in_worker_added_request
(
self
):
self
.
client
.
logout
()
language
=
create_language
()
location
=
create_location
()
count
=
Worker
.
objects
.
all
().
count
()
form_data
=
self
.
create_add_worker_form_data
(
language
,
location
)
self
.
client
.
post
(
reverse
(
'
web.views.doctor_add
'
),
data
=
form_data
)
new_count
=
Worker
.
objects
.
all
().
count
()
# new user shouldn't be added
self
.
assertEqual
(
count
,
new_count
)
@staticmethod
def
create_add_worker_form_data
(
language
,
location
):
form
=
WorkerAddForm
()
form_data
=
{}
for
key
,
value
in
form
.
initial
.
items
():
...
...
@@ -44,13 +70,7 @@ class DoctorViewTests(LoggedInTestCase):
form_data
[
"
specialization
"
]
=
"
tester
"
form_data
[
"
languages
"
]
=
[
language
.
id
]
form_data
[
"
locations
"
]
=
[
location
.
id
]
response
=
self
.
client
.
post
(
reverse
(
'
web.views.doctor_add
'
),
data
=
form_data
)
self
.
assertEqual
(
response
.
status_code
,
302
)
new_count
=
Worker
.
objects
.
all
().
count
()
self
.
assertEqual
(
count
+
1
,
new_count
)
return
form_data
def
test_render_edit_worker_request
(
self
):
worker
=
create_worker
()
...
...
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