microcks / microcks/microcks-cli

Lack of Integration and Authentication Protocol Tests for Keycloak Authorization Exchanges

Aperta
#484 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stale
Lingua principale
Go
Stelle
52
Fork
68
Merge medio
6h 54m
PR unite (30g)
10

Descrizione

### 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_

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in pkg/connectors/keycloak_client.go, in ConnectAndGetToken e ConnectAndGetTokenAndRefreshToken, quindi traccia come vengono gestiti gli header della richiesta, i parametri URL-encoded e la risposta del token. Usa un provider OIDC mock con httptest per verificare Basic Auth e il parsing corretto del token, quindi copri le risposte invalid-password e server-offline senza crash.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go
Ambito
authentication, cli, testing-qa
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
72/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.