Skip to content

Commit

Permalink
fix: Schema path validation for WSGI apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Feb 9, 2020
1 parent ac8dcec commit cea9fe6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/schemathesis/cli/callbacks.py
Expand Up @@ -12,13 +12,14 @@


def validate_schema(ctx: click.core.Context, param: click.core.Parameter, raw_value: str) -> str:
if "app" not in ctx.params and not urlparse(raw_value).netloc:
if "\x00" in raw_value or not utils.file_exists(raw_value):
raise click.UsageError("Invalid SCHEMA, must be a valid URL or file path.")
if "base_url" not in ctx.params:
raise click.UsageError('Missing argument, "--base-url" is required for SCHEMA specified by file.')
else:
_validate_url(raw_value)
if "app" not in ctx.params:
if not urlparse(raw_value).netloc:
if "\x00" in raw_value or not utils.file_exists(raw_value):
raise click.UsageError("Invalid SCHEMA, must be a valid URL or file path.")
if "base_url" not in ctx.params:
raise click.UsageError('Missing argument, "--base-url" is required for SCHEMA specified by file.')
else:
_validate_url(raw_value)
return raw_value


Expand Down

0 comments on commit cea9fe6

Please sign in to comment.