當前位置: 首頁>>代碼示例>>Python>>正文


Python WorkspaceManager.removeWorkspace方法代碼示例

本文整理匯總了Python中managers.model_managers.WorkspaceManager.removeWorkspace方法的典型用法代碼示例。如果您正苦於以下問題:Python WorkspaceManager.removeWorkspace方法的具體用法?Python WorkspaceManager.removeWorkspace怎麽用?Python WorkspaceManager.removeWorkspace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在managers.model_managers.WorkspaceManager的用法示例。


在下文中一共展示了WorkspaceManager.removeWorkspace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: PluginsToModelControllerIntegration

# 需要導入模塊: from managers.model_managers import WorkspaceManager [as 別名]
# 或者: from managers.model_managers.WorkspaceManager import removeWorkspace [as 別名]
class PluginsToModelControllerIntegration(unittest.TestCase):

    def setUp(self):
        """
        Generic test to verify that the object exists and can be
        instantiated without problems.
        """
        self.dbManager = mock()
        self.changesController = mock()
        self.reportManager = mock()

        self.dbManager = DbManager()
        self.mappersManager = MapperManager()

        self.model_controller = controller.ModelController(mock(), self.mappersManager)
        self.workspace_manager = WorkspaceManager(self.dbManager,
                                             self.mappersManager,
                                             self.changesController,
                                             self.reportManager)
        self.workspace_manager.createWorkspace('temp_workspace', 'desc', DBTYPE.FS)
        self.workspace_manager.openWorkspace('temp_workspace')

        self._plugin_controller = PluginControllerForApi("test", {"nmap": nmap_plugin.NmapPlugin(),
                                                                    "nessus": nessus_plugin.NessusPlugin()}, mock())

        api.setUpAPIs(self.model_controller, self.workspace_manager)

    def tearDown(self): 
        self.workspace_manager.removeWorkspace('temp_workspace')

    def test_nmap_scan_saves_host(self):
        output_file = open(os.path.join(os.getcwd(), 'test_cases/data/nmap_plugin_with_api.xml'))
        output = output_file.read()
        self._plugin_controller.processCommandInput("nmap localhost")
        self._plugin_controller.onCommandFinished("nmap localhost", output)
        self.model_controller.processAllPendingActions()
        self.assertEquals(len(self.model_controller.getAllHosts()), 1,
                "Not all hosts added to model")

        host = self.model_controller.getAllHosts()[0]
        self.assertEquals(len(host.getAllInterfaces()), 1,
            "Not all interfaces added to model")

        interface = host.getAllInterfaces()[0]
        self.assertEquals(len(interface.getAllServices()), 3,
            "Not all services added to model")

        services = interface.getAllServices()
        self.assertTrue(all( [ s.getStatus() == 'open' for s in services]),
                "Port status not saved correctly")


    def test_nessus_scan_saves_host(self):
        output_file = open(os.path.join(os.getcwd(), 'test_cases/data/nessus_plugin_with_api.nessus'))
        output = output_file.read() 
        self._plugin_controller.processCommandInput("./nessus report")
        self._plugin_controller.onCommandFinished("./nessus report", output)
        self.model_controller.processAllPendingActions()
        self.assertEquals(len(self.model_controller.getAllHosts()), 7,
                "Not all hosts added to model")
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:62,代碼來源:plugins_controller_integration.py

示例2: testRemoveWorkspace

# 需要導入模塊: from managers.model_managers import WorkspaceManager [as 別名]
# 或者: from managers.model_managers.WorkspaceManager import removeWorkspace [as 別名]
    def testRemoveWorkspace(self):
        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()

        workspace = Workspace('test_workspace', 'a desc')
        when(dbManager).removeDb('test_workspace').thenReturn(True)
        when(dbManager).getAllDbNames().thenReturn(['test_workspace'])

        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())
        remove_ret = workspace_manager.removeWorkspace('test_workspace')

        verify(dbManager).removeDb('test_workspace')
        self.assertTrue(remove_ret, 'bbdd not removed')
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:18,代碼來源:workspace_manager.py

