def test_get_databases(self): testdb = Path(defaults.get("database-dir")) / "testdb6" testdb.touch() assert testdb in list(recon_shell.ReconShell.get_databases()) try: testdb.unlink() except FileNotFoundError: pass
def test_do_database(self, test_input, expected, capsys): if test_input is None: self.shell.do_database("") assert expected in capsys.readouterr().out else: testdb = Path(defaults.get("database-dir")) / "testdb5" testdb.touch() self.shell.do_database(test_input) assert str(testdb) in capsys.readouterr().out try: testdb.unlink() except FileNotFoundError: pass
def test_database_delete_with_index(self, capsys): testdb = Path(defaults.get("database-dir")) / "testdb4" testdb.touch() shell = recon_shell.ReconShell() shell.select = lambda x: str(testdb.expanduser().resolve()) shell.prompt = f"[db-1] {recon_shell.DEFAULT_PROMPT}> " shell.db_mgr = MagicMock() shell.db_mgr.location = "stuff" shell.get_databases = MagicMock(return_value=[str(testdb)]) shell.database_delete("") try: assert not testdb.exists() except AssertionError: try: testdb.unlink() except FileNotFoundError: pass raise AssertionError out = capsys.readouterr().out assert "[+] deleted sqlite database" in out
def test_scan_creates_results_dir(self, test_input): assert Path(defaults.get(test_input)).exists()