yavsc/src/Yavsc.Blogs.Tests
Paul Schneider e48ede1e84
acl post: never 500 regression sentinel + async CheckOwner + fixture seed
The hard rule on POST /api/v1/blogacl is: a 500 is never acceptable,
regardless of the payload shape. The prod 500 logged on 2026-08-21 on
mercure was caused by the PostIt client sending { circleId } only, which
the server deserialised into CircleAuthorizationToBlogPost with
BlogPostId = default(long) = 0; EF Core refused the INSERT with
InvalidOperationException: The value of
'CircleAuthorizationToBlogPost.BlogPostId' is unknown. The PostIt fix
lives in b82b6722 (enrich the payload with blogPostId). The server-side
guard lives in this commit:

- BlogAclApiController.CheckOwner is now async and uses FirstOrDefaultAsync
  instead of First, so it does not deadlock the request thread and
  returns false on a missing circle (which the controller already maps
  to ChallengeResult).
- BlogsWebServerFixture now seeds Alice, her Circle and her BlogPost
  in ConfigurePipelineAsync, once at host startup, against the shared
  SqliteConnection (Cache=Shared). EnsureCreated is idempotent and
  runs against the connection that every DbContext resolves through,
  so the test theory can POST payloads with real FK ids against a
  schema that actually has the Circle / BlogSpot tables.
- BlogAclApiTests:
    - PostCircleAuthorization_returns_201_when_payload_mirrors_PostIt_shape
      is the regression sentinel for the prod fix.
    - PostCircleAuthorization_never_returns_500 is a [Theory] over
      several payload shapes; any future commit that reintroduces a
      500 path turns it red. CleanupAcl at the start of each insert-
      bearing test isolates against xUnit's no-guarantee-of-order
      execution: a successful POST in test N would otherwise conflict
      with test N+1 against the same (CircleId, BlogPostId) pair.
2026-08-21 22:00:27 +01:00
..
BlogAclApiTests.cs acl post: never 500 regression sentinel + async CheckOwner + fixture seed 2026-08-21 22:00:27 +01:00
BlogApiMappedClaimsTests.cs GetUserId_reads_NameIdentifier_when_sub_was_mapped 2026-08-10 18:34:01 +01:00
BlogApiSmokeTests.cs feat(postit): circles+ACL UI, blog fixture→SQLite, seed default user 2026-08-20 23:59:21 +01:00
BlogApiTests.cs feat(postit): circles+ACL UI, blog fixture→SQLite, seed default user 2026-08-20 23:59:21 +01:00
BlogsWebServerFixture.cs acl post: never 500 regression sentinel + async CheckOwner + fixture seed 2026-08-21 22:00:27 +01:00
CircleMembersApiTests.cs refacto API prefix + nav.back 2026-08-20 20:50:52 +01:00
Directory.Packages.props feat(tests): scaffold Yavsc.Blogs.Tests with BlogsWebServerFixture 2026-07-06 21:49:53 +01:00
JwtClaimMappingCollection.cs GetUserId_reads_NameIdentifier_when_sub_was_mapped 2026-08-10 18:34:01 +01:00
MappedClaimsBlogsWebServerFixture.cs refacto API prefix + nav.back 2026-08-20 20:50:52 +01:00
PublishEndpointTests.cs feat(postit): circles+ACL UI, blog fixture→SQLite, seed default user 2026-08-20 23:59:21 +01:00
Yavsc.Blogs.Tests.csproj feat(postit): circles+ACL UI, blog fixture→SQLite, seed default user 2026-08-20 23:59:21 +01:00