Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark --cert option on run as is_eager #4544

Merged
merged 1 commit into from Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -7,6 +7,8 @@ Unreleased

- Fix type annotation for ``json.loads``, it accepts str or bytes.
:issue:`4519`
- The ``--cert`` and ``--key`` options on ``flask run`` can be given
in either order. :issue:`4459`


Version 2.1.1
Expand Down
5 changes: 4 additions & 1 deletion src/flask/cli.py
Expand Up @@ -763,7 +763,10 @@ def convert(self, value, param, ctx):
@click.option("--host", "-h", default="127.0.0.1", help="The interface to bind to.")
@click.option("--port", "-p", default=5000, help="The port to bind to.")
@click.option(
"--cert", type=CertParamType(), help="Specify a certificate file to use HTTPS."
"--cert",
type=CertParamType(),
help="Specify a certificate file to use HTTPS.",
is_eager=True,
)
@click.option(
"--key",
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cli.py
Expand Up @@ -553,9 +553,14 @@ def test_run_cert_path():
with pytest.raises(click.BadParameter):
run_command.make_context("run", ["--key", __file__])

# cert specified first
ctx = run_command.make_context("run", ["--cert", __file__, "--key", __file__])
assert ctx.params["cert"] == (__file__, __file__)

# key specified first
ctx = run_command.make_context("run", ["--key", __file__, "--cert", __file__])
assert ctx.params["cert"] == (__file__, __file__)


def test_run_cert_adhoc(monkeypatch):
monkeypatch.setitem(sys.modules, "cryptography", None)
Expand Down