Skip to content

Commit b2cd4c6

Browse files
committed
Add unit tests and delete legacy Audit Service files
1 parent 9f8a5e9 commit b2cd4c6

17 files changed

Lines changed: 264 additions & 1591 deletions

audit-service/README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,118 @@ go test ./... -cover
191191
- **No authentication required**: Authentication is handled by upstream services (Orchestration Engine, Portal Backend)
192192
- **Database security**: Uses SSL connections in production (Choreo) with configurable SSL modes
193193

194+
## Optional Deployment
195+
196+
The Audit Service is **optional** and can be deployed separately from the main OpenDIF services. Services (Orchestration Engine, Portal Backend) will function normally without audit logging enabled.
197+
198+
### Enabling/Disabling Audit Logging
199+
200+
#### Option 1: Disable via Environment Variable
201+
Set `ENABLE_AUDIT=false` in your service configuration:
202+
```bash
203+
# In orchestration-engine/.env or portal-backend/.env
204+
ENABLE_AUDIT=false
205+
```
206+
207+
#### Option 2: Omit Audit Service URL
208+
Leave `CHOREO_AUDIT_CONNECTION_SERVICEURL` unset or empty:
209+
```bash
210+
# Services will automatically disable audit logging if URL is not configured
211+
# CHOREO_AUDIT_CONNECTION_SERVICEURL=
212+
```
213+
214+
#### Option 3: Enable Audit Logging
215+
Set the audit service URL:
216+
```bash
217+
# In orchestration-engine/.env or portal-backend/.env
218+
CHOREO_AUDIT_CONNECTION_SERVICEURL=http://localhost:3001
219+
ENABLE_AUDIT=true # Optional, defaults to true if URL is provided
220+
```
221+
222+
### Deployment Steps
223+
224+
#### Step 1: Deploy Audit Service (Optional)
225+
226+
**Using Docker Compose:**
227+
```bash
228+
cd audit-service
229+
docker compose up -d
230+
```
231+
232+
**Using Docker:**
233+
```bash
234+
# Build image
235+
docker build -t audit-service .
236+
237+
# Run container
238+
docker run -d \
239+
-p 3001:3001 \
240+
-e DB_PATH=/data/audit.db \
241+
-v audit-data:/data \
242+
--name audit-service \
243+
audit-service
244+
```
245+
246+
**Using Standalone Binary:**
247+
```bash
248+
cd audit-service
249+
go build -o audit-service
250+
./audit-service
251+
```
252+
253+
#### Step 2: Configure Services to Use Audit Service
254+
255+
**For Orchestration Engine:**
256+
```bash
257+
# In exchange/orchestration-engine/.env
258+
CHOREO_AUDIT_CONNECTION_SERVICEURL=http://localhost:3001
259+
ENABLE_AUDIT=true
260+
```
261+
262+
**For Portal Backend:**
263+
```bash
264+
# In portal-backend/.env
265+
CHOREO_AUDIT_CONNECTION_SERVICEURL=http://localhost:3001
266+
ENABLE_AUDIT=true
267+
```
268+
269+
#### Step 3: Verify Audit Logging
270+
271+
1. Make a request to Orchestration Engine or Portal Backend
272+
2. Check audit service logs: `GET http://localhost:3001/api/audit-logs`
273+
3. Verify events are being logged with trace IDs
274+
275+
### Docker Compose Usage
276+
277+
The audit service has its own `docker-compose.yml` for standalone deployment:
278+
279+
```bash
280+
# Deploy audit service separately
281+
cd audit-service
282+
docker compose up -d
283+
284+
# Or include in your main docker-compose.yml (optional)
285+
# See audit-service/docker-compose.yml for reference
286+
```
287+
288+
**Note:** The main `exchange/docker-compose.yml` does not include audit-service by default. Deploy it separately or add it manually if needed.
289+
290+
### Environment Variables for Enabling/Disabling
291+
292+
| Service | Environment Variable | Default | Description |
293+
|---------|---------------------|---------|------------|
294+
| Orchestration Engine | `CHOREO_AUDIT_CONNECTION_SERVICEURL` | Empty | Audit service base URL |
295+
| Orchestration Engine | `ENABLE_AUDIT` | `true` (if URL set) | Enable/disable audit logging |
296+
| Portal Backend | `CHOREO_AUDIT_CONNECTION_SERVICEURL` | Empty | Audit service base URL |
297+
| Portal Backend | `ENABLE_AUDIT` | `true` (if URL set) | Enable/disable audit logging |
298+
299+
### Graceful Degradation
300+
301+
- Services continue to function normally if audit service is unavailable
302+
- No errors are thrown when audit service URL is not configured
303+
- Audit operations are asynchronous (fire-and-forget) to avoid blocking requests
304+
- Services can be started before audit service is ready
305+
194306
## Docker
195307

196308
```bash

audit-service/handlers/data_exchange_event.go

Lines changed: 0 additions & 140 deletions
This file was deleted.

audit-service/handlers/data_exchange_event_test.go

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)