Skip to content

[Feature] Update the sample to the current feature set and test it end to end (#57) - #88

Merged
samgerene merged 1 commit into
developmentfrom
feature/57-update-sample
Oct 11, 2026
Merged

samgerene merged 1 commit into
developmentfrom
feature/57-update-sample

Conversation

@samgerene

Copy link
Copy Markdown
Owner

Fixes #57

Problem

The sample predates problem details, the exception handler, authentication, retries and compression. It sent JSON without a content type, and a malformed body in the POST and PUT handlers threw, which the host answers with a generic 500.

Change

Server

  • Responses are JSON with Content-Type: application/json, through a pass-through JsonArgusBodySerializer in the sample, so Accept: application/json is negotiable.
  • A body that is not valid JSON, or is null, returns a 400 problem details response; an item without a name returns 422; an unknown id returns a 404 problem details response.
  • AddArgusExceptionHandler, API key authentication (SampleApiKeyAuthenticationHandler, constant-time key comparison) and compression are registered. Listing the items calls AllowAnonymous(); every other endpoint requires credentials.

Client

  • Requests carry Content-Type and Accept: application/json and the API key; the client has a retry policy and compression enabled.
  • The run has eight steps, including a request without credentials (401) and one with malformed JSON (400). Each step checks the status it expects and throws when it differs.
  • The one-second start-up delay is gone: the client's connect waits for the pipe.

All registrations are in Program.ConfigureServices(services, pipeName), so the tests use what Main uses.

Tests

The test project now references the sample (moved here from #56). [ExcludeFromCodeCoverage] is removed from the sample classes and stays on Main, so the sample counts towards coverage.

  • SampleClientServiceTestFixture: runs the sample end to end against its own host; a wrong status faults the service and does not stop the application; the eight requests carry the content type, Accept, credentials and the assigned id.
  • SampleItemModuleTestFixture: over a pipe, with the sample's configuration: anonymous list, 401 without credentials or with a wrong key or scheme on every other route, 400 and 422 for invalid bodies on POST and PUT (the stored item stays unchanged), the create/read/update/delete cycle, 404 for unknown ids, a body above the compression threshold.
  • ProgramTestFixture: compression on both sides, the retry policy, the exception handler, the authentication handler and the JSON serializer are registered.

Issue check

Point in #57 Result
Sends JSON without Content-Type: application/json requests and responses carry it; tested for the client's requests and the module's responses
Malformed JSON in POST/PUT yields 500 400 problem details; tested for both verbs
Return problem details for invalid JSON context.Problem(...), which also sets the correlation token as instance (instead of the static ArgusProblemDetails.BadRequest)
Demonstrate AddArgusExceptionHandler registered; registration tested (no sample handler throws, so it is not observable over the pipe)
Demonstrate authentication API key handler, one anonymous endpoint; tested
Demonstrate a retry policy configured on the client; configuration tested
Demonstrate compression enabled on both sides; configuration tested. The sample's own bodies are below the 1 KB threshold, so the run itself does not compress
Comment: end-to-end test of the sample, including malformed JSON returning 400 Verify_that_the_sample_completes_all_its_steps_against_its_own_host; step 3 of the sample

Verification

  • dotnet build ArgusTransfer.sln: 0 warnings
  • dotnet test ArgusTransfer.sln: 739 passed
  • dotnet format ArgusTransfer.sln --verify-no-changes: clean
  • dotnet build ArgusTransfer.sln -warnaserror: 0 warnings
  • The sample was run: all eight steps print the expected status.

Not done, from the review: a sample step that actually compresses, a separate fixture for the authentication handler, and tests that pin the server-assigned id and the list content. Nothing ran on Linux or macOS locally.

CHANGELOG.md has an entry, CLAUDE.md a "Sample" paragraph, and the module excerpt in the wiki page "Routing And Modules" is updated.

🤖 Generated with Claude Code

…d to end (#57)

The sample sends and returns JSON with a content type, answers invalid
bodies with problem details instead of a 500, and registers the exception
handler, API key authentication, a retry policy and compression. The test
project references the sample, runs it end to end and tests its module
over a pipe.
@samgerene samgerene self-assigned this Oct 11, 2026
@sonarqubecloud

Copy link
Copy Markdown

@samgerene
samgerene merged commit 233bb72 into development Oct 11, 2026
5 checks passed
@samgerene
samgerene deleted the feature/57-update-sample branch October 11, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Update the sample to the current feature set

1 participant