def test_remote_move_to_non_sync_root(self): sb, ctl = self.sb_1, self.controller_1 session = ctl.get_session() # Grant ReadWrite permission on Workspaces for test user workspaces_path = u'/default-domain/workspaces' op_input = "doc:" + workspaces_path self.root_remote_client.execute("Document.SetACE", op_input=op_input, user="******", permission="ReadWrite", grant="true") workspaces_info = self.root_remote_client.fetch(workspaces_path) workspaces = workspaces_info[u'uid'] # Get remote client with Workspaces as base folder and local client remote_client = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, base_folder=workspaces, upload_tmp_dir=self.upload_tmp_dir) local_client = self.local_client_1 # Create a non synchronized folder remote_client.make_folder(u'/', u'Non synchronized folder') # Move Original Folder 1 to Non synchronized folder remote_client.move(u'/nuxeo-drive-test-workspace/Original Folder 1', u'/Non synchronized folder') self.assertFalse( remote_client.exists( u'/nuxeo-drive-test-workspace/Original Folder 1')) self.assertTrue( remote_client.exists( u'/Non synchronized folder/Original Folder 1')) # Synchronize: the folder move is detected as a deletion self.wait_audit_change_finder_if_needed() self.wait() self.assertEquals(ctl.synchronizer.update_synchronize_server(sb), 1) # Check local folder self.assertFalse(local_client.exists(u'/Original Folder 1')) # Check folder state folder_1_state = session.query(LastKnownState).filter_by( remote_name=u'Original Folder 1').all() self.assertEquals(len(folder_1_state), 0) # The more things change, the more they remain the same. self.wait_audit_change_finder_if_needed() self.wait() self.assertEquals(ctl.synchronizer.update_synchronize_server(sb), 0)
def test_remote_move_to_non_sync_root(self): # Grant ReadWrite permission on Workspaces for test user workspaces_path = u'/default-domain/workspaces' op_input = "doc:" + workspaces_path self.root_remote_client.execute("Document.SetACE", op_input=op_input, user="******", permission="ReadWrite", grant="true") workspaces_info = self.root_remote_client.fetch(workspaces_path) workspaces = workspaces_info[u'uid'] # Get remote client with Workspaces as base folder and local client remote_client = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, base_folder=workspaces, upload_tmp_dir=self.upload_tmp_dir) local_client = self.local_client_1 # Create a non synchronized folder unsync_folder = remote_client.make_folder(u'/', u'Non synchronized folder') try: # Move Original Folder 1 to Non synchronized folder remote_client.move( u'/nuxeo-drive-test-workspace/Original Folder 1', u'/Non synchronized folder') self.assertFalse( remote_client.exists( u'/nuxeo-drive-test-workspace/Original Folder 1')) self.assertTrue( remote_client.exists( u'/Non synchronized folder/Original Folder 1')) # Synchronize: the folder move is detected as a deletion self.wait_sync(wait_for_async=True) # Check local folder self.assertFalse(local_client.exists(u'/Original Folder 1')) # Check folder state folder_1_state = self._get_state(self.folder_1_id) self.assertEquals(folder_1_state, None) finally: # Clean the non synchronized folder remote_client.delete(unsync_folder, use_trash=False)
def test_remote_move_to_non_sync_root(self): sb, ctl = self.sb_1, self.controller_1 session = ctl.get_session() # Grant ReadWrite permission on Workspaces for test user workspaces_path = u'/default-domain/workspaces' op_input = "doc:" + workspaces_path self.root_remote_client.execute("Document.SetACE", op_input=op_input, user="******", permission="ReadWrite", grant="true") workspaces_info = self.root_remote_client.fetch(workspaces_path) workspaces = workspaces_info[u'uid'] # Get remote client with Workspaces as base folder and local client remote_client = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, base_folder=workspaces, upload_tmp_dir=self.upload_tmp_dir) local_client = self.local_client_1 # Create a non synchronized folder remote_client.make_folder(u'/', u'Non synchronized folder') # Move Original Folder 1 to Non synchronized folder remote_client.move(u'/nuxeo-drive-test-workspace/Original Folder 1', u'/Non synchronized folder') self.assertFalse(remote_client.exists( u'/nuxeo-drive-test-workspace/Original Folder 1')) self.assertTrue(remote_client.exists( u'/Non synchronized folder/Original Folder 1')) # Synchronize: the folder move is detected as a deletion self.wait_audit_change_finder_if_needed() self.wait() self.assertEquals(ctl.synchronizer.update_synchronize_server(sb), 1) # Check local folder self.assertFalse(local_client.exists(u'/Original Folder 1')) # Check folder state folder_1_state = session.query(LastKnownState).filter_by( remote_name=u'Original Folder 1').all() self.assertEquals(len(folder_1_state), 0) # The more things change, the more they remain the same. self.wait_audit_change_finder_if_needed() self.wait() self.assertEquals(ctl.synchronizer.update_synchronize_server(sb), 0)
def test_remote_move_to_non_sync_root(self): # Grant ReadWrite permission on Workspaces for test user workspaces_path = u'/default-domain/workspaces' op_input = "doc:" + workspaces_path self.root_remote_client.execute("Document.SetACE", op_input=op_input, user="******", permission="ReadWrite", grant="true") workspaces_info = self.root_remote_client.fetch(workspaces_path) workspaces = workspaces_info[u'uid'] # Get remote client with Workspaces as base folder and local client remote_client = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, base_folder=workspaces, upload_tmp_dir=self.upload_tmp_dir) local_client = self.local_client_1 # Create a non synchronized folder unsync_folder = remote_client.make_folder(u'/', u'Non synchronized folder') try: # Move Original Folder 1 to Non synchronized folder remote_client.move(u'/nuxeo-drive-test-workspace/Original Folder 1', u'/Non synchronized folder') self.assertFalse(remote_client.exists( u'/nuxeo-drive-test-workspace/Original Folder 1')) self.assertTrue(remote_client.exists( u'/Non synchronized folder/Original Folder 1')) # Synchronize: the folder move is detected as a deletion self.wait_sync(wait_for_async=True) # Check local folder self.assertFalse(local_client.exists(u'/Original Folder 1')) # Check folder state folder_1_state = self._get_state(self.folder_1_id) self.assertEquals(folder_1_state, None) finally: # Clean the non synchronized folder remote_client.delete(unsync_folder, use_trash=False)
def test_move_sync_root_child_to_user_workspace(self): """See https://jira.nuxeo.com/browse/NXP-14870""" admin_remote_client = self.root_remote_client user1_workspace_uid = None try: # Get remote and local clients remote_user1 = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, upload_tmp_dir=self.upload_tmp_dir) remote_user2 = RemoteDocumentClient( self.nuxeo_url, self.user_2, u'nxdrive-test-device-2', self.version, password=self.password_2, upload_tmp_dir=self.upload_tmp_dir) local_user2 = LocalClient(self.local_nxdrive_folder_2) # Make sure personal workspace is created for user1 and fetch its uid user1_workspace_uid = remote_user1.make_file_in_user_workspace('File in user workspace', filename='UWFile.txt')['parentRef'] # As user1 register personal workspace as a sync root remote_user1.register_as_root(user1_workspace_uid) # As user1 create a parent folder in user1's personal workspace parent_folder_uid = remote_user1.make_folder(user1_workspace_uid, 'Parent') # As user1 grant Everything permission to user2 on parent folder op_input = "doc:" + parent_folder_uid admin_remote_client.execute("Document.SetACE", op_input=op_input, user="******", permission="Everything", grant="true") # As user1 create a child folder in parent folder child_folder_uid = remote_user1.make_folder(parent_folder_uid, 'Child') # As user2 register parent folder as a sync root remote_user2.register_as_root(parent_folder_uid) remote_user2.unregister_as_root(self.workspace) # Start engine for user2 self.engine_2.start() # Wait for synchronization self.wait_sync(wait_for_async=True, wait_for_engine_1=False, wait_for_engine_2=True) # Check locally synchronized content self.assertEquals(len(local_user2.get_children_info('/')), 1) self.assertTrue(local_user2.exists('/Parent')) self.assertTrue(local_user2.exists('/Parent/Child')) # As user1 move child folder to user1's personal workspace remote_user1.move(child_folder_uid, user1_workspace_uid) # Wait for synchronization self.wait_sync(wait_for_async=True, wait_for_engine_1=False, wait_for_engine_2=True) # Check locally synchronized content self.assertFalse(local_user2.exists('/Parent/Child')) finally: # Cleanup user1 personal workspace if user1_workspace_uid is not None and admin_remote_client.exists(user1_workspace_uid): admin_remote_client.delete(user1_workspace_uid, use_trash=False)
def test_move_sync_root_child_to_user_workspace(self): """See https://jira.nuxeo.com/browse/NXP-14870""" admin_remote_client = self.root_remote_client user1_workspace_uid = None try: # Get remote and local clients remote_user1 = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, upload_tmp_dir=self.upload_tmp_dir) remote_user2 = RemoteDocumentClient( self.nuxeo_url, self.user_2, u'nxdrive-test-device-2', self.version, password=self.password_2, upload_tmp_dir=self.upload_tmp_dir) local_user2 = LocalClient(self.local_nxdrive_folder_2) # Make sure personal workspace is created for user1 and fetch its uid user1_workspace_uid = remote_user1.make_file_in_user_workspace( 'File in user workspace', filename='UWFile.txt')['parentRef'] # As user1 register personal workspace as a sync root remote_user1.register_as_root(user1_workspace_uid) # As user1 create a parent folder in user1's personal workspace parent_folder_uid = remote_user1.make_folder( user1_workspace_uid, 'Parent') # As user1 grant Everything permission to user2 on parent folder op_input = "doc:" + parent_folder_uid admin_remote_client.execute("Document.SetACE", op_input=op_input, user=self.user_2, permission="Everything", grant="true") # As user1 create a child folder in parent folder child_folder_uid = remote_user1.make_folder( parent_folder_uid, 'Child') # As user2 register parent folder as a sync root remote_user2.register_as_root(parent_folder_uid) remote_user2.unregister_as_root(self.workspace) # Start engine for user2 self.engine_2.start() # Wait for synchronization self.wait_sync(wait_for_async=True, wait_for_engine_1=False, wait_for_engine_2=True) # Check locally synchronized content self.assertEquals(len(local_user2.get_children_info('/')), 1) self.assertTrue(local_user2.exists('/Parent')) self.assertTrue(local_user2.exists('/Parent/Child')) # As user1 move child folder to user1's personal workspace remote_user1.move(child_folder_uid, user1_workspace_uid) # Wait for synchronization self.wait_sync(wait_for_async=True, wait_for_engine_1=False, wait_for_engine_2=True) # Check locally synchronized content self.assertFalse(local_user2.exists('/Parent/Child')) finally: # Cleanup user1 personal workspace if user1_workspace_uid is not None and admin_remote_client.exists( user1_workspace_uid): admin_remote_client.delete(user1_workspace_uid, use_trash=False)
def test_move_sync_root_child_to_user_workspace(self): """See https://jira.nuxeo.com/browse/NXP-14870""" admin_remote_client = self.root_remote_client user1_workspace_path = ('/default-domain/UserWorkspaces/' 'nuxeoDriveTestUser-user-1') try: # Get remote and local clients remote_user1 = RemoteDocumentClient( self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version, password=self.password_1, upload_tmp_dir=self.upload_tmp_dir) remote_user2 = RemoteDocumentClient( self.nuxeo_url, self.user_2, u'nxdrive-test-device-2', self.version, password=self.password_2, upload_tmp_dir=self.upload_tmp_dir) local_user2 = LocalClient(self.local_nxdrive_folder_2) # Make sure personal workspace is created for user1 remote_user1.make_file_in_user_workspace('File in user workspace', filename='UWFile.txt') # As user1 register personal workspace as a sync root remote_user1.register_as_root(user1_workspace_path) # As user1 create a parent folder in user1's personal workspace remote_user1.make_folder(user1_workspace_path, 'Parent') # As user1 grant Everything permission to user2 on parent folder parent_folder_path = user1_workspace_path + '/Parent' op_input = "doc:" + parent_folder_path admin_remote_client.execute("Document.SetACE", op_input=op_input, user="******", permission="Everything", grant="true") # As user1 create a child folder in parent folder remote_user1.make_folder(parent_folder_path, 'Child') # As user2 register parent folder as a sync root remote_user2.register_as_root(parent_folder_path) # Bind server for user2 ctl_2 = self.controller_2 ctl_2.bind_server(self.local_nxdrive_folder_2, self.nuxeo_url, self.user_2, self.password_2) # Launch first synchronization syn_2 = ctl_2.synchronizer self._synchronize(syn_2) # Check locally synchronized content self.assertEquals(len(local_user2.get_children_info('/')), 1) self.assertTrue(local_user2.exists('/Parent')) self.assertTrue(local_user2.exists('/Parent/Child')) # As user1 move child folder to user1's personal workspace remote_user1.move(parent_folder_path + '/Child', user1_workspace_path) # Synchronize self._synchronize(syn_2) # Check locally synchronized content self.assertFalse(local_user2.exists('/Parent/Child')) finally: # Cleanup user1 personal workspace if admin_remote_client.exists(user1_workspace_path): admin_remote_client.delete(user1_workspace_path, use_trash=False)