Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
frozen
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
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
CSE6
frozen
Commits
388b75eb
Commit
388b75eb
authored
2 years ago
by
Arno Wunderlich
Browse files
Options
Downloads
Patches
Plain Diff
alter test to avoid using password in views.py
parent
05c976e4
No related branches found
No related tags found
1 merge request
!50
Fixing security issues from static testing
Pipeline
#15700
failed
2 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tjts5901/views.py
+2
-0
2 additions, 0 deletions
src/tjts5901/views.py
tests/test_db.py
+17
-1
17 additions, 1 deletion
tests/test_db.py
with
19 additions
and
1 deletion
src/tjts5901/views.py
+
2
−
0
View file @
388b75eb
...
...
@@ -73,6 +73,7 @@ def test_item_adding():
with
open
(
"
src/tjts5901/test.jpeg
"
,
"
rb
"
)
as
image_file
:
image
=
image_file
.
read
()
# Create a new item
item
=
Item
()
item
.
title
=
"
Test title
"
...
...
@@ -82,6 +83,7 @@ def test_item_adding():
item
.
image
=
image
item
.
save
()
return
"
OK
"
@bp.route
(
"
/addItem
"
,
methods
=
(
'
GET
'
,
'
POST
'
))
...
...
This diff is collapsed.
Click to expand it.
tests/test_db.py
+
17
−
1
View file @
388b75eb
import
random
from
flask_login
import
login_user
from
tjts5901.views
import
test_item_adding
from
tjts5901.models
import
User
def
test_db
():
"""
Testing the db connection via previously defined test method
"""
#assert init_db({'TESTING': True}).testing
# for test purpose create random number (unique mail address required)
ran_int
=
str
(
random
.
randint
(
0
,
10000
))
# Create a new user
user
=
User
()
user
.
email
=
"
test
"
+
ran_int
+
"
@gmail.com
"
user
.
password
=
"
placeholder
"
user
.
save
()
#login with this user
login_user
(
user
,
remember
=
False
)
assert
test_item_adding
()
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