Skip to content

Commit abfb8e6

Browse files
committed
fix: correct parameter order and type annotations in get_github_app_installation_token
## What Fixed swapped parameter order in test_get_github_app_installation_token where gh_app_private_key_bytes and gh_app_id were in the wrong positions. Updated type annotations for gh_app_id and gh_app_installation_id from str to int | None to match the actual types returned by get_int_env_var and passed by callers. ## Why The test passed despite the swapped arguments because create_jwt_headers was mocked, so the incorrect types were never exercised. The str type annotations were inconsistent with auth_to_github (which already used int | None) and with config.py where these values originate as int | None from get_int_env_var. ## Notes - Added str() cast at the create_jwt_headers call site, matching the existing pattern in auth_to_github line 36 Signed-off-by: jmeridth <jmeridth@gmail.com>
1 parent 013faea commit abfb8e6

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

auth.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,26 @@ def auth_to_github(
5151

5252
def get_github_app_installation_token(
5353
ghe: str,
54-
gh_app_id: str,
54+
gh_app_id: int | None,
5555
gh_app_private_key_bytes: bytes,
56-
gh_app_installation_id: str,
56+
gh_app_installation_id: int | None,
5757
) -> str | None:
5858
"""
5959
Get a GitHub App Installation token.
6060
API: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation # noqa: E501
6161
6262
Args:
6363
ghe (str): the GitHub Enterprise endpoint
64-
gh_app_id (str): the GitHub App ID
64+
gh_app_id (int | None): the GitHub App ID
6565
gh_app_private_key_bytes (bytes): the GitHub App Private Key
66-
gh_app_installation_id (str): the GitHub App Installation ID
66+
gh_app_installation_id (int | None): the GitHub App Installation ID
6767
6868
Returns:
6969
str: the GitHub App token
7070
"""
71-
jwt_headers = github3.apps.create_jwt_headers(gh_app_private_key_bytes, gh_app_id)
71+
jwt_headers = github3.apps.create_jwt_headers(
72+
gh_app_private_key_bytes, str(gh_app_id)
73+
)
7274
api_endpoint = f"{ghe}/api/v3" if ghe else "https://api.github.com"
7375
url = f"{api_endpoint}/app/installations/{gh_app_installation_id}/access_tokens"
7476

test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_get_github_app_installation_token(self, mock_post):
8585
mock_ghe = ""
8686

8787
result = get_github_app_installation_token(
88-
mock_ghe, b"gh_private_token", "gh_app_id", "gh_installation_id"
88+
mock_ghe, "gh_app_id", b"gh_private_token", "gh_installation_id"
8989
)
9090

9191
self.assertEqual(result, dummy_token)

0 commit comments

Comments
 (0)