Пример #1
0
    def testHandlerFiltersDirectoriesIfFlagIsSet(self):
        test_lib.ClientFixture(self.client_id, token=self.token)

        # Only fetch sub-directories.
        args = vfs_plugin.ApiGetFileListArgs(client_id=self.client_id,
                                             file_path=self.file_path,
                                             directories_only=True)
        result = self.handler.Handle(args, token=self.token)

        self.assertEqual(len(result.items), 1)
        self.assertEqual(result.items[0].is_directory, True)
        self.assertIn(self.file_path, result.items[0].path)
Пример #2
0
    def testHandlerListsFilesAndDirectories(self):
        test_lib.ClientFixture(self.client_id, token=self.token)

        # Fetch all children of a directory.
        args = vfs_plugin.ApiGetFileListArgs(client_id=self.client_id,
                                             file_path=self.file_path)
        result = self.handler.Handle(args, token=self.token)

        self.assertEqual(len(result.items), 4)
        for item in result.items:
            # Check that all files are really in the right directory.
            self.assertIn(self.file_path, item.path)
    def testVfsMethodsAreAccessChecked(self):
        args = api_vfs.ApiGetFileDetailsArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFileDetails,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiGetFileListArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFileList,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiGetFileTextArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFileText,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiGetFileBlobArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFileBlob,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiGetFileVersionTimesArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFileVersionTimes,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiGetFileDownloadCommandArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetFileDownloadCommand,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiCreateVfsRefreshOperationArgs(
            client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.CreateVfsRefreshOperation,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiGetVfsTimelineArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetVfsTimeline,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiGetVfsTimelineAsCsvArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.GetVfsTimelineAsCsv,
                                        "CheckClientAccess",
                                        args=args)

        args = api_vfs.ApiUpdateVfsFileContentArgs(client_id=self.client_id)
        self.CheckMethodIsAccessChecked(self.router.UpdateVfsFileContent,
                                        "CheckClientAccess",
                                        args=args)
Пример #4
0
 def testRaisesIfFirstComponentIsNotWhitelisted(self):
     args = vfs_plugin.ApiGetFileListArgs(client_id=self.client_id,
                                          file_path="/analysis")
     with self.assertRaises(ValueError):
         self.handler.Handle(args, token=self.token)
Пример #5
0
 def testDoesNotRaiseIfPathIsRoot(self):
     args = vfs_plugin.ApiGetFileListArgs(client_id=self.client_id,
                                          file_path="/")
     self.handler.Handle(args, token=self.token)
Пример #6
0
 def testDoesNotRaiseIfFirstCompomentIsEmpty(self):
     args = vfs_plugin.ApiGetFileListArgs(client_id=self.client_id,
                                          file_path="")
     self.handler.Handle(args, token=self.token)