Exemplo n.º 1
0
 def test_unix_domain_sockets(self):
     mySourceFileStatRemote = lib_client.SourceRemote(
         RemoteWsgiTestAgent + "/survol/sources_types/Linux/unix_domain_sockets.py")
     tripleFileStatRemote = mySourceFileStatRemote.get_triplestore()
     print("Len tripleFileStatRemote=",len(tripleFileStatRemote))
     # This should not be empty.
     self.assertTrue(len(tripleFileStatRemote)>=1)
Exemplo n.º 2
0
    def test_wsgi_file_stat_rdf(self):
        # http://rchateau-hp:8000/survol/sources_types/CIM_DataFile/file_stat.py?xid=CIM_DataFile.Name%3DC%3A%2FWindows%2Fexplorer.exe
        mySourceFileStatRemote = lib_client.SourceRemote(
            RemoteWsgiTestAgent + "/survol/sources_types/CIM_DataFile/file_stat.py",
            "CIM_DataFile",
            Name=always_present_file)

        cleanFileAlwaysThere = lib_util.standardized_file_path(always_present_file)
        dirFileAlwaysThere = lib_util.standardized_file_path(always_present_dir)

        print("urlFileStatRemote=",mySourceFileStatRemote.Url())
        print("qryFileStatRemote=",mySourceFileStatRemote.create_url_query())
        data_triplestore = mySourceFileStatRemote.get_triplestore()

        # CIM_Directory.Name=C:/Windows
        # CIM_DataFile.Name=C:/Windows/explorer.exe
        # Win32_Group.Name=TrustedInstaller,Domain=NT SERVICE
        # CIM_Directory.Name=C:/
        list_instances = data_triplestore.get_instances()

        found_file = False
        found_dir = False
        for one_instance in list_instances:
            print("test_wsgi_file_stat_rdf one_instance=", one_instance)
            if not found_dir:
                found_dir = str(one_instance) == "CIM_Directory.Name=" + dirFileAlwaysThere
            if not found_file:
                found_file = str(one_instance) == "CIM_DataFile.Name=" + cleanFileAlwaysThere

        self.assertTrue(found_dir, "Cannot find directory:" + dirFileAlwaysThere)
        self.assertTrue(found_file, "Cannot find file:" + always_present_file)
Exemplo n.º 3
0
 def test_installed_rpm_packages(self):
     mySourceFileStatRemote = lib_client.SourceRemote(
         RemoteWsgiTestAgent + "/survol/sources_types/Linux/installed_rpm_packages.py")
     tripleFileStatRemote = mySourceFileStatRemote.get_triplestore()
     print("Len tripleFileStatRemote=",len(tripleFileStatRemote))
     # This should not be empty.
     self.assertTrue(len(tripleFileStatRemote)>=1)
Exemplo n.º 4
0
 def test_unix_domain_sockets(self):
     my_source_file_stat_remote = lib_client.SourceRemote(
         _remote_wsgi_test_agent +
         "/survol/sources_types/Linux/unix_domain_sockets.py")
     triple_file_stat_remote = my_source_file_stat_remote.get_triplestore()
     print("Len triple_file_stat_remote=", len(triple_file_stat_remote))
     # This should not be empty.
     self.assertTrue(len(triple_file_stat_remote) >= 1)
Exemplo n.º 5
0
 def test_wsgi_file_directory(self):
     mySourceFileStatRemote = lib_client.SourceRemote(
         RemoteWsgiTestAgent + "/survol/sources_types/CIM_Directory/file_directory.py",
         "CIM_Directory",
         Name=always_present_dir)
     tripleFileStatRemote = mySourceFileStatRemote.get_triplestore()
     print("Len tripleFileStatRemote=",len(tripleFileStatRemote))
     # This should not be empty.
     self.assertTrue(len(tripleFileStatRemote)>=1)
Exemplo n.º 6
0
 def test_twisted_wsgi_file_directory(self):
     my_source_file_stat_remote = lib_client.SourceRemote(
         self.m_remote_wsgi_test_agent + "/survol/sources_types/CIM_Directory/file_directory.py",
         "CIM_Directory",
         Name=always_present_dir)
     triple_file_stat_remote = my_source_file_stat_remote.get_triplestore()
     print("Len triple_file_stat_remote=", len(triple_file_stat_remote))
     # This should not be empty.
     self.assertTrue(len(triple_file_stat_remote) >= 1)
Exemplo n.º 7
0
    def test_wsgi_file_stat_json(self):
        # http://the_host:8000/survol/sources_types/CIM_DataFile/file_stat.py?xid=CIM_DataFile.Name%3DC%3A%2FWindows%2Fexplorer.exe
        my_source_file_stat_remote = lib_client.SourceRemote(
            _remote_wsgi_test_agent +
            "/survol/sources_types/CIM_DataFile/file_stat.py",
            "CIM_DataFile",
            Name=always_present_file)
        print("URL=", my_source_file_stat_remote.source_url())
        print("Query=", my_source_file_stat_remote.create_url_query())
        json_content = my_source_file_stat_remote.content_json()

        dir_file_always_there = os.path.basename(always_present_dir)
        base_file_always_there = os.path.basename(always_present_file)

        # "No doc explorer.exe"
        # "File stat information..."
        json_title = json_content['page_title']
        print("json_title=", json_title)

        self.assertTrue(json_title.startswith("File stat information"),
                        "Incorrect title:" + json_title)

        found_file = False
        found_dir = False
        json_nodes = json_content['nodes']
        for one_node in json_nodes:
            print("test_wsgi_file_stat_json one_node=", one_node)
            node_entity_class = one_node['entity_class']
            node_name = one_node['name']
            if not found_file:
                # {u'entity_class': u'CIM_DataFile', u'name': u'explorer.exe' }
                found_file = node_entity_class == 'CIM_DataFile' and node_name == base_file_always_there
            if not found_dir:
                # {u'entity_class': u'CIM_Directory', u'name': u'Windows/'}
                found_dir = node_entity_class == 'CIM_Directory' and node_name == dir_file_always_there + "/"

        self.assertTrue(found_file,
                        "Could not find file:" + always_present_file)
        self.assertTrue(found_dir,
                        "Could not find directory:" + dir_file_always_there)

        # json_links= [
        # {
        # u'survol_link_prop': u'directory',
        # u'source': u'http://rchateau-hp:9000/survol/entity.py?xid=CIM_Directory.Name=C%3A%2FWindows',
        # u'target': u'http://rchateau-hp:9000/survol/entity.py?xid=CIM_DataFile.Name=C%3A%2FWindows%2Fexplorer.exe'},
        json_links = json_content['links']
        link_found = False
        for one_link in json_links:
            if one_link['survol_link_prop'] == 'directory' \
                    and one_link['source'].endswith(dir_file_always_there) \
                    and one_link['target'].endswith(base_file_always_there):
                link_found = True
                break
        self.assertTrue(link_found,
                        "Could not find edge between file and directory")