grr/server/grr_response_server/artifact_test.py
def testKnowledgeBaseRetrievalLinux(self):
    """Check we can retrieve a Linux kb."""
    with test_lib.ConfigOverrider({
        "Artifacts.knowledge_base": [
            "LinuxWtmp", "NetgroupConfiguration", "LinuxPasswdHomedirs",
            "LinuxRelease"
        ],
        "Artifacts.netgroup_filter_regexes": ["^login$"],
        "Artifacts.netgroup_user_blacklist": ["isaac"]
    }):
      with vfs_test_lib.FakeTestDataVFSOverrider():
        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. yagharek from netgroup.
    self.assertCountEqual([x.username for x in kb.users],
                          ["user1", "user2", "user3", "yagharek"])
    user = kb.GetUser(username="user1")
    self.assertEqual(user.last_logon.AsSecondsSinceEpoch(), 1296552099)
    self.assertEqual(user.homedir, "/home/user1")
Check we can retrieve a Linux kb.
Check we can retrieve a Linux kb.
Check we can retrieve a Linux kb .
def testKnowledgeBaseRetrievalLinux(self):
    with test_lib.ConfigOverrider({
        "Artifacts.knowledge_base": [
            "LinuxWtmp", "NetgroupConfiguration", "LinuxPasswdHomedirs",
            "LinuxRelease"
        ],
        "Artifacts.netgroup_filter_regexes": ["^login$"],
        "Artifacts.netgroup_user_blacklist": ["isaac"]
    }):
      with vfs_test_lib.FakeTestDataVFSOverrider():
        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", "yagharek"])
    user = kb.GetUser(username="user1")
    self.assertEqual(user.last_logon.AsSecondsSinceEpoch(), 1296552099)
    self.assertEqual(user.homedir, "/home/user1")
def testKnowledgeBaseRetrievalLinux ( self ) : with test_lib . ConfigOverrider ( { "Artifacts.knowledge_base" : [ "LinuxWtmp" , "NetgroupConfiguration" , "LinuxPasswdHomedirs" , "LinuxRelease" ] , "Artifacts.netgroup_filter_regexes" : [ "^login$" ] , "Artifacts.netgroup_user_blacklist" : [ "isaac" ] } ) : with vfs_test_lib . FakeTestDataVFSOverrider ( ) : 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" , "yagharek" ] ) user = kb . GetUser ( username = "user1" ) self . assertEqual ( user . last_logon . AsSecondsSinceEpoch ( ) , 1296552099 ) self . assertEqual ( user . homedir , "/home/user1" )
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. yagharek from netgroup.
self