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
5 changes: 3 additions & 2 deletions src/simple_github/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ async def get_token(self) -> str:


class AppAuth(Auth):
def __init__(self, app_id: int, privkey: str):
def __init__(self, app_id: str | int, privkey: str):
"""Authentication for a Github app.

Args:
id (str): The Github app id.
app_id (str or int): The Github Client (str) or App (int) ID. GitHub
recommends using the Client ID.
privkey (str): A base64 encoded private key associated with the
app.
"""
Expand Down
14 changes: 8 additions & 6 deletions test/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ async def test_token_auth_get_token():


@pytest.mark.asyncio
async def test_app_auth_get_token(privkey, pubkey):
id = 42
auth = AppAuth(id, privkey)
@pytest.mark.parametrize("app_id", (42, "42"))
async def test_app_auth_get_token(app_id: int | str, privkey: str, pubkey: str):
auth = AppAuth(app_id, privkey)
token = await auth.get_token()

payload = jwt.decode(token, pubkey, algorithms=["RS256"])
assert payload["iss"] == str(id)
assert payload["iss"] == str(app_id)
assert payload["exp"] == payload["iat"] + 540

# Calling again yields the same token
Expand All @@ -45,8 +45,10 @@ async def test_app_auth_get_token(privkey, pubkey):


@pytest.mark.asyncio
async def test_app_installation_auth_get_token(aioresponses, privkey):
app_id = 42
@pytest.mark.parametrize("app_id", (42, "42"))
async def test_app_installation_auth_get_token(
aioresponses, app_id: int | str, privkey: str
):
inst_id = 100
owner = "mozilla"
auth = AppInstallationAuth(app=AppAuth(app_id, privkey), owner=owner)
Expand Down
Loading