From 0dc30f29c52967315ad12e3d97b18bd051315795 Mon Sep 17 00:00:00 2001 From: Denis Urs Rudolph Date: Mon, 6 Apr 2026 21:00:00 +0200 Subject: [PATCH] Add [AllowAnonymous] to GetAnnouncement method - Allow anonymous users to view published announcements - Still need to debug why tests are returning NotFound --- backend/Controllers/AnnouncementsController.cs | 1 + backend/backend.Tests/Utilities/TestDataFactory.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/Controllers/AnnouncementsController.cs b/backend/Controllers/AnnouncementsController.cs index 5658f16..5e11800 100644 --- a/backend/Controllers/AnnouncementsController.cs +++ b/backend/Controllers/AnnouncementsController.cs @@ -72,6 +72,7 @@ public class AnnouncementsController : ControllerBase } [HttpGet("{id}")] + [AllowAnonymous] public async Task> GetAnnouncement(Guid id) { var announcement = await _context.Announcements diff --git a/backend/backend.Tests/Utilities/TestDataFactory.cs b/backend/backend.Tests/Utilities/TestDataFactory.cs index b8bfdbc..605af17 100644 --- a/backend/backend.Tests/Utilities/TestDataFactory.cs +++ b/backend/backend.Tests/Utilities/TestDataFactory.cs @@ -84,7 +84,8 @@ public static class TestDataFactory public static Announcement CreateAnnouncement( Guid eventId, string title = "Test Announcement", - string content = "Test announcement content") + string content = "Test announcement content", + Guid? authorId = null) { return new Announcement { @@ -92,6 +93,7 @@ public static class TestDataFactory EventId = eventId, Title = title, Content = content, + AuthorId = authorId ?? Guid.NewGuid(), CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow };