Skip to content

Commit 9772bad

Browse files
committed
Adds arch diagram for test env in kind
1 parent 15178ad commit 9772bad

1 file changed

Lines changed: 53 additions & 133 deletions

File tree

test/kind/README.md

Lines changed: 53 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# KIND Mixed Authentication Tests
22

3-
This directory contains end-to-end tests for the Observatorium API's mixed authentication feature using a KIND (Kubernetes in Docker) cluster.
3+
This directory contains end-to-end tests for the Observatorium API's multi-authenticator feature using in KinD.
4+
Certificates are generated using cert-manager, and an OIDC provider (Dex) is deployed for authentication testing.
5+
The tests verify that the API correctly routes requests to the appropriate authentication method
6+
based on path patterns and enforces RBAC authorization.
7+
8+
Endpoints are stubbed to backend services (nginx proxy and httpbin) to validate that authenticated requests are properly forwarded.
49

510
## Overview
611

@@ -9,15 +14,11 @@ The tests verify that:
914
- Write endpoints (receive, push) use mTLS authentication
1015
- Path-based authentication routing works correctly
1116
- RBAC authorization is enforced
12-
- Backend proxying functions properly
1317

1418
## Prerequisites
1519

16-
- Docker
17-
- KIND (Kubernetes in Docker)
20+
- KinD
1821
- kubectl
19-
- Go 1.19+
20-
- make
2122

2223
## Quick Start
2324

@@ -44,138 +45,57 @@ The tests verify that:
4445
make teardown
4546
```
4647

47-
## Test Scenarios
48-
49-
The e2e tests cover:
50-
51-
### ✅ OIDC Authentication Tests
52-
- Read endpoints accept valid OIDC tokens
53-
- Query, query_range, labels, series endpoints work with Bearer tokens
54-
- Tokens are obtained via OAuth2 password grant flow from Dex
55-
56-
### ✅ mTLS Authentication Tests
57-
- Write endpoints require client certificates
58-
- Receive and push endpoints work with valid client certificates
59-
- Admin client certificates are used for write operations
60-
61-
### ✅ Authentication Rejection Tests
62-
- Read endpoints reject requests with only mTLS certificates
63-
- Write endpoints reject requests with only OIDC tokens
64-
- Invalid certificates are properly rejected
6548

66-
### ✅ Path Pattern Matching
67-
- Regex path patterns correctly route to appropriate auth methods
68-
- Edge cases in path matching work as expected
69-
70-
### ✅ RBAC Enforcement
71-
- Authorization rules are applied after successful authentication
72-
- User permissions are respected
73-
74-
### ✅ Backend Proxying
75-
- Authenticated requests are properly forwarded to backend services
76-
- Request headers and data are preserved
7749

7850
## Architecture
7951

52+
```mermaid
53+
graph TB
54+
Client[Client Requests]
55+
56+
subgraph "KIND Cluster"
57+
subgraph "Observatorium API"
58+
API[obs-api<br/>Multi-Authenticator]
59+
end
60+
61+
subgraph "Authentication Providers"
62+
Dex[Dex OIDC Provider<br/>Identity Server]
63+
CertManager[cert-manager<br/>Certificate Authority]
64+
end
65+
66+
subgraph "Backend Services"
67+
Nginx[nginx proxy<br/>Stubbed Backend]
68+
HttpBin[httpbin<br/>Test Service]
69+
end
70+
71+
subgraph "TLS Infrastructure"
72+
TLS[TLS Certificates<br/>mTLS Authentication]
73+
end
74+
end
75+
76+
Client -->|Read Requests<br/>query, labels| API
77+
Client -->|Write Requests<br/>receive, push| API
78+
79+
API -->|OIDC Auth<br/>Read endpoints| Dex
80+
API -->|mTLS Auth<br/>Write endpoints| TLS
81+
82+
API -->|Authenticated<br/>Requests| Nginx
83+
Nginx -->|Proxied<br/>Requests| HttpBin
84+
85+
CertManager -->|Generates| TLS
86+
87+
style API fill:#e1f5fe
88+
style Dex fill:#f3e5f5
89+
style TLS fill:#e8f5e8
90+
style Nginx fill:#fff3e0
91+
style HttpBin fill:#fff3e0
8092
```
81-
Test Runner → Port Forward → Observatorium API → Backend Services
82-
83-
[OIDC/mTLS Auth]
84-
85-
Dex OIDC
86-
```
87-
88-
### Components
8993

