microcks / microcks/microcks-cli

Lack of Integration and Authentication Protocol Tests for Keycloak Authorization Exchanges

Open
#484 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
Go
Stars
52
Forks
68
Avg merge
6h 54m
Merged PRs (30d)
10

Description

### Describe the bug

###

* **Location**: [pkg/connectors/keycloak_client.go](file:///c:/Users/Hp/microcks-cli/pkg/connectors/keycloak_client.go) -> `ConnectAndGetToken` & `ConnectAndGetTokenAndRefreshToken`
* **Detailed Description**:
This is about how the CLI logs us in for the first time. It has to send our credentials to the authentication server (Keycloak), format the request headers (including base64 encoding), and parse the token payload we get back.

Since we don't have tests for these authentication functions, any minor code change could break the login flow. If this fails, users won't even be able to connect to the Microcks server at all. We should test that our request payload format is correct and that we handle server response errors cleanly.
* **Test Requirements**:
* Verify that the client correctly formats base64 authorization headers for basic authentication.
* Make sure the credential request parameters are correctly URL-encoded.
* Verify that we cleanly parse successful response tokens and handle common server failures (like invalid password or server offline) without crashing.

#### Simulation Diagram
```mermaid
sequenceDiagram
autonumber
actor Test as Test Runner
participant KC as keycloakClient
participant mockOIDC as Mock OIDC Provider (httptest)

Test->>KC: Invoke ConnectAndGetToken()
activate KC
KC->>KC: Base64 Encode Username:Password
KC->>mockOIDC: POST /protocol/openid-connect/token (grant_type=client_credentials)
Note over mockOIDC: Validate Basic Auth header & Body form-params
activate mockOIDC
mockOIDC-->>KC: HTTP 200 OK {"access_token": "mock-token", "token_type": "Bearer"}
deactivate mockOIDC
KC-->>Test: Return "mock-token"
deactivate KC
```

### Expected behavior

_No response_

### Actual behavior

_No response_

### How to Reproduce?

_No response_

### Microcks version or git rev

_No response_

### Install method (`docker-compose`, `helm chart`, `operator`, `docker-desktop extension`,...)

_No response_

### Additional information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/connectors/keycloak_client.go at ConnectAndGetToken and ConnectAndGetTokenAndRefreshToken, then trace how the request headers, URL-encoded parameters, and token response are handled. Use an httptest mock OIDC provider to verify Basic Auth and successful token parsing, then cover invalid-password and server-offline responses without crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
authentication, cli, testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.