コード例 #1
0
def test_announcer_provider_with_acl(mock_client_provider,
                                     mock_serverset_provider):
    mock_client = create_autospec(spec=KazooClient, instance=True)
    mock_client_provider.return_value = mock_client
    mock_serverset = create_autospec(spec=ServerSet, instance=True)
    mock_serverset_provider.return_value = mock_serverset

    zk_auth = ZkAuth(auth=[Auth(scheme='s', credential='ca')],
                     acl=[
                         Access(scheme='s',
                                credential='cl',
                                permissions=Permissions(create=True))
                     ])

    dap = DefaultAnnouncerCheckerProvider('zookeeper.example.com', '', False,
                                          None, zk_auth)
    job = make_job('aurora', 'prod', 'proxy', 'primary', portmap={})
    assigned_task = make_assigned_task(job, assigned_ports={'primary': 12345})
    dap.from_assigned_task(assigned_task, None)

    mock_client_provider.assert_called_once_with(
        'zookeeper.example.com',
        connection_retry=dap.DEFAULT_RETRY_POLICY,
        auth_data=[('s', 'ca')],
        default_acl=[ACL(KazooPermissions.CREATE, Id('s', 'cl'))])
コード例 #2
0
 def from_dict(cls, acl_dict):
     """ ACL from dict """
     perms = acl_dict.get("perms", Permissions.ALL)
     id_dict = acl_dict.get("id", {})
     id_scheme = id_dict.get("scheme", "world")
     id_id = id_dict.get("id", "anyone")
     return ACL(perms, Id(id_scheme, id_id))
コード例 #3
0
ファイル: serialization.py プロジェクト: zouchao2010/kazoo
def read_acl(bytes, offset):
    perms = int_struct.unpack_from(bytes, offset)[0]
    offset += int_struct.size
    scheme, offset = read_string(bytes, offset)
    id, offset = read_string(bytes, offset)
    return ACL(perms, Id(scheme, id)), offset
コード例 #4
0
ファイル: test_acl_reader.py プロジェクト: sowen/zk_shell
 def test_username_password(self):
     acl = ACLReader.extract_acl('username_password:user:secret:cdrwa')
     expected = ACL(perms=31,
                    id=Id(scheme='digest',
                          id=u'user:5w9W4eL3797Y4Wq8AcKUPPk8ha4='))
     self.assertEqual(expected, acl)
コード例 #5
0
ファイル: test_acl_reader.py プロジェクト: sowen/zk_shell
 def test_extract_acl(self):
     acl = ACLReader.extract_acl('world:anyone:cdrwa')
     expected = ACL(perms=31, id=Id(scheme='world', id='anyone'))
     self.assertEqual(expected, acl)