From 51606bf27678aa239edd024c787b00c63090db3a Mon Sep 17 00:00:00 2001 From: HackTheOxidation Date: Sat, 25 Nov 2023 18:02:24 +0100 Subject: [PATCH] [#1536] Enhancement: Add shortcut for --verify=no. --- httpie/cli/definition.py | 11 +++++++++++ tests/test_ssl.py | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/httpie/cli/definition.py b/httpie/cli/definition.py index 843b29c9cf..7043a3227e 100644 --- a/httpie/cli/definition.py +++ b/httpie/cli/definition.py @@ -811,6 +811,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False): ssl.add_argument( '--verify', + dest='verify', default='yes', short_help='If "no", skip SSL verification. If a file path, use it as a CA bundle.', help=""" @@ -820,6 +821,16 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False): variable instead.) """, ) +ssl.add_argument( + '-k', + dest='verify', + default='no', + short_help='Shortcut for "--verify=no" skipping SSL verification', + help=""" + Shortcut for "--verify=no" which skips verification of the host's + SSL certificate. See the '--verify' flag help for further information. + """, +) ssl.add_argument( '--ssl', dest='ssl_version', diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 6fb983785a..d247c81770 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -113,6 +113,11 @@ def test_verify_no_OK(self, httpbin_secure): r = http(httpbin_secure.url + '/get', '--verify=no') assert HTTP_OK in r + def test_verify_no_shortcut_OK(self, httpbin_secure): + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + r = http(httpbin_secure.url + '/get', '-k') + assert HTTP_OK in r + @pytest.mark.parametrize('verify_value', ['false', 'fALse']) def test_verify_false_OK(self, httpbin_secure, verify_value): urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)