def testVfsMethodsAreAccessChecked(self): args = api_vfs.ApiListFilesArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked(self.router.ListFiles, "CheckClientAccess", args=args) args = api_vfs.ApiGetVfsFilesArchiveArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked(self.router.GetVfsFilesArchive, "CheckClientAccess", args=args) args = api_vfs.ApiGetFileDetailsArgs(client_id=self.client_id) self.CheckMethodIsAccessChecked(self.router.GetFileDetails, "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)
def testHandlerStartsFlow(self): test_lib.ClientFixture(self.client_id, token=self.token) args = vfs_plugin.ApiUpdateVfsFileContentArgs( client_id=self.client_id, file_path=self.file_path) result = self.handler.Handle(args, token=self.token) # Check returned operation_id to references a MultiGetFile flow. flow_obj = aff4.FACTORY.Open(result.operation_id, token=self.token) self.assertEqual(flow_obj.Get(flow_obj.Schema.TYPE), "MultiGetFile")
def Run(self): fixture_test_lib.ClientFixture(self.client_id, token=self.token) def ReplaceFlowId(): flows_dir_fd = aff4.FACTORY.Open(self.client_id.Add("flows"), token=self.token) flow_urn = list(flows_dir_fd.ListChildren())[0] return {flow_urn.Basename(): "W:ABCDEF"} with test_lib.FakeTime(42): self.Check("UpdateVfsFileContent", args=vfs_plugin.ApiUpdateVfsFileContentArgs( client_id=self.client_id.Basename(), file_path=self.file_path), replace=ReplaceFlowId)
def testRaisesIfFirstComponentNotInWhitelist(self): args = vfs_plugin.ApiUpdateVfsFileContentArgs( client_id=self.client_id, file_path="/analysis") with self.assertRaises(ValueError): self.handler.Handle(args, token=self.token)
def testRaisesOnRootPath(self): args = vfs_plugin.ApiUpdateVfsFileContentArgs( client_id=self.client_id, file_path="/") with self.assertRaises(ValueError): self.handler.Handle(args, token=self.token)