Skip to content

Commit

Permalink
fix: Overflow crash in --hypothesis-deadline CLI option
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Feb 9, 2020
1 parent 9a385f5 commit 235d00d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/schemathesis/cli/__init__.py
Expand Up @@ -123,7 +123,8 @@ def schemathesis(pre_run: Optional[str] = None) -> None:
@click.option(
"--hypothesis-deadline",
help="Duration in milliseconds that each individual example with a test is not allowed to exceed.",
type=OptionalInt(1),
# max value to avoid overflow. It is maximum amount of days in milliseconds
type=OptionalInt(1, 999999999 * 24 * 3600 * 1000),
)
@click.option("--hypothesis-derandomize", help="Use Hypothesis's deterministic mode.", is_flag=True, default=None)
@click.option(
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test_commands.py
Expand Up @@ -114,7 +114,7 @@ def test_commands_version(cli):
),
(
("run", "http://127.0.0.1", "--hypothesis-deadline=0"),
'Error: Invalid value for "--hypothesis-deadline": 0 is smaller than the minimum valid value 1.',
'Error: Invalid value for "--hypothesis-deadline": 0 is not in the valid range of 1 to 86399999913600000.',
),
(
("run", "http://127.0.0.1", "--header=тест:test"),
Expand Down
1 change: 1 addition & 0 deletions test/cli/test_crashes.py
Expand Up @@ -76,6 +76,7 @@ def paths(draw):
)
@example(params=[], flags=[], multiple_params=["--header=0:0\r"])
@example(params=["--hypothesis-deadline=0"], flags=[], multiple_params=[])
@example(params=["--hypothesis-deadline=86399999999999993"], flags=[], multiple_params=[])
@pytest.mark.usefixtures("mocked_schema")
def test_valid_parameters_combos(cli, schema_url, params, flags, multiple_params):
result = cli.run(schema_url, *params, *multiple_params, *flags)
Expand Down

0 comments on commit 235d00d

Please sign in to comment.