Repository: stuartmccoll/gitlab-changelog-generator

Issue:
Add support for self-signed https certificates
Follow-up of #23 : Now that SSL is supported, it would be awesome to have a flag for disabling the certificate check in case of a self-hosted, self-signed certificate (mostly when using an intranet instance)

- https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests
- maybe this answer explains the least intrusive patch: https://stackoverflow.com/a/50159273/1531708

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 57d78f7..63bc117 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # CHANGELOG
 
+## v1.0.6 - 2019/10/01
+
+- Added a flag to disable SSL checking - [issue](https://github.com/stuartmccoll/gitlab-changelog-generator/issues/30) raised by [PhilLab](https://github.com/PhilLab).
+
 ## v1.0.5 - 2019/06/01
 
 - Amended the way date formatting is handled - [issue](https://github.com/stuartmccoll/gitlab-changelog-generator/issues/25) raised by [smutel](https://github.com/smutel), commit(s) contributed by [smutel](https://github.com/smutel).
diff --git a/changelog_generator/calls.py b/changelog_generator/calls.py
index 2546183..be30a21 100644
--- a/changelog_generator/calls.py
+++ b/changelog_generator/calls.py
@@ -24,6 +24,7 @@ def get_last_commit_date(cli_args: dict) -> str:
                 if "token" in cli_args
                 else None
             },
+            verify=cli_args["ssl"],
         )
         logger.info(response.status_code)
         response.raise_for_status()
@@ -69,6 +70,7 @@ def get_closed_issues_for_project(cli_args: dict) -> dict:
             headers={"PRIVATE-TOKEN": cli_args["token"]}
             if "token" in cli_args
             else None,
+            verify=cli_args["ssl"],
         )
         response.raise_for_status()
     except requests.exceptions.HTTPError as ex:
@@ -103,6 +105,7 @@ def get_last_tagged_release_date(cli_args: dict) -> str:
             headers={"PRIVATE-TOKEN": cli_args["token"]}
             if "token" in cli_args
             else None,
+            verify=cli_args["ssl"],
         )
         response.raise_for_status()
     except requests.exceptions.HTTPError as ex:
@@ -138,6 +141,7 @@ def get_commits_since_date(date: str, cli_args: dict) -> list:
             headers={"PRIVATE-TOKEN": cli_args["token"]}
             if "token" in cli_args
             else None,
+            verify=cli_args["ssl"],
         )
         response.raise_for_status()
     except requests.exceptions.HTTPError as ex:
diff --git a/changelog_generator/entry_point.py b/changelog_generator/entry_point.py
index e65de05..7c7d007 100644
--- a/changelog_generator/entry_point.py
+++ b/changelog_generator/entry_point.py
@@ -65,6 +65,15 @@ def process_arguments() -> dict:
         help="gitlab personal token for auth",
         required=False,
     )
+    parser.add_argument(
+        "-s",
+        "--ssl",
+        dest="ssl",
+        help="specify whether or not to enable ssl",
+        required=False,
+        default=True,
+        type=lambda x: (str(x).lower() in ["false", "2", "no"]),
+    )
 
     args = parser.parse_args()
 
@@ -78,6 +87,7 @@ def process_arguments() -> dict:
         "version": args.version,
         "changelog": args.changelog,
         "token": args.token,
+        "ssl": args.ssl,
     }
 
 
diff --git a/setup.py b/setup.py
index dd09982..89e1dd2 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
 
 setuptools.setup(
     name="gitlab-changelog-generator",
-    version="1.0.5",
+    version="1.0.6",
     author="Stuart McColl",
     author_email="it@stuartmccoll.co.uk",
     description="A small command line utility for generating CHANGELOG.md "


Test patch:
diff --git a/changelog_generator/tests/test_calls.py b/changelog_generator/tests/test_calls.py
index 2147a0a..de881c1 100644
--- a/changelog_generator/tests/test_calls.py
+++ b/changelog_generator/tests/test_calls.py
@@ -29,6 +29,7 @@ class TestCalls(unittest.TestCase):
             "branch_two": "master",
             "version": "1",
             "changelog": "N",
+            "ssl": "True",
         }
 
         try:
@@ -51,6 +52,7 @@ class TestCalls(unittest.TestCase):
             "branch_two": "master",
             "version": "1",
             "changelog": "N",
+            "ssl": "True",
         }
 
         commit_date = get_last_commit_date(cli_args)
@@ -74,6 +76,7 @@ class TestCalls(unittest.TestCase):
             "branch_two": "master",
             "version": "1",
             "changelog": "N",
+            "ssl": "True",
         }
 
         try:
@@ -103,6 +106,7 @@ class TestCalls(unittest.TestCase):
             "branch_two": "master",
             "version": "1",
             "changelog": "N",
+            "ssl": "True",
         }
 
         commits = get_commits_since_date(
@@ -138,6 +142,7 @@ class TestCalls(unittest.TestCase):
             "branch_two": "master",
             "version": "1",
             "changelog": "N",
+            "ssl": "True",
         }
 
         self.assertEqual(
@@ -165,6 +170,7 @@ class TestCalls(unittest.TestCase):
             "branch_two": "master",
             "version": "1",
             "changelog": "N",
+            "ssl": "True",
         }
 
         self.assertEqual(
diff --git a/changelog_generator/tests/test_entry_point.py b/changelog_generator/tests/test_entry_point.py
index c05877c..5aafc8b 100644
--- a/changelog_generator/tests/test_entry_point.py
+++ b/changelog_generator/tests/test_entry_point.py
@@ -32,6 +32,7 @@ class TestGenerator(unittest.TestCase):
             "version": "1.2.3",
             "changelog": "N",
             "token": "test-token",
+            "ssl": True,
         }
 
         result = process_arguments()