grr/server/grr_response_server/artifact_test.py
def testKnowledgeBaseRetrievalLinuxPasswd(self):
    """Check we can retrieve a Linux kb."""
    with vfs_test_lib.FakeTestDataVFSOverrider():
      with test_lib.ConfigOverrider({
          "Artifacts.knowledge_base": [
              "LinuxWtmp", "LinuxPasswdHomedirs", "LinuxRelease"
          ],
          "Artifacts.knowledge_base_additions": [],
          "Artifacts.knowledge_base_skip": []
      }):
        with test_lib.SuppressLogs():
          kb = self._RunKBI()

    self.assertEqual(kb.os_major_version, 14)
    self.assertEqual(kb.os_minor_version, 4)
    # user 1,2,3 from wtmp.
    self.assertCountEqual([x.username for x in kb.users],
                          ["user1", "user2", "user3"])
    user = kb.GetUser(username="user1")
    self.assertEqual(user.last_logon.AsSecondsSinceEpoch(), 1296552099)
    self.assertEqual(user.homedir, "/home/user1")

    user = kb.GetUser(username="user2")
    self.assertEqual(user.last_logon.AsSecondsSinceEpoch(), 1296552102)
    self.assertEqual(user.homedir, "/home/user2")

    self.assertFalse(kb.GetUser(username="buguser3"))
Check we can retrieve a Linux kb.
Check we can retrieve a Linux kb.
Check we can retrieve a Linux kb .
def testKnowledgeBaseRetrievalLinuxPasswd(self):
    with vfs_test_lib.FakeTestDataVFSOverrider():
      with test_lib.ConfigOverrider({
          "Artifacts.knowledge_base": [
              "LinuxWtmp", "LinuxPasswdHomedirs", "LinuxRelease"
          ],
          "Artifacts.knowledge_base_additions": [],
          "Artifacts.knowledge_base_skip": []
      }):
        with test_lib.SuppressLogs():
          kb = self._RunKBI()
    self.assertEqual(kb.os_major_version, 14)
    self.assertEqual(kb.os_minor_version, 4)
    self.assertCountEqual([x.username for x in kb.users],
                          ["user1", "user2", "user3"])
    user = kb.GetUser(username="user1")
    self.assertEqual(user.last_logon.AsSecondsSinceEpoch(), 1296552099)
    self.assertEqual(user.homedir, "/home/user1")
    user = kb.GetUser(username="user2")
    self.assertEqual(user.last_logon.AsSecondsSinceEpoch(), 1296552102)
    self.assertEqual(user.homedir, "/home/user2")
    self.assertFalse(kb.GetUser(username="buguser3"))
def testKnowledgeBaseRetrievalLinuxPasswd ( self ) : with vfs_test_lib . FakeTestDataVFSOverrider ( ) : with test_lib . ConfigOverrider ( { "Artifacts.knowledge_base" : [ "LinuxWtmp" , "LinuxPasswdHomedirs" , "LinuxRelease" ] , "Artifacts.knowledge_base_additions" : [ ] , "Artifacts.knowledge_base_skip" : [ ] } ) : with test_lib . SuppressLogs ( ) : kb = self . _RunKBI ( ) self . assertEqual ( kb . os_major_version , 14 ) self . assertEqual ( kb . os_minor_version , 4 ) self . assertCountEqual ( [ x . username for x in kb . users ] , [ "user1" , "user2" , "user3" ] ) user = kb . GetUser ( username = "user1" ) self . assertEqual ( user . last_logon . AsSecondsSinceEpoch ( ) , 1296552099 ) self . assertEqual ( user . homedir , "/home/user1" ) user = kb . GetUser ( username = "user2" ) self . assertEqual ( user . last_logon . AsSecondsSinceEpoch ( ) , 1296552102 ) self . assertEqual ( user . homedir , "/home/user2" ) self . assertFalse ( kb . GetUser ( username = "buguser3" ) )
Check we can retrieve a Linux kb.
Check we can retrieve a Linux kb .
"""Check we can retrieve a Linux kb.""" # user 1,2,3 from wtmp.
self