def teatime_scan(ip): s = Scanner( ip=ip, port=DEFAULT_PORT, node_type=NodeType.IPFS, plugins=[CommandCheck()], ) return s.run()
def test_intrusive_logging(logger_mock, node_type: NodeType): plugin_mock = MagicMock() plugin_mock.INTRUSIVE = True scanner = Scanner(ip="127.0.0.1", port=8545, node_type=node_type, plugins=[plugin_mock]) scanner.run() logger_mock.warning.assert_called_once()
def test_repr(): target = "127.0.0.1" plugins = [None, None, None] node_type = NodeType.GETH scanner = Scanner(target, port=8545, node_type=node_type, plugins=plugins) scanner_repr = str(scanner) assert target in scanner_repr assert str(len(plugins)) in scanner_repr assert str(node_type) in scanner_repr
def test_scanner_report(node_type: NodeType): mock_plugins = [MagicMock() for _ in range(5)] scanner = Scanner(ip="127.0.0.1", port=8545, node_type=node_type, plugins=mock_plugins) report = scanner.run() assert scanner.plugins == mock_plugins assert scanner.node_type == node_type assert scanner.target == "http://127.0.0.1:8545" assert report.target == scanner.target assert isinstance(report.meta.get("elapsed"), float) assert isinstance(report.id, str) assert isinstance(report.timestamp, str) assert report.issues == [] for plugin in mock_plugins: plugin.run.assert_called_once()
import json from teatime import Context, NodeType, Scanner from teatime.plugins.ipfs import UnixFSEnum s = Scanner( ip="127.0.0.1", port=5001, node_type=NodeType.IPFS, plugins=[UnixFSEnum()], ) report = s.run() print(json.dumps(report.to_dict(), indent=2, sort_keys=True))