90-
- **KIND Cluster**: Local Kubernetes cluster for testing
91-
- **Observatorium API**: Main API with mixed authentication
92-
- **Dex**: OIDC provider for OAuth2/OIDC authentication
93-
- **cert-manager**: Automatic TLS certificate generation
94-
- **HTTPBin**: Backend service for request/response testing
95-
- **nginx**: Reverse proxy for backend routing
96-
97-
## Configuration
98-
99-
### Authentication Paths
100-
101-
**OIDC Paths** (Bearer token required):
102-
```
103-
^/api/(metrics|logs)/v1/auth-tenant/api/v1/(query|query_range|query_exemplars|labels|label/.*/values|series|metadata|rules|alerts).*
104-
```
105-
106-
**mTLS Paths** (Client certificate required):
107-
```
108-
^/api/(metrics|logs)/v1/auth-tenant/api/v1/(receive|push).*
109-
```
94+
The architecture demonstrates:
11095

111-
### Test Credentials
112-
113-
**OIDC Users:**
114-
- Username: `admin@example.com`
115-
- Password: `password`
116-
- Client: `observatorium-api`
117-
118-
**mTLS Certificates:**
119-
- Admin client cert: `testdata/admin-client.{crt,key}`
120-
- Test client cert: `testdata/test-client.{crt,key}`
121-
- CA cert: `testdata/ca.crt`
122-
123-
## Makefile Targets
124-
125-
- `make setup` - Complete environment setup
126-
- `make cluster-create` - Create KIND cluster only
127-
- `make deploy` - Deploy applications only
128-
- `make test` - Run e2e tests
129-
- `make test-comprehensive` - Run comprehensive test suite
130-
- `make teardown` - Clean up everything
131-
- `make reset` - Tear down and set up again
132-
- `make cluster-info` - Show cluster information
133-
134-
## Known Issues
135-
136-
- **TestReadEndpointsRejectMTLS DNS Error**: One test scenario fails with `dial tcp: lookup dex.proxy.svc.cluster.local: no such host`. This occurs when the test tries to access OIDC authentication from outside the cluster. The mixed authentication functionality works correctly - this is a test implementation limitation.
137-
138-
## Troubleshooting
139-
140-
### Port Forward Issues
141-
If tests fail with connection errors, check that port forwards are working:
142-
```bash
143-
# Check if ports are available
144-
netstat -an | grep :8080
145-
netstat -an | grep :5556
146-
147-
# Manual port forward test
148-
kubectl port-forward -n proxy service/observatorium-api 8080:8080
149-
```
150-
151-
### Certificate Issues
152-
Verify certificates are generated correctly:
153-
```bash
154-
kubectl get certificates -n proxy
155-
kubectl describe certificate server-cert -n proxy
156-
```
157-
158-
### OIDC Issues
159-
Check Dex logs and configuration:
160-
```bash
161-
kubectl logs -n proxy deployment/dex
162-
kubectl get configmap dex-config -n proxy -o yaml
163-
```
164-
165-
### API Issues
166-
Check API logs for authentication errors:
167-
```bash
168-
kubectl logs -n proxy deployment/observatorium-api
169-
```
96+
- **Path-based routing**: Different endpoints use different authentication methods
97+
- **OIDC Authentication**: Read endpoints (query, labels) authenticate via Dex OIDC provider
98+
- **mTLS Authentication**: Write endpoints (receive, push) use mutual TLS certificates
99+
- **Backend proxying**: Authenticated requests are forwarded to stubbed backend services
100+
- **Certificate management**: cert-manager handles TLS certificate lifecycle
170101

171-
## Files
172-
173-
- `Makefile` - Build and test automation
174-
- `e2e.go` - End-to-end test implementation
175-
- `extract-config.sh` - Certificate and config extraction script
176-
- `resources/` - Kubernetes resource definitions
177-
- `backends.yaml` - Backend services
178-
- `certificates.yaml` - TLS certificate requests
179-
- `dex.yaml` - Dex OIDC provider
180-
- `services.yaml` - Service definitions
181-
- `testdata/` - Generated certificates and config (created by setup)

0 commit comments

Comments
 (0)