Skip to content
Snippets Groups Projects
Commit 388b75eb authored by Arno Wunderlich's avatar Arno Wunderlich
Browse files

alter test to avoid using password in views.py

parent 05c976e4
No related branches found
No related tags found
1 merge request!50Fixing security issues from static testing
Pipeline #15700 failed
......@@ -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'))
......
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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment