Skip to content

test: stop booting a random port for repository tests - #349

Merged
fjlopez merged 3 commits into
devfrom
test/316-drop-random-port
Oct 21, 2026
Merged

fjlopez merged 3 commits into
devfrom
test/316-drop-random-port

Conversation

@fjlopez

@fjlopez fjlopez commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Why

Five repository tests boot an embedded server with RANDOM_PORT and RestTemplate to check HAL status and JSON. Sibling Data REST tests already cover that kind of contract with MockMvc on the shared context.

What changed

DatabaseConnectionRepositoryIntegrationTest, RoleRepositoryIntegrationTest, TerritoryRepositoryIntegrationTest, TerritoryGroupTypeRepositoryIntegrationTest, and UserResourceIntegrationTest now use @SpringBootTest with @AutoConfigureMockMvc. Admin calls use @WithMockUser(roles = "ADMIN"). Each previous assertion stays, including user create, delete, and the following 404. The port-only TestUtils.adminAuthHeaders helper and ClientHttpLoggerRequestInterceptor are removed. The unreleased changelog notes the change.

Scope

Test code and the changelog only. No production paths. Liquibase JPA slice tests from #317 are unchanged.

Blast Radius

These classes no longer bind a server port. They join the existing MockMvc context. Cookie login remains covered by the authentication controller tests.

Verification

The five classes passed on their own. The pre-commit hook ran spotlessCheck, the full H2 test task, and jacocoTestReport.

Fixes #316

@fjlopez
fjlopez merged commit 3722adb into dev Oct 21, 2026
1 check passed
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.

1 participant