Example #1
0
  def testListingRegistryDirectoryDoesNotYieldMtimes(self):
    with vfs_test_lib.RegistryVFSStubber():

      client_id = self.SetupClient(0)
      pb = rdf_paths.PathSpec(
          path="/HKEY_LOCAL_MACHINE/SOFTWARE/ListingTest",
          pathtype=rdf_paths.PathSpec.PathType.REGISTRY)

      output_path = client_id.Add("registry").Add(pb.first.path)
      aff4.FACTORY.Delete(output_path, token=self.token)

      client_mock = action_mocks.ListDirectoryClientMock()

      flow_test_lib.TestFlowHelper(
          filesystem.ListDirectory.__name__,
          client_mock,
          client_id=client_id,
          pathspec=pb,
          token=self.token)

      results = list(
          aff4.FACTORY.Open(output_path, token=self.token).OpenChildren())
      self.assertEqual(len(results), 2)
      for result in results:
        st = result.Get(result.Schema.STAT)
        self.assertIsNone(st.st_mtime)
Example #2
0
    def testListingRegistryDirectoryDoesNotYieldMtimes(self):
        with vfs_test_lib.RegistryVFSStubber():

            client_id = self.SetupClient(0)
            pb = rdf_paths.PathSpec(
                path="/HKEY_LOCAL_MACHINE/SOFTWARE/ListingTest",
                pathtype=rdf_paths.PathSpec.PathType.REGISTRY)

            client_mock = action_mocks.ListDirectoryClientMock()

            flow_test_lib.TestFlowHelper(compatibility.GetName(
                filesystem.ListDirectory),
                                         client_mock,
                                         client_id=client_id,
                                         pathspec=pb,
                                         token=self.token)

            if data_store.AFF4Enabled():
                output_path = client_id.Add("registry").Add(pb.first.path)
                results = list(
                    aff4.FACTORY.Open(output_path,
                                      token=self.token).OpenChildren())
                self.assertLen(results, 2)
                for result in results:
                    st = result.Get(result.Schema.STAT)
                    self.assertIsNone(st.st_mtime)
            else:
                children = data_store.REL_DB.ListChildPathInfos(
                    self.client_id.Basename(),
                    rdf_objects.PathInfo.PathType.REGISTRY,
                    ["HKEY_LOCAL_MACHINE", "SOFTWARE", "ListingTest"])
                self.assertLen(children, 2)
                for child in children:
                    self.assertIsNone(child.stat_entry.st_mtime)
    def testNotificationWhenListingRegistry(self):
        # Change the username so notifications get written.
        token = self.token.Copy()
        token.username = "******"
        acl_test_lib.CreateUser(token.username)

        with vfs_test_lib.RegistryVFSStubber():
            client_id = self.SetupClient(0)
            pb = rdf_paths.PathSpec(
                path="/HKEY_LOCAL_MACHINE/SOFTWARE/ListingTest",
                pathtype=rdf_paths.PathSpec.PathType.REGISTRY)

            client_mock = action_mocks.ListDirectoryClientMock()

            flow_test_lib.TestFlowHelper(compatibility.GetName(
                filesystem.ListDirectory),
                                         client_mock,
                                         client_id=client_id,
                                         pathspec=pb,
                                         token=token)

        notifications = data_store.REL_DB.ReadUserNotifications(token.username)
        self.assertLen(notifications, 1)
        n = notifications[0]
        self.assertEqual(n.reference.vfs_file.path_type,
                         rdf_objects.PathInfo.PathType.REGISTRY)
        self.assertEqual(n.reference.vfs_file.path_components,
                         ["HKEY_LOCAL_MACHINE", "SOFTWARE", "ListingTest"])
    def testListingRegistryDirectoryDoesNotYieldMtimes(self):
        with vfs_test_lib.RegistryVFSStubber():

            client_id = self.SetupClient(0)
            pb = rdf_paths.PathSpec(
                path="/HKEY_LOCAL_MACHINE/SOFTWARE/ListingTest",
                pathtype=rdf_paths.PathSpec.PathType.REGISTRY)

            client_mock = action_mocks.ListDirectoryClientMock()

            flow_test_lib.TestFlowHelper(compatibility.GetName(
                filesystem.ListDirectory),
                                         client_mock,
                                         client_id=client_id,
                                         pathspec=pb,
                                         token=self.token)

            children = data_store.REL_DB.ListChildPathInfos(
                self.client_id, rdf_objects.PathInfo.PathType.REGISTRY,
                ["HKEY_LOCAL_MACHINE", "SOFTWARE", "ListingTest"])
            self.assertLen(children, 2)
            for child in children:
                self.assertIsNone(child.stat_entry.st_mtime)
Example #5
0
  def testNotificationWhenListingRegistry(self):
    # Change the username so notifications get written.
    token = self.token.Copy()
    token.username = "******"
    acl_test_lib.CreateUser(token.username)

    with vfs_test_lib.RegistryVFSStubber():
      client_id = self.SetupClient(0)
      pb = rdf_paths.PathSpec(
          path="/HKEY_LOCAL_MACHINE/SOFTWARE/ListingTest",
          pathtype=rdf_paths.PathSpec.PathType.REGISTRY)

      client_mock = action_mocks.ListDirectoryClientMock()

      flow_test_lib.TestFlowHelper(
          compatibility.GetName(filesystem.ListDirectory),
          client_mock,
          client_id=client_id,
          pathspec=pb,
          token=token)

    if data_store.RelationalDBEnabled():
      notifications = data_store.REL_DB.ReadUserNotifications(token.username)
      self.assertLen(notifications, 1)
      n = notifications[0]
      self.assertEqual(n.reference.vfs_file.path_type,
                       rdf_objects.PathInfo.PathType.REGISTRY)
      self.assertEqual(n.reference.vfs_file.path_components,
                       ["HKEY_LOCAL_MACHINE", "SOFTWARE", "ListingTest"])
    else:
      user = aff4.FACTORY.Open("aff4:/users/%s" % token.username, token=token)
      notifications = user.Get(user.Schema.PENDING_NOTIFICATIONS)
      self.assertLen(notifications, 1)
      expected_urn = ("aff4:/C.1000000000000000/registry/"
                      "HKEY_LOCAL_MACHINE/SOFTWARE/ListingTest")
      self.assertEqual(notifications[0].subject, expected_urn)
Example #6
0
 def setUp(self):
     super(TestStubbedRegistryFinderFlow, self).setUp()
     registry_stubber = vfs_test_lib.RegistryVFSStubber()
     registry_stubber.Start()
     self.addCleanup(registry_stubber.Stop)
Example #7
0
 def setUp(self):
   super(RegistryVFSTests, self).setUp()
   self.registry_stubber = vfs_test_lib.RegistryVFSStubber()
   self.registry_stubber.Start()
Example #8
0
 def setUp(self):
   super().setUp()
   registry_stubber = vfs_test_lib.RegistryVFSStubber()
   registry_stubber.Start()
   self.addCleanup(registry_stubber.Stop)
Example #9
0
 def setUp(self):
     super(TestRegistryFinderFlow, self).setUp()
     self.registry_stubber = vfs_test_lib.RegistryVFSStubber()
     self.registry_stubber.Start()