microcks / microcks/microcks-cli
Lack of Integration and Authentication Protocol Tests for Keycloak Authorization Exchanges
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 52
- Forks
- 68
- Ø Merge
- 6 Std. 54 Min.
- Gemergte PRs (30 T.)
- 10
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in pkg/connectors/keycloak_client.go bei ConnectAndGetToken und ConnectAndGetTokenAndRefreshToken und verfolge anschließend, wie die Request-Header, URL-encoded-Parameter und die Token-Antwort verarbeitet werden. Verwende einen httptest-Mock-OIDC-Provider, um Basic Auth und das erfolgreiche Parsen des Tokens zu überprüfen, und decke anschließend die Antworten invalid-password und server-offline ohne Abstürze ab.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- go
- Bereich
- authentication, cli, testing-qa
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 72/100