Skip to content

Commit 76ebdb0

Browse files
committed
add test for authorization repr
1 parent cbbcf74 commit 76ebdb0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

test/test_auth/test_authorization.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ def test_user_info(self):
116116
with self.assertRaises(asab.exceptions.NotAuthenticatedError):
117117
self.Authz.user_info()
118118

119+
def test_repr(self):
120+
self.assertEqual(self.Authz.__repr__(), "<Authorization [EXPIRED] cid=None>")
121+
119122

120123
class TestTenantAuthorized(unittest.TestCase):
121124
"""
@@ -218,6 +221,9 @@ def test_authorized_resources(self):
218221
"Entity is authorized to access RESOURCE_1, RESOURCE_2 in TENANT_1.",
219222
)
220223

224+
def test_repr(self):
225+
self.assertEqual(self.Authz.__repr__(), "<Authorization cid=None>")
226+
221227

222228
class TestTenantForbidden(unittest.TestCase):
223229
"""
@@ -326,6 +332,7 @@ def setUp(self):
326332
claims = {
327333
"iat": time.time() - 60,
328334
"exp": time.time() + 3600,
335+
"sub": "asab:test:testuser",
329336
"resources": {
330337
"*": [RESOURCE_1],
331338
TENANT_1: [RESOURCE_1, RESOURCE_2],
@@ -409,6 +416,9 @@ def test_authorized_resources(self):
409416
"Entity is globally authorized to access RESOURCE_1.",
410417
)
411418

419+
def test_repr(self):
420+
self.assertEqual(self.Authz.__repr__(), "<Authorization cid='asab:test:testuser'>")
421+
412422

413423
class TestSuperuserTenant(unittest.TestCase):
414424
"""
@@ -421,6 +431,7 @@ def setUp(self):
421431
claims = {
422432
"iat": time.time() - 60,
423433
"exp": time.time() + 3600,
434+
"sub": "asab:test:testuser",
424435
"resources": {
425436
"*": [RESOURCE_SUPERUSER],
426437
},
@@ -493,6 +504,9 @@ def test_authorized_resources(self):
493504
{RESOURCE_SUPERUSER},
494505
)
495506

507+
def test_repr(self):
508+
self.assertEqual(self.Authz.__repr__(), "<Authorization [SUPERUSER] cid='asab:test:testuser'>")
509+
496510

497511
class TestSuperuserGlobal(unittest.TestCase):
498512
"""

0 commit comments

Comments
 (0)