Conversation
Signed-off-by: aniket866 <iamaniketkumarmaner@gmail.com>
aniket866
requested review from
Harsh4902,
lbroudoux and
yada
as code owners
September 28, 2026 19:23
This branch was successfully deployed
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.
Description
keycloak_client.go ConnectAndGetTokenhas no tests at all. The entireKeycloak client package is untested. The most critical path to test is when
Keycloak returns a non-200 status (wrong credentials, realm not found, server
error) — the function should return a
KindAPIerror with the HTTP status codeand body. Currently nothing verifies this.
Why Necessary
Wrong credentials is the single most common failure a new user encounters. If
this error path regresses — e.g. the function panics, returns a nil error, or
swallows the body — users get no feedback and assume the server is down.
What If Not Present
A change to the response-parsing code (e.g. switching JSON library, restructuring
the token response) could silently break authentication for all users and no test
would catch it before release.
Diagram
sequenceDiagram participant T as Test participant KC as keycloakClient participant TS as httptest.Server T->>TS: register handler → always return 401 {"error":"unauthorized"} T->>KC: NewKeycloakClient(server.URL, "id", "secret") T->>KC: ConnectAndGetToken() KC->>TS: POST /protocol/openid-connect/token TS-->>KC: 401 {"error":"unauthorized"} KC-->>T: error (KindAPI) T->>T: assert error != nil T->>T: assert error contains "401" T->>T: assert KindOf(err) == KindAPIAi usage Disclosure: Chatgpt is used to review files and it's missing tests
Closes #554