Beispiel #1
0
 def test_rules_when_values_in_desired_are_none(self):
     current = {
         'rules': [{
             'resource_names': ['check-cpu']
         }]
     }
     desired = {
         'rules': [{
             'resource_names': None
         }]
     }
     assert role_utils.do_roles_differ(current, desired) is True
 def test_key_missing_in_desired(self):
     current = {
         'rules': [{
             'verbs': ['update', 'create'],
             'resources': ['hooks', 'assets'],
             'resource_names': ['check-cpu']
         }]
     }
     desired = {
         'rules': [{
             'verbs': ['create', 'update'],
             'resources': ['hooks', 'assets']
         }]
     }
     assert role_utils.do_roles_differ(current, desired) is True
 def test_role_exists_but_with_additional_rules(self):
     current = {
         'rules': [{
             'verbs': ['get', 'list'],
             'resources': ['entities', 'check']
         }, {
             'verbs': ['create', 'update', 'delete'],
             'resources': ['assets', 'hooks']
         }]
     }
     desired = {
         'rules': [{
             'verbs': ['list', 'get'],
             'resources': ['check', 'entities']
         }]
     }
     assert role_utils.do_roles_differ(current, desired) is True
 def test_different_rules_order(self):
     current = {
         'rules': [{
             'verbs': ['get', 'list'],
             'resources': ['entities', 'checks']
         }, {
             'verbs': ['create', 'delete', 'update'],
             'resources': ['assets', 'hooks']
         }]
     }
     desired = {
         'rules': [{
             'verbs': ['delete', 'create', 'update'],
             'resources': ['hooks', 'assets']
         }, {
             'verbs': ['list', 'get'],
             'resources': ['checks', 'entities']
         }]
     }
     assert role_utils.do_roles_differ(current, desired) is False