11from unittest import TestCase
2+
3+ from ..provider .dto import Tenancy # noqa: TID252
24from .acls import (
3- ACL_KEYS ,
45 ACL_ALLOW_IDS_KEY ,
56 ACL_ALLOW_PATTERN_KEY ,
67 ACL_DENY_IDS_KEY ,
78 ACL_DENY_PATTERN_KEY ,
9+ ACL_KEYS ,
810 allowed_by_acls ,
911)
1012
11- from ..provider .dto import Tenancy
12-
1313
1414class ACLTestCase (TestCase ):
15-
1615 def assert_allowed (self , resource , tenancy ):
1716 """Helper method to make logic clearer"""
1817 self .assertTrue (allowed_by_acls (resource , tenancy ))
@@ -28,7 +27,8 @@ def test_no_annotations(self):
2827 for t in tenancies :
2928 self .assert_allowed (test_resource , t )
3029
31- # Check that all tenancies are allowed when all ACL annotations are present but empty
30+ # Check that all tenancies are allowed when all ACL annotations are present but
31+ # empty
3232 def test_empty_annotations (self ):
3333 tenancies = [Tenancy (id = f"test-id-{ i } " , name = f"name-{ i } " ) for i in range (3 )]
3434 test_resource = {"metadata" : {"annotations" : {k : "" for k in ACL_KEYS }}}
@@ -61,16 +61,16 @@ def test_allow_ids(self):
6161 # Check that filtering by allowed name pattern works
6262 def test_allow_pattern (self ):
6363 test_resource = {"metadata" : {"annotations" : {ACL_ALLOW_PATTERN_KEY : "prod-" }}}
64- self .assert_allowed (test_resource , Tenancy (id = "" , name = f "prod-123" ))
65- self .assert_allowed (test_resource , Tenancy (id = "" , name = f "test-prod-2" ))
66- self .assert_denied (test_resource , Tenancy (id = "" , name = f "staging" ))
64+ self .assert_allowed (test_resource , Tenancy (id = "" , name = "prod-123" ))
65+ self .assert_allowed (test_resource , Tenancy (id = "" , name = "test-prod-2" ))
66+ self .assert_denied (test_resource , Tenancy (id = "" , name = "staging" ))
6767
6868 # Check that filtering by denied name patterm works
6969 def test_deny_pattern (self ):
7070 test_resource = {"metadata" : {"annotations" : {ACL_DENY_PATTERN_KEY : "prod-" }}}
7171 self .assert_denied (test_resource , Tenancy (id = "" , name = "prod-123" ))
72- self .assert_denied (test_resource , Tenancy (id = "" , name = f "test-prod-2" ))
73- self .assert_allowed (test_resource , Tenancy (id = "" , name = f "staging-123" ))
72+ self .assert_denied (test_resource , Tenancy (id = "" , name = "test-prod-2" ))
73+ self .assert_allowed (test_resource , Tenancy (id = "" , name = "staging-123" ))
7474
7575 # Check that presence of any 'allow' key triggers deny by default
7676 def test_default_deny_with_allows (self ):
0 commit comments