コード例 #1
0
 def test_empty_methods(self):
     acls = {
         'available': {
             'acls': []
         },
         'validation': {},
     }
     AclConfigValidator.check_acl_validation_methods(
         acls, acls['available']['acls'])
コード例 #2
0
 def test_check_acl_roots(self):
     AclConfigValidator.check_acl_roots({
         'available': {
             'acls': []
         },
         'room': {
             'acls': []
         },
         'channel': {
             'acls': []
         },
         'validation': {},
     })
コード例 #3
0
 def test_anything_but_with_value(self):
     acls = {
         'available': {
             'acls': ['gender']
         },
         'validation': {
             'gender': {
                 'type': 'anything',
                 'value': 'm,f'
             }
         },
     }
     AclConfigValidator.check_acl_validation_methods(
         acls, acls['available']['acls'])
コード例 #4
0
 def test_str_in_csv_method(self):
     acls = {
         'available': {
             'acls': ['gender']
         },
         'validation': {
             'gender': {
                 'type': 'str_in_csv',
                 'value': 'm,f'
             }
         },
     }
     AclConfigValidator.check_acl_validation_methods(
         acls, acls['available']['acls'])
コード例 #5
0
ファイル: environ.py プロジェクト: labrook/dino
def get_acl_config() -> Union[MappingProxyType, dict]:
    acl_paths = None
    if 'DINO_ACL' in os.environ:
        acl_paths = [os.environ['DINO_ACL']]

    acls, _ = find_config_acl(acl_paths)

    if acls is None or len(acls) == 0:
        return MappingProxyType({
            'room': dict(),
            'channel': dict(),
            'available': dict(),
        })

    check_acls = [
        ('channel', acls.get('channel', None)),
        ('room', acls.get('room', None))
    ]
    checked_acls = {
        'available': dict(),
        'room': dict(),
        'channel': dict()
    }

    AclConfigValidator.validate_acl_config(acls, check_acls)

    for acl_target, target_acls in check_acls:
        if target_acls is None or len(target_acls) == 0:
            continue
        for action in target_acls:
            if target_acls[action] is None:
                continue

            keys = set(target_acls[action]['acls'])

            if 'exclude' in target_acls[action]:
                excludes = target_acls[action]['exclude']
                for exclude in excludes:
                    keys.remove(exclude)

            if action not in checked_acls[acl_target]:
                checked_acls[acl_target][action] = list()
            for acl in keys:
                checked_acls[acl_target][action].append(acl)
    return acls
コード例 #6
0
 def test_no_acls_for_action(self):
     acls = {'room': {'join': {'exclude': []}}}
     check_acls = [('channel', acls.get('channel', None)),
                   ('room', acls.get('room', None))]
     AclConfigValidator.check_acl_actions(check_acls, self.actions,
                                          self.available)
コード例 #7
0
 def test_empty_acl(self):
     acls = {'room': {'join': None}}
     check_acls = [('channel', []), ('room', acls.get('room', None))]
     AclConfigValidator.check_acl_actions(check_acls, self.actions,
                                          self.available)
コード例 #8
0
 def test_action_is_none(self):
     acls = {'foo': {'bar': None}}
     AclConfigValidator.check_acl_rules(acls, self.actions, self.rules)
コード例 #9
0
 def test_ignore_unknown_actions(self):
     acls = {'foo': {'bar': {'acls': [], 'exclude': []}}}
     AclConfigValidator.check_acl_rules(acls, self.actions, self.rules)
コード例 #10
0
 def test_rules(self):
     acls = {'room': {'gender': {'acls': [], 'exclude': []}}}
     AclConfigValidator.check_acl_rules(acls, self.actions, self.rules)
コード例 #11
0
 def test_exclude_nothing_and_no_available(self):
     AclConfigValidator.check_acl_excludes([], [])
コード例 #12
0
 def test_exclude_nothing(self):
     AclConfigValidator.check_acl_excludes(['foo', 'bar', 'baz'], [])
コード例 #13
0
 def test_in_types(self):
     keys = {'gender', 'membership'}
     AclConfigValidator.check_acl_keys_in_available(self.available,
                                                    ApiTargets.ROOM, keys)