Skip to content

Commit

Permalink
fix(cli): add ability to disable SSL verification
Browse files Browse the repository at this point in the history
Add a `--no-ssl-verify` option to disable SSL verification

Closes: #2714
  • Loading branch information
JohnVillalovos authored and nejch committed Dec 13, 2023
1 parent fad1441 commit 3fe9fa6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions gitlab/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,25 @@ def _get_base_parser(add_help: bool = True) -> argparse.ArgumentParser:
required=False,
default=os.getenv("GITLAB_URL"),
)
parser.add_argument(

ssl_verify_group = parser.add_mutually_exclusive_group()
ssl_verify_group.add_argument(
"--ssl-verify",
help=(
"Whether SSL certificates should be validated. [env var: GITLAB_SSL_VERIFY]"
"Path to a CA_BUNDLE file or directory with certificates of trusted CAs. "
"[env var: GITLAB_SSL_VERIFY]"
),
required=False,
default=os.getenv("GITLAB_SSL_VERIFY"),
)
ssl_verify_group.add_argument(
"--no-ssl-verify",
help="Disable SSL verification",
required=False,
dest="ssl_verify",
action="store_false",
)

parser.add_argument(
"--timeout",
help=(
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ def test_base_parser():
assert args.verbose
assert args.gitlab == "gl_id"
assert args.config_file == ["foo.cfg", "bar.cfg"]
assert args.ssl_verify is None


def test_no_ssl_verify():
parser = cli._get_base_parser()
args = parser.parse_args(["--no-ssl-verify"])
assert args.ssl_verify is False


def test_v4_parse_args():
Expand Down

0 comments on commit 3fe9fa6

Please sign in to comment.