ACCEPTANCE: Add Acceptance Tests For Sdk And AspNetCore Clients - #27
Open
cjdutoit wants to merge 5 commits into
Open
Conversation
cjdutoit
force-pushed
the
users/cjdutoit/acceptance-sdk-add-acceptance-tests
branch
from
August 11, 2026 14:28
a6ed619 to
4414a45
Compare
This was referenced Aug 11, 2026
cjdutoit
force-pushed
the
users/cjdutoit/acceptance-sdk-add-acceptance-tests
branch
2 times, most recently
from
August 11, 2026 16:31
61b43eb to
cf9a1f9
Compare
cjdutoit
force-pushed
the
users/cjdutoit/acceptance-sdk-add-acceptance-tests
branch
from
August 11, 2026 17:08
cf9a1f9 to
c43fe70
Compare
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.
Second of three test tranches. Stacked on #26 — base is
users/cjdutoit/foundations-sdk-add-unit-tests, so review that first and this will retarget tomainonce #26 merges.What this adds
27 acceptance tests driving the public client surface end to end against a WireMock-stubbed CIS2 and PDS, with no mocks below the client boundary.
NHSDigital.ApiPlatform.Sdk.Tests.Acceptance—ApiPlatformClientTests(19), against the standaloneApiPlatformClientwith in-memory storage:Authorization,X-Request-IDandNHSD-Session-URIDheaders actually reach the wire.OperationCanceledExceptionsurfaces unwrapped.NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance—SessionBackedApiPlatformClientTests(8), resolving the client from a DI container wired the way a host app would (AddApiPlatformSdkCore+AddApiPlatformSdkAspNetCore) with a session-backedIHttpContextAccessor:ISessionunder the expected keys.Source changes
Two acceptance tests failed against the code as it stood and exposed real defects, fixed on the #26 branch:
CareIdentityService's outerTryCatchre-wrapped exceptions its own innerTryCatchhad already mapped, so an HTTP 500 from the token endpoint reached callers as a dependency exception wrapping a service exception wrapping a dependency exception. It now rethrows its own exception types unchanged.InvalidOperationException, which the catch-all turned into a service exception — i.e. a caller-side tampering check reported as a server fault. It now throwsInvalidStateCareIdentityServiceExceptionand surfaces as a validation exception.Integration tests follow in PR 3.
Closes #30
Review remediation
ShouldThrowDependencyExceptionOnSearchPatientsIfPdsFailsAsyncran
NotFoundthrough the same theory as500and locked in a mapping the repo's own exceptionrules contradict. 4xx now has its own test asserting
*DependencyValidationException; thedependency-failure test covers 500/502 only.
ShouldThrowValidationExceptionOnGetUserInfoIfStateDoesNotMatchAsyncwas misnamed — it assertsDependencyValidationException, a different category. Renamed.delayed response when the client aborts, and
Stop()blocks on it, so each delay test billed itsfull delay. Delays are now just long enough to outlive the timeout under test. The SDK suite went
from 30s to 2s; the ASP.NET Core suite from 20s to 7s.
HttpClienttimeout no longer applies to the whole class. It left roughly 35 ms ofheadroom over measured cold start, and did in fact produce a spurious failure during this work.
The class container now uses the framework default, and only the two timeout tests build their own
short-timeout container.
Follow-up from the remediation verification pass
CareIdentityServiceClientDependencyValidationException;only the PDS half of that mapping was covered.
Sign-in now goes through the default client and only the call under test uses the short-timeout
container.
Stop(), so it is purewall clock. The ASP.NET Core suite is now ~6s and the SDK suite ~2s, from 20s and 30s originally.