Skip to content

Commit 3fe9fa6

Browse files
JohnVillalovosnejch
authored andcommitted
fix(cli): add ability to disable SSL verification
Add a `--no-ssl-verify` option to disable SSL verification Closes: #2714
1 parent fad1441 commit 3fe9fa6

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

gitlab/cli.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,25 @@ def _get_base_parser(add_help: bool = True) -> argparse.ArgumentParser:
194194
required=False,
195195
default=os.getenv("GITLAB_URL"),
196196
)
197-
parser.add_argument(
197+
198+
ssl_verify_group = parser.add_mutually_exclusive_group()
199+
ssl_verify_group.add_argument(
198200
"--ssl-verify",
199201
help=(
200-
"Whether SSL certificates should be validated. [env var: GITLAB_SSL_VERIFY]"
202+
"Path to a CA_BUNDLE file or directory with certificates of trusted CAs. "
203+
"[env var: GITLAB_SSL_VERIFY]"
201204
),
202205
required=False,
203206
default=os.getenv("GITLAB_SSL_VERIFY"),
204207
)
208+
ssl_verify_group.add_argument(
209+
"--no-ssl-verify",
210+
help="Disable SSL verification",
211+
required=False,
212+
dest="ssl_verify",
213+
action="store_false",
214+
)
215+
205216
parser.add_argument(
206217
"--timeout",
207218
help=(

tests/unit/test_cli.py

+7
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ def test_base_parser():
106106
assert args.verbose
107107
assert args.gitlab == "gl_id"
108108
assert args.config_file == ["foo.cfg", "bar.cfg"]
109+
assert args.ssl_verify is None
110+
111+
112+
def test_no_ssl_verify():
113+
parser = cli._get_base_parser()
114+
args = parser.parse_args(["--no-ssl-verify"])
115+
assert args.ssl_verify is False
109116

110117

111118
def test_v4_parse_args():

0 commit comments

Comments
 (0)