Repository navigation
[Feature] Update the sample to the current feature set and test it end to end (#57) - #88
Merged
Merged
Conversation
…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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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
Content-Type: application/json, through a pass-throughJsonArgusBodySerializerin the sample, soAccept: application/jsonis negotiable.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 callsAllowAnonymous(); every other endpoint requires credentials.Client
Content-TypeandAccept: application/jsonand the API key; the client has a retry policy and compression enabled.All registrations are in
Program.ConfigureServices(services, pipeName), so the tests use whatMainuses.Tests
The test project now references the sample (moved here from #56).
[ExcludeFromCodeCoverage]is removed from the sample classes and stays onMain, 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
Content-Type: application/jsoncontext.Problem(...), which also sets the correlation token asinstance(instead of the staticArgusProblemDetails.BadRequest)AddArgusExceptionHandlerVerify_that_the_sample_completes_all_its_steps_against_its_own_host; step 3 of the sampleVerification
dotnet build ArgusTransfer.sln: 0 warningsdotnet test ArgusTransfer.sln: 739 passeddotnet format ArgusTransfer.sln --verify-no-changes: cleandotnet build ArgusTransfer.sln -warnaserror: 0 warningsNot 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.mdhas an entry,CLAUDE.mda "Sample" paragraph, and the module excerpt in the wiki page "Routing And Modules" is updated.🤖 Generated with Claude Code