Skip to content

test(#129): run the full openespi-authserver test suite in CI - #227

Merged
dfcoffin merged 6 commits into
mainfrom
fix/129-authserver-unit-tests
Nov 14, 2026
Merged

dfcoffin merged 6 commits into
mainfrom
fix/129-authserver-unit-tests

Conversation

@dfcoffin

Copy link
Copy Markdown
Contributor

Summary

The Authorization Server's untagged tests were broken (306 run, 29 failures, 23 errors), and CI ran only the testcontainers-it group. This PR fixes or deletes every failing test and makes CI and releases run the whole suite.

Stacked on #207 (base feature/196-dcr-opaque-tokens), because #207 deletes ClientRegistrationControllerTest. Merge #207 first; this PR then retargets to main.

Test class Change
AuthorizationServerApplicationTests contextLoads on H2 local (which can't start: #226) replaced by 7 tests against the real context on MySQL: filter chains, settings, beans, seeded clients
AuthorizationServerConfigTest Deleted. 25 tests that mocked HttpSecurity and checked framework behavior; their concerns are covered by the context tests above
EspiTokenCustomizerTest Now uses a real JwtEncodingContext instead of mocks; duplicate cases merged into parameterized tests
OAuthAdminControllerTest Dropped 6 access-control tests: standalone MockMvc has no security filters, so they couldn't test it. AdminEndpointAuthorizationIntegrationTest (GHSA-mh65) covers it
SecurityIntegrationTest Moved to Testcontainers MySQL with the real config; stale expectations corrected (seeded secrets, queryParam for authorize, CSRF on the session chain, real response headers)

Also removes the unused H2 test profile, and drops -Dgroups=testcontainers-it from the CI matrix and release-meta.sh. Docs are updated. No production code changed.

Found along the way (separate issues)

Notes

  • The JaCoCo check now runs but is below the 0.50 line minimum in 4 packages: authserver 0.33, controller 0.27, dto 0.22, service 0.25. It's advisory (haltOnFailure=false), so the build doesn't fail.

Test plan

Closes #129

🤖 Generated with Claude Code

@dfcoffin
dfcoffin force-pushed the feature/196-dcr-opaque-tokens branch from 8937bd3 to 763ee55 Compare November 13, 2026 07:53
@dfcoffin
dfcoffin force-pushed the fix/129-authserver-unit-tests branch from 4817529 to b0bf4ed Compare November 13, 2026 08:02
@dfcoffin dfcoffin closed this Nov 13, 2026
@dfcoffin dfcoffin reopened this Nov 13, 2026
Base automatically changed from feature/196-dcr-opaque-tokens to main November 14, 2026 04:59
dfcoffin and others added 5 commits November 14, 2026 14:04
…llerTest

The standalone MockMvc setup installs no security filter chain and no
method-security proxy, so the 401/403 (and "allowed") tests could never
exercise access control. Admin API authorization is covered against the
real configuration by AdminEndpointAuthorizationIntegrationTest and
AdminBearerTokenIntegrationTest. The request-handling tests stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the strict-stubbed JwtEncodingContext mocks (UnnecessaryStubbing,
NPE on null claims) with a real context and assertions on the resulting
claims. Role-to-resource-URI and customer-grant cases become parameterized;
duplicate "ESPI compliance" cases and null-context/null-claims/null-endpoint
cases (outside the framework contract) are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… test

AuthorizationServerConfigTest called the @bean filter-chain methods against
a mocked HttpSecurity and stubbed JdbcTemplate (ClassCast, UnfinishedStubbing,
null @value settings, removed /connect/register and JWK expectations) - it
tested the framework, not our configuration. AuthorizationServerApplicationTests
booted on the H2 'local' profile, which no longer starts.

AuthorizationServerApplicationTests now extends AbstractAuthserverIntegrationTest
(real config, MySQL Testcontainer) and asserts what the started context holds:
the four security filter chains, no JwtDecoder/JwtEncoder (opaque only, #134),
issuer and protocol endpoints, the JDBC client repository, grant-context
authorization service and ESPI customizer beans, and the seeded default clients'
grants, scopes, token format, TTLs, consent and PKCE settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move SecurityIntegrationTest off the H2 'test' profile (no schema: the H2
profile had no Flyway location) onto AbstractAuthserverIntegrationTest, and
correct its stale expectations:

- use the seeded clients' real secrets (the "{bcrypt}secret" literal never matched)
- malformed Basic header -> 400 invalid_request; client_secret_post on a
  client_secret_basic client -> 401 invalid_client
- protocol endpoints are CSRF-exempt by design; CSRF is asserted on the
  session-chain admin DELETE with an MFA-complete admin instead
- discovery document instead of the removed /oauth2/jwks endpoint
- authorize requests use queryParam (Spring AS reads the query string) and a
  per-test client, and assert delegation/redirect-URI/scope outcomes exactly
- introspection by the DataCustodian client of another client's token

Removed: the six admin access-control cases (covered by
AdminEndpointAuthorizationIntegrationTest / AdminBearerTokenIntegrationTest),
the duplicate opaque-token case, the no-op CORS case, and the unused
application-test.yml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The authserver unit tests are repaired, so drop the -Dgroups=testcontainers-it
restriction from the CI test matrix and from release-meta.sh, and update
CLAUDE.md, README.md, RELEASING.md, CI_CD_SETUP.md and the testcontainers-it
tag comments to say that `mvn verify -pl openespi-authserver` runs everything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dfcoffin
dfcoffin force-pushed the fix/129-authserver-unit-tests branch from b0bf4ed to 8c69ee7 Compare November 14, 2026 19:05
AuthorizationServerApplicationTests pins the exact set of SecurityFilterChain
beans. It was written before #240 added actuatorSecurityFilterChain, so the
first CI run of the rebased suite failed on that one assertion (1 of 274).
Keep the pin (a new chain changes which requests the others see) and list the
fifth chain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dfcoffin
dfcoffin merged commit f825aca into main Nov 14, 2026
11 checks passed
@dfcoffin
dfcoffin deleted the fix/129-authserver-unit-tests branch November 14, 2026 19:19
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.

Auth-server tests are broken AND excluded from CI — repair test infrastructure, then re-enable in CI

1 participant