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: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ jobs:
comment-title: 'Backend Unit Test Results'
results-path: 'coverage/*.trx'
coverage-path: 'coverage/**/coverage.cobertura.xml'
coverage-threshold: 30
# A few points under the 2026-10-04 baseline (72.2% lines) β€” raise as coverage grows.
coverage-threshold: 68
coverage-type: cobertura

frontend:
Expand Down
13 changes: 13 additions & 0 deletions Server.UnitTests/NotificationsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ public void GetVapidPublicKey_WhenOnlyPublicKeyIsSet_ReturnsNotFound()

// ── Subscribe / Unsubscribe ───────────────────────────────────────────────

// #462: only 0 (NFL) and 1 (CFB) are real sports β€” anything else would be stored and then never
// match a push, silently cutting that device off.
[Fact]
public async Task Subscribe_UndefinedSport_IsRejected_AndNothingIsSaved()
{
var request = new PushSubscriptionRequestDto { Endpoint = "https://push.example/ep1", P256dh = "p", Auth = "a", Sport = (LeagueType)5 };

var result = await BuildController("user-1").Subscribe(request);

Assert.IsType<BadRequestObjectResult>(result);
await _subscriptionService.DidNotReceive().SubscribeAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string?>(), Arg.Any<LeagueType?>());
}

[Fact]
public async Task Subscribe_ValidRequest_CallsServiceForTheCaller()
{
Expand Down
3 changes: 3 additions & 0 deletions Server/Controllers/NotificationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public async Task<IActionResult> Subscribe([FromBody] PushSubscriptionRequestDto
{
if (string.IsNullOrWhiteSpace(request.Endpoint) || string.IsNullOrWhiteSpace(request.P256dh) || string.IsNullOrWhiteSpace(request.Auth))
return BadRequest("Endpoint, P256dh, and Auth are required.");
// Only real sports (0 = NFL, 1 = CFB) β€” any other value would never match a push.
if (request.Sport is { } sport && !Enum.IsDefined(sport))
return BadRequest("Sport must be 0 (NFL) or 1 (CFB).");

await subscriptionService.SubscribeAsync(CurrentUserId, request.Endpoint, request.P256dh, request.Auth, request.UserAgent, request.Sport);
return NoContent();
Expand Down
Loading