Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
112e5863
Verified
Commit
112e5863
authored
5 months ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
Fixed tests
Signed-off-by:
Martin Weise
<
martin.weise@tuwien.ac.at
>
parent
d5d7ac9e
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!372
WIP
,
!371
Hotfix the wrong user id, ref #480
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dbrepo-search-service/test/test_jwt.py
+12
-11
12 additions, 11 deletions
dbrepo-search-service/test/test_jwt.py
dbrepo-search-service/test/test_opensearch_client.py
+1
-2
1 addition, 2 deletions
dbrepo-search-service/test/test_opensearch_client.py
with
13 additions
and
13 deletions
dbrepo-search-service/test/test_jwt.py
+
12
−
11
View file @
112e5863
...
@@ -12,9 +12,9 @@ class JwtTest(unittest.TestCase):
...
@@ -12,9 +12,9 @@ class JwtTest(unittest.TestCase):
def
response
(
self
,
roles
:
[
str
])
->
dict
:
def
response
(
self
,
roles
:
[
str
])
->
dict
:
return
dict
({
return
dict
({
"
client_id
"
:
"
username
"
,
'
client_id
'
:
'
username
'
,
"
realm_access
"
:
{
'
realm_access
'
:
{
"
roles
"
:
roles
'
roles
'
:
roles
}
}
})
})
...
@@ -37,13 +37,13 @@ class JwtTest(unittest.TestCase):
...
@@ -37,13 +37,13 @@ class JwtTest(unittest.TestCase):
def
test_verify_token_empty_token_fails
(
self
):
def
test_verify_token_empty_token_fails
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
# test
# test
user
=
verify_token
(
""
)
user
=
verify_token
(
''
)
self
.
assertFalse
(
user
)
self
.
assertFalse
(
user
)
def
test_verify_token_malformed_token_fails
(
self
):
def
test_verify_token_malformed_token_fails
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
# test
# test
user
=
verify_token
(
"
eyEYEY12345
"
)
user
=
verify_token
(
'
eyEYEY12345
'
)
self
.
assertFalse
(
user
)
self
.
assertFalse
(
user
)
def
test_verify_token_succeeds
(
self
):
def
test_verify_token_succeeds
(
self
):
...
@@ -59,25 +59,25 @@ class JwtTest(unittest.TestCase):
...
@@ -59,25 +59,25 @@ class JwtTest(unittest.TestCase):
def
test_verify_password_no_username_fails
(
self
):
def
test_verify_password_no_username_fails
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
# test
# test
user
=
verify_password
(
None
,
"
pass
"
)
user
=
verify_password
(
None
,
'
pass
'
)
self
.
assertFalse
(
user
)
self
.
assertFalse
(
user
)
def
test_verify_password_empty_username_fails
(
self
):
def
test_verify_password_empty_username_fails
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
# test
# test
user
=
verify_password
(
""
,
"
pass
"
)
user
=
verify_password
(
''
,
'
pass
'
)
self
.
assertFalse
(
user
)
self
.
assertFalse
(
user
)
def
test_verify_password_no_password_fails
(
self
):
def
test_verify_password_no_password_fails
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
# test
# test
user
=
verify_password
(
"
username
"
,
None
)
user
=
verify_password
(
'
username
'
,
None
)
self
.
assertFalse
(
user
)
self
.
assertFalse
(
user
)
def
test_verify_password_empty_password_fails
(
self
):
def
test_verify_password_empty_password_fails
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
# test
# test
user
=
verify_password
(
"
username
"
,
""
)
user
=
verify_password
(
'
username
'
,
''
)
self
.
assertFalse
(
user
)
self
.
assertFalse
(
user
)
def
test_verify_password_succeeds
(
self
):
def
test_verify_password_succeeds
(
self
):
...
@@ -87,11 +87,12 @@ class JwtTest(unittest.TestCase):
...
@@ -87,11 +87,12 @@ class JwtTest(unittest.TestCase):
mock
.
post
(
'
http://auth-service:8080/api/auth/realms/dbrepo/protocol/openid-connect/token
'
,
mock
.
post
(
'
http://auth-service:8080/api/auth/realms/dbrepo/protocol/openid-connect/token
'
,
json
=
self
.
response
([]))
json
=
self
.
response
([]))
# test
# test
user
=
verify_password
(
"
username
"
,
"
password
"
)
user
=
verify_password
(
'
username
'
,
'
password
'
)
self
.
assertIsNotNone
(
user
)
self
.
assertIsNotNone
(
user
)
def
test_get_user_roles_succeeds
(
self
):
def
test_get_user_roles_succeeds
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
# test
# test
roles
:
[
str
]
=
get_user_roles
(
User
(
username
=
"
username
"
,
roles
=
[]))
roles
:
[
str
]
=
get_user_roles
(
User
(
id
=
'
b98415d8-28bc-4472-84ff-3d09cc79aff6
'
,
username
=
'
username
'
,
roles
=
[]))
self
.
assertEqual
([],
roles
)
self
.
assertEqual
([],
roles
)
This diff is collapsed.
Click to expand it.
dbrepo-search-service/test/test_opensearch_client.py
+
1
−
2
View file @
112e5863
...
@@ -189,8 +189,7 @@ class OpenSearchClientTest(unittest.TestCase):
...
@@ -189,8 +189,7 @@ class OpenSearchClientTest(unittest.TestCase):
OpenSearchClient
().
update_database
(
database_id
=
req
.
id
,
data
=
req
)
OpenSearchClient
().
update_database
(
database_id
=
req
.
id
,
data
=
req
)
# test
# test
response
=
OpenSearchClient
().
fuzzy_search
(
search_term
=
"
test
"
)
OpenSearchClient
().
fuzzy_search
(
search_term
=
"
test_tuw
"
)
self
.
assertTrue
(
len
(
response
)
>
0
)
def
test_unit_independent_search_fails
(
self
):
def
test_unit_independent_search_fails
(
self
):
with
app
.
app_context
():
with
app
.
app_context
():
...
...
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