microcks / microcks/microcks-cli
Lack of Integration and Authentication Protocol Tests for Keycloak Authorization Exchanges
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 52
- Forks
- 68
- Merge medio
- 6 h 54 min
- PR fusionados (30 d)
- 10
Descripción
Describe the bug
-
Location: 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
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en pkg/connectors/keycloak_client.go, en ConnectAndGetToken y ConnectAndGetTokenAndRefreshToken, y sigue cómo se gestionan los encabezados de la solicitud, los parámetros URL-encoded y la respuesta del token. Usa un proveedor OIDC simulado con httptest para verificar Basic Auth y el análisis correcto del token; después, cubre las respuestas invalid-password y server-offline sin provocar crashes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- go
- Área
- authentication, cli, testing-qa
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 72/100