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
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
labels:
- "dependencies"
- "ci"
Expand All @@ -12,5 +13,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
open-pull-requests-limit: 10
labels:
- "dependencies"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
pull_request:
branches: [main, 1.0-maintenance, 2.0-development]
branches: [main, develop]
push:
branches: [main]
branches: [main, develop]

permissions:
contents: read
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Commit Lint

on:
pull_request:
branches: [main, 1.0-maintenance]
branches: [main, develop]

permissions:
contents: read
Expand Down Expand Up @@ -30,9 +30,8 @@ jobs:
"chore", "docs", "test", "style", "ci", "perf"
]],
"scope-enum": [1, "always", [
"core", "helpers", "deps", "release", "ci",
"version", "hmac", "docs", "tests", "examples",
"async", "statcalc"
"core", "helpers", "deps", "release", "ci",
"version", "hmac", "docs", "tests", "examples"
]],
"subject-max-length": [1, "always", 100],
"header-max-length": [0, "always"],
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Integration Tests

on:
pull_request:
branches: [main, 1.0-maintenance]
branches: [main, develop]
push:
branches: [main]
branches: [main, develop]
workflow_dispatch:

permissions:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
release:
name: Semantic Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
Expand Down Expand Up @@ -70,6 +71,7 @@ jobs:
# Publish the package to PyPI
pypi-publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs:
- release
permissions:
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/test.yml

This file was deleted.

3 changes: 2 additions & 1 deletion src/swgoh_comlink/helpers/_arena.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_arena_payout(offset: int, fleet: bool = False) -> datetime:
else:
payout = payout.replace(hour=18, minute=0, second=0, microsecond=0)
payout = payout - timedelta(minutes=(offset + local_offset))
if payout < datetime.now():
# Loop until payout time is in the future in case payout time is adjusted to a past time
while payout < datetime.now():
payout = payout + timedelta(days=1)
return payout
37 changes: 29 additions & 8 deletions tests/integration/test_hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
COMLINK_HMAC_URL,
HMAC_ACCESS_KEY,
HMAC_SECRET_KEY,
TEST_ALLYCODE,
)

pytestmark = pytest.mark.integration
Expand Down Expand Up @@ -48,14 +49,24 @@ def test_hmac_sync_player_request_succeeds(comlink_hmac):

@hmac_configured
def test_hmac_no_key_rejected():
"""Sync client without HMAC keys is rejected by the protected endpoint."""
"""Sync client without HMAC keys is rejected by the protected endpoint.

Uses a POST endpoint (`playerArena`) because the Comlink HMAC service
only enforces HMAC on POST; GET endpoints like `/enums` are
unauthenticated.
"""
with SwgohComlink(url=COMLINK_HMAC_URL) as client, pytest.raises(SwgohComlinkException):
client.get_enums()
client.get_player_arena(allycode=TEST_ALLYCODE, player_details_only=True)


@hmac_configured
def test_hmac_wrong_key_rejected():
"""Sync client with wrong secret key is rejected by the protected endpoint."""
"""Sync client with wrong secret key is rejected by the protected endpoint.

Uses a POST endpoint (`playerArena`) because the Comlink HMAC service
only enforces HMAC on POST; GET endpoints like `/enums` are
unauthenticated.
"""
with (
SwgohComlink(
url=COMLINK_HMAC_URL,
Expand All @@ -64,7 +75,7 @@ def test_hmac_wrong_key_rejected():
) as client,
pytest.raises(SwgohComlinkException),
):
client.get_enums()
client.get_player_arena(allycode=TEST_ALLYCODE, player_details_only=True)


# ── Async: valid HMAC ───────────────────────────────────────────────────
Expand Down Expand Up @@ -94,23 +105,33 @@ async def test_hmac_async_player_request_succeeds(async_comlink_hmac):
@hmac_configured
@pytest.mark.asyncio
async def test_hmac_no_key_async_rejected():
"""Async client without HMAC keys is rejected by the protected endpoint."""
"""Async client without HMAC keys is rejected by the protected endpoint.

Uses a POST endpoint (`playerArena`) because the Comlink HMAC service
only enforces HMAC on POST; GET endpoints like `/enums` are
unauthenticated.
"""
async with SwgohComlinkAsync(url=COMLINK_HMAC_URL) as client:
with pytest.raises(SwgohComlinkException):
await client.get_enums()
await client.get_player_arena(allycode=TEST_ALLYCODE, player_details_only=True)


@hmac_configured
@pytest.mark.asyncio
async def test_hmac_wrong_key_async_rejected():
"""Async client with wrong secret key is rejected by the protected endpoint."""
"""Async client with wrong secret key is rejected by the protected endpoint.

Uses a POST endpoint (`playerArena`) because the Comlink HMAC service
only enforces HMAC on POST; GET endpoints like `/enums` are
unauthenticated.
"""
async with SwgohComlinkAsync(
url=COMLINK_HMAC_URL,
access_key=HMAC_ACCESS_KEY,
secret_key="wrong_secret_key",
) as client:
with pytest.raises(SwgohComlinkException):
await client.get_enums()
await client.get_player_arena(allycode=TEST_ALLYCODE, player_details_only=True)


# ── HMAC header verification ────────────────────────────────────────────
Expand Down
Loading