diff --git a/src/schemathesis/runner/__init__.py b/src/schemathesis/runner/__init__.py index 852e2fd42f..e536ebaeff 100644 --- a/src/schemathesis/runner/__init__.py +++ b/src/schemathesis/runner/__init__.py @@ -446,6 +446,8 @@ def prepare( # pylint: disable=too-many-arguments if "base_url" not in loader_options: loader_options["base_url"] = get_base_url(schema_uri) + if loader is from_uri and loader_options.get("auth"): + loader_options["auth"] = get_requests_auth(loader_options["auth"], loader_options.pop("auth_type", None)) schema = loader(schema_uri, **loader_options) return execute_from_schema( schema, diff --git a/test/cli/test_commands.py b/test/cli/test_commands.py index 87bd780834..87cfa88dac 100644 --- a/test/cli/test_commands.py +++ b/test/cli/test_commands.py @@ -165,7 +165,10 @@ def test_commands_run_help(cli): ( ([SCHEMA_URI], {"checks": DEFAULT_CHECKS, "loader": from_uri, "workers_num": 1}), ([SCHEMA_URI, "--checks=all"], {"checks": ALL_CHECKS, "loader": from_uri, "workers_num": 1}), - ([SCHEMA_URI, "--exitfirst"], {"checks": DEFAULT_CHECKS, "exit_first": True, "loader": from_uri, "workers_num": 1}), + ( + [SCHEMA_URI, "--exitfirst"], + {"checks": DEFAULT_CHECKS, "exit_first": True, "loader": from_uri, "workers_num": 1}, + ), ( [SIMPLE_PATH, "--base-url=http://127.0.0.1"], { @@ -227,13 +230,26 @@ def test_commands_run_help(cli): ), ( [SCHEMA_URI, "--method=POST", "--method", "GET"], - {"checks": DEFAULT_CHECKS, "loader": from_uri, "loader_options": {"method": ("POST", "GET")}, "workers_num": 1}, + { + "checks": DEFAULT_CHECKS, + "loader": from_uri, + "loader_options": {"method": ("POST", "GET")}, + "workers_num": 1, + }, ), ( [SCHEMA_URI, "--endpoint=users"], - {"checks": DEFAULT_CHECKS, "loader": from_uri, "loader_options": {"endpoint": ("users",)}, "workers_num": 1}, + { + "checks": DEFAULT_CHECKS, + "loader": from_uri, + "loader_options": {"endpoint": ("users",)}, + "workers_num": 1, + }, + ), + ( + [SCHEMA_URI, "--tag=foo"], + {"checks": DEFAULT_CHECKS, "loader": from_uri, "loader_options": {"tag": ("foo",)}, "workers_num": 1}, ), - ([SCHEMA_URI, "--tag=foo"], {"checks": DEFAULT_CHECKS, "loader": from_uri, "loader_options": {"tag": ("foo",)}, "workers_num": 1}), ( [SCHEMA_URI, "--base-url=https://example.com/api/v1test"], { @@ -243,7 +259,10 @@ def test_commands_run_help(cli): "workers_num": 1, }, ), - ([SCHEMA_URI, "--hypothesis-seed=123"], {"checks": DEFAULT_CHECKS, "loader": from_uri, "seed": 123, "workers_num": 1}), + ( + [SCHEMA_URI, "--hypothesis-seed=123"], + {"checks": DEFAULT_CHECKS, "loader": from_uri, "seed": 123, "workers_num": 1}, + ), ( [ SCHEMA_URI,