Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ __pycache__/
# C extensions
*.so

# ai
**/.claude/*.local.*

# Distribution / packaging
.Python
build/
Expand Down
2 changes: 1 addition & 1 deletion auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 16 additions & 2 deletions test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"))
Expand Down
Loading