def test_remove_acl(self): name = 'test' acl = [{'name': 'acl'}] self.gateway_instance_mock.shares.remove_acl = MagicMock() SharesManager().remove_acl(name, acl) self.gateway_instance_mock.shares.remove_acl.assert_called_once_with( name, acl)
def test_add_screened_file_types(self): name = 'test' screened_file_types = ['exe'] self.gateway_instance_mock.shares.add_screened_file_types = MagicMock() SharesManager().add_screened_file_types(name, screened_file_types) self.gateway_instance_mock.shares.add_screened_file_types.assert_called_once_with( name, screened_file_types)
def test_modify_share(self): name = 'test' directory = '/test/dir' self.gateway_instance_mock.shares.modify = MagicMock() SharesManager().modify_share(name, directory=directory) self.gateway_instance_mock.shares.modify.assert_called_once_with( name=name, directory=directory)
def test_remove_trusted_nfs_clients(self): name = 'test' trusted_nfs_clients = [{'name': 'trusted_nfs_client'}] self.gateway_instance_mock.shares.remove_trusted_nfs_clients = MagicMock( ) SharesManager().remove_trusted_nfs_clients(name, trusted_nfs_clients) self.gateway_instance_mock.shares.remove_trusted_nfs_clients.assert_called_once_with( name, trusted_nfs_clients)
def remove_trusted_nfs_client(name=None, address=None, netmask=None, session_id=None, **_kwargs): SharesManager(session_id=session_id).remove_trusted_nfs_clients( name, [converters.create_remove_trusted_nfs_client_entry(address, netmask)]) return NoContent, 200
def remove_acl(name=None, principal_type=None, principal_name=None, session_id=None, **_kwargs): SharesManager(session_id=session_id).remove_acl(name, [ converters.create_remove_share_access_control_entry( principal_type, principal_name) ]) return NoContent, 200
def put(body=None, session_id=None, **_kwargs): SharesManager(session_id=session_id).modify_share( body['name'], directory=body.get('directory'), acl=_get_acl_from_body(body), access=body.get('access'), csc=body.get('client_side_caching'), dir_permissions=body.get('dir_permissions'), comment=body.get('comment'), export_to_afp=body.get('export_to_afp'), export_to_ftp=body.get('export_to_ftp'), export_to_nfs=body.get('export_to_nfs'), export_to_pc_agent=body.get('export_to_pc_agent'), export_to_rsync=body.get('export_to_rsync'), indexed=body.get('indexed'), trusted_nfs_clients=_get_trusted_nfs_clients_from_body(body)) return NoContent, 200
def post(body=None, session_id=None, **_kwargs): body = body or {} directory = body.get('directory') if directory is None: raise werkzeug_exceptions.BadRequest( description="Share creation request must include a directory") SharesManager(session_id=session_id).add_share( body['name'], directory, acl=_get_acl_from_body(body), access=body.get('access'), csc=body.get('client_side_caching'), dir_permissions=body.get('dir_permissions'), comment=body.get('comment'), export_to_afp=body.get('export_to_afp'), export_to_ftp=body.get('export_to_ftp'), export_to_nfs=body.get('export_to_nfs'), export_to_pc_agent=body.get('export_to_pc_agent'), export_to_rsync=body.get('export_to_rsync'), indexed=body.get('indexed'), trusted_nfs_clients=_get_trusted_nfs_clients_from_body(body)) return NoContent, 200
def search(session_id=None, **_kwargs): return [ _to_external_json(share_object) for share_object in SharesManager(session_id=session_id).get() ]
def add_screened_file_types(name=None, body=None, session_id=None, **_kwargs): SharesManager(session_id=session_id).add_screened_file_types(name, body) return NoContent, 200
def get_screened_file_types(name=None, session_id=None, **_kwargs): return SharesManager(session_id=session_id).get_screened_file_types(name)
def get_acl(name=None, session_id=None, **_kwargs): return [ converters.to_external_acl(acl_rule) for acl_rule in SharesManager(session_id=session_id).get_acl(name) ]
def test_get_trusted_nfs_clients(self): name = 'test' self.gateway_instance_mock.shares.get_trusted_nfs_clients = MagicMock() SharesManager().get_trusted_nfs_clients(name) self.gateway_instance_mock.shares.get_trusted_nfs_clients.assert_called_once_with( name)
def test_get_acl(self): name = 'test' self.gateway_instance_mock.shares.get_acl = MagicMock() SharesManager().get_acl(name) self.gateway_instance_mock.shares.get_acl.assert_called_once_with(name)
def test_delete(self): name = 'test' self.gateway_instance_mock.shares.delete = MagicMock() SharesManager().delete(name) self.gateway_instance_mock.shares.delete.assert_called_once_with(name)
def get(name=None, session_id=None, **_kwargs): return _to_external_json(SharesManager(session_id=session_id).get(name))
def delete(name=None, session_id=None, **_kwargs): SharesManager(session_id=session_id).delete(name) return NoContent, 200
def get_trusted_nfs_clients(name=None, session_id=None, **_kwargs): return [ converters.to_external_trusted_nfs_client(entry) for entry in SharesManager( session_id=session_id).get_trusted_nfs_clients(name) ]
def add_acl(name=None, body=None, session_id=None, **_kwargs): SharesManager(session_id=session_id).add_acl( name, [converters.acl_json_to_object(acl_rule) for acl_rule in body]) return NoContent, 200
def test_get_screened_file_types(self): name = 'test' self.gateway_instance_mock.shares.get_screened_file_types = MagicMock() SharesManager().get_screened_file_types(name) self.gateway_instance_mock.shares.get_screened_file_types.assert_called_once_with( name)