Skip to content

Commit

Permalink
chore: Fix auth type parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Tkachenko authored and Stranger6667 committed Feb 7, 2020
1 parent 4160583 commit e9b9a12
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/schemathesis/runner/__init__.py
Expand Up @@ -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,
Expand Down
29 changes: 24 additions & 5 deletions test/cli/test_commands.py
Expand Up @@ -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"],
{
Expand Down Expand Up @@ -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"],
{
Expand All @@ -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,
Expand Down

0 comments on commit e9b9a12

Please sign in to comment.