Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Compare revisions
5f672fcdd8c585e0c761397b4616db7c3a54dde0 to 40ae09c4ec1072a15b1f9625c6525b29dcb2872a
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
tddd96-grupp11/teknikattan-scoring-system
Select target project
No results found
40ae09c4ec1072a15b1f9625c6525b29dcb2872a
Select Git revision
Swap
Target
tddd96-grupp11/teknikattan-scoring-system
Select target project
tddd96-grupp11/teknikattan-scoring-system
1 result
5f672fcdd8c585e0c761397b4616db7c3a54dde0
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/populate.py
+2
-2
2 additions, 2 deletions
server/populate.py
server/tests/test_app.py
+29
-4
29 additions, 4 deletions
server/tests/test_app.py
with
31 additions
and
6 deletions
server/populate.py
View file @
40ae09c4
...
...
@@ -11,8 +11,8 @@ from app.database.models import City, QuestionType, Role
def
_add_items
():
media_types
=
[
"
Image
"
,
"
Video
"
]
question_types
=
[
"
Boolean
"
,
"
Multiple
"
,
"
Text
"
]
component_types
=
[
"
Text
"
,
"
Image
"
]
question_types
=
[
"
Text
"
,
"
Practical
"
,
"
Multiple
"
,
"
Single
"
]
component_types
=
[
"
Text
"
,
"
Image
"
,
"
Question
"
]
view_types
=
[
"
Team
"
,
"
Judge
"
,
"
Audience
"
,
"
Operator
"
]
roles
=
[
"
Admin
"
,
"
Editor
"
]
...
...
This diff is collapsed.
Click to expand it.
server/tests/test_app.py
View file @
40ae09c4
...
...
@@ -2,15 +2,37 @@
This file tests the api function calls.
"""
import
time
import
app.core.http_codes
as
codes
from
app.database.controller.add
import
competition
from
app.database.models
import
Slide
import
pytest
from
app.core
import
sockets
from
tests
import
app
,
client
,
db
from
tests.test_helpers
import
add_default_values
,
change_order_test
,
delete
,
get
,
post
,
put
# @pytest.mark.skip(reason="Takes long time")
def
test_locked_api
(
client
):
add_default_values
()
# Login in with default user but wrong password until blocked
for
i
in
range
(
4
):
response
,
body
=
post
(
client
,
"
/api/auth/login
"
,
{
"
email
"
:
"
test@test.se
"
,
"
password
"
:
"
password1
"
})
assert
response
.
status_code
==
codes
.
UNAUTHORIZED
# Login with right password, user should be locked
response
,
body
=
post
(
client
,
"
/api/auth/login
"
,
{
"
email
"
:
"
test@test.se
"
,
"
password
"
:
"
password
"
})
assert
response
.
status_code
==
codes
.
UNAUTHORIZED
# Sleep for 4 secounds
time
.
sleep
(
4
)
# Check so the user is no longer locked
response
,
body
=
post
(
client
,
"
/api/auth/login
"
,
{
"
email
"
:
"
test@test.se
"
,
"
password
"
:
"
password
"
})
assert
response
.
status_code
==
codes
.
OK
def
test_misc_api
(
client
):
add_default_values
()
...
...
@@ -125,6 +147,10 @@ def test_auth_and_user_api(client):
assert
response
.
status_code
==
codes
.
OK
headers
=
{
"
Authorization
"
:
"
Bearer
"
+
body
[
"
access_token
"
]}
# Login in with default user but wrong password
response
,
body
=
post
(
client
,
"
/api/auth/login
"
,
{
"
email
"
:
"
test@test.se
"
,
"
password
"
:
"
password1
"
})
assert
response
.
status_code
==
codes
.
UNAUTHORIZED
# Create user
register_data
=
{
"
email
"
:
"
test1@test.se
"
,
"
password
"
:
"
abc123
"
,
"
role_id
"
:
2
,
"
city_id
"
:
1
}
response
,
body
=
post
(
client
,
"
/api/auth/signup
"
,
register_data
,
headers
)
...
...
@@ -211,7 +237,6 @@ def test_auth_and_user_api(client):
assert
response
.
status_code
==
codes
.
OK
# TODO: Check if current users jwt (jti) is in blacklist after logging out
response
,
body
=
get
(
client
,
"
/api/users
"
,
headers
=
headers
)
assert
response
.
status_code
==
codes
.
UNAUTHORIZED
...
...
@@ -479,4 +504,4 @@ def test_authorization(client):
# Also get antoher teams answers
response
,
body
=
get
(
client
,
f
"
/api/competitions/
{
competition_id
}
/teams/
{
team_id
+
1
}
/answers
"
,
headers
=
headers
)
assert
response
.
status_code
==
codes
.
OK
\ No newline at end of file
assert
response
.
status_code
==
codes
.
OK
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
Next