diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d9febb2..7258072 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -20,4 +20,3 @@ examples: "feat: add new logger" or "fix: remove unused imports" - [ ] If documentation is needed for this change, has that been included in this pull request - [ ] run `make lint` and fix any issues that you have introduced - [ ] run `make test` and ensure you have test coverage for the lines you are introducing -- [ ] If publishing new data to the public (scorecards, security scan results, code quality results, live dashboards, etc.), please request review from `@jeffrey-luszcz` diff --git a/.gitignore b/.gitignore index 2446185..0eec7c0 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ __pycache__/ # C extensions *.so +# ai +**/.claude/*.local.* + # Distribution / packaging .Python build/ diff --git a/auth.py b/auth.py index 6669f54..a5e551a 100644 --- a/auth.py +++ b/auth.py @@ -32,7 +32,7 @@ def auth_to_github( else: gh = github3.github.GitHub() gh.login_as_app_installation( - gh_app_private_key_bytes, gh_app_id, gh_app_installation_id + gh_app_private_key_bytes, str(gh_app_id), gh_app_installation_id ) github_connection = gh elif ghe and token: diff --git a/test_auth.py b/test_auth.py index 9337abc..a7ed25b 100644 --- a/test_auth.py +++ b/test_auth.py @@ -58,7 +58,7 @@ def test_auth_to_github_with_ghe_and_ghe_app(self, mock_ghe): result = auth.auth_to_github( "", "123", "123", b"123", "https://github.example.com", True ) - mock.login_as_app_installation.assert_called_once() + mock.login_as_app_installation.assert_called_once_with(b"123", "123", "123") self.assertEqual(result, mock) @patch("github3.github.GitHub") @@ -71,7 +71,21 @@ def test_auth_to_github_with_app(self, mock_gh): result = auth.auth_to_github( "", "123", "123", b"123", "https://github.example.com", False ) - mock.login_as_app_installation.assert_called_once() + mock.login_as_app_installation.assert_called_once_with(b"123", "123", "123") + self.assertEqual(result, mock) + + @patch("github3.github.GitHub") + def test_auth_to_github_with_app_int_app_id(self, mock_gh): + """ + Test that an integer app_id is converted to a string before passing + to login_as_app_installation, to avoid PyJWT TypeError on the iss claim. + """ + mock = mock_gh.return_value + mock.login_as_app_installation = MagicMock(return_value=True) + result = auth.auth_to_github("", 123, 456, b"private_key", "", False) + mock.login_as_app_installation.assert_called_once_with( + b"private_key", "123", 456 + ) self.assertEqual(result, mock) @patch("github3.apps.create_jwt_headers", MagicMock(return_value="gh_token"))