def testDiskVolumeInfoWindows(self): self.SetupClients(1, system="Windows") with test_lib.VFSOverrider(rdf_paths.PathSpec.PathType.REGISTRY, test_lib.FakeRegistryVFSHandler): client_mock = action_mocks.WindowsVolumeClientMock( "StatFile", "ListDirectory") with test_lib.Instrument(flow.GRRFlow, "SendReply") as send_reply: for _ in test_lib.TestFlowHelper( "DiskVolumeInfo", client_mock, client_id=self.client_id, token=self.token, path_list=[r"D:\temp\something", r"/var/tmp"]): pass results = [] for cls, reply in send_reply.args: if isinstance(cls, filesystem.DiskVolumeInfo) and isinstance( reply, rdf_client.Volume): results.append(reply) # We asked for D and we guessed systemroot (C) for "/var/tmp", but only # C and Z are present, so we should just get C. self.assertItemsEqual( [x.windowsvolume.drive_letter for x in results], ["C:"]) self.assertEqual(len(results), 1) with test_lib.Instrument(flow.GRRFlow, "SendReply") as send_reply: for _ in test_lib.TestFlowHelper("DiskVolumeInfo", client_mock, client_id=self.client_id, token=self.token, path_list=[r"Z:\blah"]): pass results = [] for cls, reply in send_reply.args: if isinstance(cls, filesystem.DiskVolumeInfo) and isinstance( reply, rdf_client.Volume): results.append(reply) self.assertItemsEqual( [x.windowsvolume.drive_letter for x in results], ["Z:"]) self.assertEqual(len(results), 1)
def testDiskVolumeInfoWindows(self): client = aff4.FACTORY.Open(self.client_id, mode="rw", token=self.token) client.Set(client.Schema.SYSTEM("Windows")) client.Flush() vfs.VFS_HANDLERS[rdfvalue.PathSpec.PathType. REGISTRY] = test_lib.FakeRegistryVFSHandler client_mock = action_mocks.WindowsVolumeClientMock( "StatFile", "ListDirectory") with test_lib.Instrument(flow.GRRFlow, "SendReply") as send_reply: for _ in test_lib.TestFlowHelper( "DiskVolumeInfo", client_mock, client_id=self.client_id, token=self.token, path_list=[r"D:\temp\something", r"/var/tmp"]): pass results = [] for cls, reply in send_reply.args: if isinstance(cls, filesystem.DiskVolumeInfo) and isinstance( reply, rdfvalue.Volume): results.append(reply) # We asked for D and we guessed systemroot (C) for "/var/tmp", but only C # and Z are present, so we should just get C. self.assertItemsEqual([x.windows.drive_letter for x in results], ["C:"]) self.assertEqual(len(results), 1) with test_lib.Instrument(flow.GRRFlow, "SendReply") as send_reply: for _ in test_lib.TestFlowHelper("DiskVolumeInfo", client_mock, client_id=self.client_id, token=self.token, path_list=[r"Z:\blah"]): pass results = [] for cls, reply in send_reply.args: if isinstance(cls, filesystem.DiskVolumeInfo) and isinstance( reply, rdfvalue.Volume): results.append(reply) self.assertItemsEqual([x.windows.drive_letter for x in results], ["Z:"]) self.assertEqual(len(results), 1)