test: add integration tests for authentication endpoints#39
Merged
DenizAltunkapan merged 3 commits intoJul 2, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds end-to-end integration coverage for the API gateway’s public auth endpoints and fixes a validation error-mapping gap so @Valid @RequestBody failures return 400 instead of falling through to the generic 500 handler.
Changes:
- Add
GatewayAuthControllerIntegrationTestcovering/auth/register,/auth/login, and/auth/refresh. - Add a
WebExchangeBindExceptionhandler to return400 BAD_REQUESTwith aggregated field error messages. - Add test profile R2DBC H2 configuration + test-scoped H2 dependencies to run against an in-memory database.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apigateway/src/test/resources/application-test.yaml | Configures in-memory R2DBC H2 and schema initialization for integration tests. |
| apigateway/src/test/java/vaultweb/apigateway/controller/GatewayAuthControllerIntegrationTest.java | New integration tests for register/login/refresh flows using WebTestClient. |
| apigateway/src/main/java/vaultweb/apigateway/exceptions/GlobalExceptionHandler.java | Adds handler for WebExchangeBindException to map body validation failures to 400 responses. |
| apigateway/pom.xml | Adds test dependencies for running R2DBC H2 integration tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ts assert absent fields
Member
Author
|
Hey @DenizAltunkapan, this one's been sitting for a bit — CI's green and it's mergeable whenever you get a chance to take a look. Thanks! |
Member
|
@GabrielBBaldez thanks for reminding me! it got lost in the emails |
DenizAltunkapan
approved these changes
Jul 2, 2026
DenizAltunkapan
left a comment
Member
There was a problem hiding this comment.
@GabrielBBaldez thanks
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.
Summary
Adds integration tests for the public authentication endpoints (
/auth/register,/auth/login,/auth/refresh), addressing #31. The gateway is started on a random port backed by an in-memory R2DBC (H2) database, so each test exercises the full controller → service → repository path end to end (no mocking of the data layer).Coverage (12 tests):
register: valid payload, duplicate email, duplicate username, invalid email format, weak password, missing fieldlogin: valid (by email and by username), wrong password, non-existent user, missing fieldrefresh: round-trips a refresh token obtained from loginDrive-by fix: the new tests surfaced that request-validation failures (
WebExchangeBindExceptionfrom@Validbodies) fell through to the generic handler and returned 500. Added a handler so they now return 400 with the field messages, consistent with the existingConstraintViolationExceptionhandling.Verified locally with
mvn spotless:check test→ 13 tests pass.Resolves #31.