Skip to content

Commit

Permalink
fix: Validation of --request-timeout` parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Feb 9, 2020
1 parent cea9fe6 commit 919faf6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Expand Up @@ -13,6 +13,7 @@ Fixed
- Crash on non latin-1 encodable value in ``auth`` CLI option. `#404`_
- Crash on invalid value in ``header`` CLI options. `#405`_
- Crash on some invalid URLs in ``schema`` CLI option. `#406`_
- Validation of ``--request-timeout`` parameter. `#407`_

`0.24.1`_ - 2020-02-08
----------------------
Expand Down Expand Up @@ -695,6 +696,7 @@ Fixed
.. _0.3.0: https://github.com/kiwicom/schemathesis/compare/v0.2.0...v0.3.0
.. _0.2.0: https://github.com/kiwicom/schemathesis/compare/v0.1.0...v0.2.0

.. _#407: https://github.com/kiwicom/schemathesis/issues/407
.. _#406: https://github.com/kiwicom/schemathesis/issues/406
.. _#405: https://github.com/kiwicom/schemathesis/issues/405
.. _#404: https://github.com/kiwicom/schemathesis/issues/404
Expand Down
6 changes: 5 additions & 1 deletion src/schemathesis/cli/__init__.py
Expand Up @@ -113,7 +113,11 @@ def schemathesis(pre_run: Optional[str] = None) -> None:
callback=callbacks.validate_base_url,
)
@click.option("--app", help="WSGI application to test", type=str, callback=callbacks.validate_app)
@click.option("--request-timeout", help="Timeout in milliseconds for network requests during the test run.", type=int)
@click.option(
"--request-timeout",
help="Timeout in milliseconds for network requests during the test run.",
type=click.IntRange(1),
)
@click.option("--validate-schema", help="Enable or disable validation of input schema.", type=bool, default=True)
@click.option("--show-errors-tracebacks", help="Show full tracebacks for internal errors.", is_flag=True, default=False)
@click.option(
Expand Down
11 changes: 10 additions & 1 deletion test/cli/test_commands.py
Expand Up @@ -59,6 +59,14 @@ def test_commands_version(cli):
(("run", SIMPLE_PATH), 'Error: Missing argument, "--base-url" is required for SCHEMA specified by file.'),
(("run", SIMPLE_PATH, "--base-url=test"), "Error: Invalid base URL"),
(("run", SIMPLE_PATH, "--base-url=127.0.0.1:8080"), "Error: Invalid base URL"),
(
("run", "http://127.0.0.1", "--request-timeout=-5"),
'Error: Invalid value for "--request-timeout": -5 is smaller than the minimum valid value 1.',
),
(
("run", "http://127.0.0.1", "--request-timeout=0"),
'Error: Invalid value for "--request-timeout": 0 is smaller than the minimum valid value 1.',
),
(
("run", "http://127.0.0.1", "--method=+"),
'Error: Invalid value for "--method" / "-M": Invalid regex: nothing to repeat at position 0',
Expand Down Expand Up @@ -157,7 +165,8 @@ def test_commands_run_help(cli):
" -b, --base-url TEXT Base URL address of the API, required for",
" SCHEMA if specified by file.",
" --app TEXT WSGI application to test",
" --request-timeout INTEGER Timeout in milliseconds for network requests",
" --request-timeout INTEGER RANGE",
" Timeout in milliseconds for network requests",
" during the test run.",
" --validate-schema BOOLEAN Enable or disable validation of input schema.",
" --show-errors-tracebacks Show full tracebacks for internal errors.",
Expand Down

0 comments on commit 919faf6

Please sign in to comment.