示例3: TestWorkspacesManagement

# 需要導入模塊: from managers.model_managers import WorkspaceManager [as 別名]
# 或者: from managers.model_managers.WorkspaceManager import removeWorkspace [as 別名]
class TestWorkspacesManagement(unittest.TestCase):

    def setUp(self):
        self.couch_uri = CONF.getCouchURI()
        # self.cdm = CouchdbManager(uri=self.couch_uri)
        wpath = os.path.expanduser("~/.faraday/persistence/" )
        # self.fsm = FSManager(wpath)
        
        self.dbManager = DbManager()
        self.mappersManager = MapperManager()
        self.changesController = ChangeController(self.mappersManager)

        self.wm = WorkspaceManager(self.dbManager, self.mappersManager,
                                    self.changesController)
        self._fs_workspaces = []
        self._couchdb_workspaces = []

    def tearDown(self):
        self.cleanCouchDatabases()
        self.cleanFSWorkspaces()
        # pass

    def new_random_workspace_name(self):
        return ("aworkspace" + "".join(random.sample(
            [chr(i) for i in range(65, 90)], 10))).lower()

    def cleanFSWorkspaces(self):
        import shutil
        basepath = os.path.expanduser("~/.faraday/persistence/")

        for d in self._fs_workspaces:
            wpath = os.path.join(basepath, d)
            if os.path.isdir(wpath):
                shutil.rmtree(wpath)

    def cleanCouchDatabases(self):
        try:
            for wname in self._couchdb_workspaces:
                self.cdm.removeWorkspace(wname)
        except Exception as e:
            print e

    def test_create_fs_workspace(self):
        """
        Verifies the creation of a filesystem workspace
        """
        wname = self.new_random_workspace_name()
        self._fs_workspaces.append(wname)
        self.wm.createWorkspace(wname, 'desc', DBTYPE.FS)

        wpath = os.path.expanduser("~/.faraday/persistence/%s" % wname)
        self.assertTrue(os.path.exists(wpath))

    def test_create_couch_workspace(self):
        """
        Verifies the creation of a couch workspace
        """
        wname = self.new_random_workspace_name()
        self._couchdb_workspaces.append(wname)
        self.wm.createWorkspace(wname, 'a desc', DBTYPE.COUCHDB)

        res_connector = self.dbManager.getConnector(wname)
        self.assertTrue(res_connector)
        self.assertEquals(res_connector.getType(), DBTYPE.COUCHDB)
        self.assertTrue(self.mappersManager.find(wname), "Workspace document not found")

        wpath = os.path.expanduser("~/.faraday/persistence/%s" % wname)
        self.assertFalse(os.path.exists(wpath))

        # self.assertEquals(WorkspaceOnCouch.__name__, self.wm.getWorkspaceType(wname))

    def test_delete_couch_workspace(self):
        """
        Verifies the deletion of a couch workspace
        """
        wname = self.new_random_workspace_name()
        self.wm.createWorkspace(wname, 'a desc', DBTYPE.COUCHDB)

        self.assertTrue(self.mappersManager.find(wname), "Workspace document not found")

        #Delete workspace
        self.wm.removeWorkspace(wname)
        self.assertIsNone(self.mappersManager.find(wname))
        self.assertFalse(self.dbManager.connectorExists(wname))

    def test_delete_fs_workspace(self):
        """
        Verifies the deletion of a filesystem workspace
        """
        wname = self.new_random_workspace_name()
        self.wm.createWorkspace(wname, 'desc', DBTYPE.FS)

        wpath = os.path.expanduser("~/.faraday/persistence/%s" % wname)
        self.assertTrue(os.path.exists(wpath))

        #Delete workspace
        self.wm.removeWorkspace(wname)
        self.assertFalse(os.path.exists(wpath))

    def test_list_workspaces(self):
#.........這裏部分代碼省略.........
開發者ID:BwRy,項目名稱:faraday,代碼行數:103,代碼來源:workspace.py


注:本文中的managers.model_managers.WorkspaceManager.removeWorkspace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。