INTEGRATION: Add Integration Tests For Sdk And AspNetCore Clients - #28
Open
cjdutoit wants to merge 7 commits into
Conversation
cjdutoit
force-pushed
the
users/cjdutoit/acceptance-sdk-add-acceptance-tests
branch
from
August 11, 2026 14:51
2376e9f to
61b43eb
Compare
cjdutoit
force-pushed
the
users/cjdutoit/integration-sdk-add-integration-tests
branch
from
August 11, 2026 14:51
33bb93f to
01e803e
Compare
cjdutoit
force-pushed
the
users/cjdutoit/acceptance-sdk-add-acceptance-tests
branch
from
August 11, 2026 16:31
61b43eb to
cf9a1f9
Compare
cjdutoit
force-pushed
the
users/cjdutoit/integration-sdk-add-integration-tests
branch
from
August 11, 2026 16:33
01e803e to
e9b08e4
Compare
cjdutoit
force-pushed
the
users/cjdutoit/acceptance-sdk-add-acceptance-tests
branch
from
August 11, 2026 17:08
cf9a1f9 to
c43fe70
Compare
cjdutoit
force-pushed
the
users/cjdutoit/integration-sdk-add-integration-tests
branch
from
August 11, 2026 17:09
e9b08e4 to
0295593
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.
Third and final test tranche. Stacked on #27 (which is stacked on #26) — review those first; this retargets to
mainas they merge.What this adds
23 integration tests (3 skipped, see below) exercising the real composed object graph — real brokers, real DI container, real configuration binding — rather than mocks.
NHSDigital.ApiPlatform.Sdk.Tests.Integration(19):CareIdentityServiceClientTests— login URL construction against the configured CIS2 endpoint, unique CSRF state per call, empty access token before login, logout without a session, and the validation/dependency-validation/cancellation paths.PersonalDemographicsServiceClientTests— configuration binding, null and unauthenticated search criteria, cancellation.ServiceCollectionExtensionsTests— the whole graph resolves from a real container and falls back to the in-memory storage brokers as singletons.NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration(4):AddApiPlatformSdkCore+AddApiPlatformSdkAspNetCore, the session-backed brokers genuinely replace the in-memory defaults, and CSRF state and access tokens round-trip throughISession.Three tests that need a live NHS conversation carry an explicit
[Fact(Skip = "...")]rather than passing vacuously.Replaces the previous
NhsLoginTestsThe old tests were removed and rewritten:
BuildLoginUrl,Logout,GetAccessToken,GetUserInfo) violatedts-testing-002/ts-testing-007.Assert.True(true, "..."), which cannot fail.configuration.GetSection("CIS").Get<ApiPlatformConfigurations>()bound nothing, becauseApiPlatformConfigurationsnestsCareIdentityandPersonalDemographicsServicewhile the JSON was flat. Every endpoint was therefore the empty string, andAssert.Contains(config.CareIdentity.AuthEndpoint, loginUrl)was asserting that the URL contains"". The appsettings shape is fixed and the endpoints are now genuinely asserted.Please rotate these credentials
NHSDigital.ApiPlatform.Sdk.Tests.Integration/appsettings.jsoncontained a live-looking CIS2ClientIdandClientSecretcommitted to the repository. This PR removes them from the working tree and sources credentials fromappsettings.Development.json(now git ignored) orApiPlatform__CareIdentity__*environment variables — but they remain in git history, so they should be treated as compromised and rotated.Closes #31
Review remediation
ShouldOverrideTheInMemoryStorageBrokersWithSessionBackedOnescould not fail. It asserted thesession brokers beat the in-memory ones without ever registering the in-memory ones, so the
assertion was true by construction. It now registers both.
not decide the winner, contrary to what
Documentation/DependencyGraph/README.mdclaimed.AddApiPlatformSdkInMemoryStorageusesTryAddSingleton, butAddApiPlatformSdkAspNetCoreusesplain
AddScoped, which appends rather than no-ops — and the last registration for a service isthe one that resolves. The session brokers therefore win in either order. The README advice to
"call
AddApiPlatformSdkAspNetCore()first or you get the process-wide singletons" was wrong, andboth it and the graph descriptions are corrected. There is now a test for each ordering.
ConfigurationProvider.HasCredentialswas dead code and its XML doc described askip-when-absent mechanism that does not exist. Removed, and the doc now says what actually
happens: live tests carry an explicit
[Fact(Skip = "...")].Follow-up from the remediation verification pass
Documented one nuance the corrected registration-order claim did not cover: last-wins governs
GetService/GetRequiredServiceonly. IfAddApiPlatformSdkInMemoryStorageruns first, itssingleton descriptor remains in the collection, so
GetServices<IApiPlatformStateBroker>()returnsboth implementations and a host that enumerates them can still reach the process-wide singleton.