Пример #1
0
def test_options_for_scan_missing_mandatory(monkeypatch, arg):
    command = "./scan example.org --scan=a11y --%s" % arg.replace("_", "-")
    monkeypatch.setattr(sys, "argv", command.split(" "))
    scan_utils.options()
    command = "./scan example.org --scan=a11y --%s=" % arg.replace("_", "-")
    monkeypatch.setattr(sys, "argv", command.split(" "))
    scan_utils.options()
Пример #2
0
def test_options_for_scan_help(monkeypatch, capsys, args):
    monkeypatch.setattr(sys, "argv", args.split(" "))
    # Handling exception here instead of with decorator because we want to
    # examine the console output.
    with pytest.raises(SystemExit) as exc:
        scan_utils.options()
    assert exc.typename == "SystemExit"
    out, err = capsys.readouterr()
    assert out.startswith("usage: scan [-h]")
Пример #3
0
def test_options_for_scan_no_target(monkeypatch, capsys):
    # Handling exception here instead of with decorator because for some reason
    # even our enhanced ArgumentParser generates SystemExit for this error
    # instead of a more specific exception.
    command = "./scan --scan=a11y"
    monkeypatch.setattr(sys, "argv", command.split(" "))
    with pytest.raises(SystemExit) as exc:
        scan_utils.options()
    assert exc.typename == "SystemExit"
    out, err = capsys.readouterr()
    assert err.endswith("arguments are required: domains\n")
Пример #4
0
def test_options_for_scan_basic(monkeypatch):
    command = "./scan example.org --scan=a11y"
    monkeypatch.setattr(sys, "argv", command.split(" "))
    result, _ = scan_utils.options()
    assert result == {
        "_": default_underscore_scan,
        "domains": "example.org",
        "scan": "a11y",
        **scan_default_values,
        "output": "./",
    }
Пример #5
0
def test_options(monkeypatch, args, expected):
    monkeypatch.setattr(sys, "argv", args.split(" "))
    result = scan_utils.options()
    assert result == expected
Пример #6
0
def test_options_for_scan_check_for_single_args(monkeypatch, command, expected):
    monkeypatch.setattr(sys, "argv", command.split(" "))
    result, _ = scan_utils.options()
    if not result == expected:
        pytest.set_trace()
    assert result == expected
Пример #7
0
def test_options_for_scan_lambda_profile_no_lambda(monkeypatch):
    command = "./scan example.org --scan=a11y --lambda-profile=something"
    monkeypatch.setattr(sys, "argv", command.split(" "))
    scan_utils.options()
Пример #8
0
def test_options(monkeypatch, args, expected):
    monkeypatch.setattr(sys, "argv", args.split(" "))
    result = scan_utils.options()
    assert result == expected