Skip to content
Snippets Groups Projects
Verified Commit 112e5863 authored by Martin Weise's avatar Martin Weise
Browse files

Fixed tests

parent d5d7ac9e
Branches
Tags
2 merge requests!372WIP,!371Hotfix the wrong user id, ref #480
...@@ -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)
...@@ -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():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment