Skip to content

Commit cf3e608

Browse files
committed
Add unit tests and delete legacy Audit Service files
1 parent 6fd7ad1 commit cf3e608

30 files changed

Lines changed: 881 additions & 2082 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ mocks/mock-dmt/Config.toml
4545
**/consent-engine/consent-engine
4646
**/orchestration-engine/orchestration-engine
4747
**/portal-backend/portal-backend
48+
**/audit-service/audit-service
49+
50+
# Database files
51+
**/*.db
52+
audit-service/data/
4853

4954
# Allow .choreo directories for WSO2 Choreo deployment
5055
!**/.choreo/

audit-service/.choreo/component.yaml

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

audit-service/.env.example

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,90 @@
1+
# Audit Service Environment Variables
2+
# Copy this file to .env and update values as needed for your environment
3+
14
# =============================================================================
2-
# AUDIT SERVICE ENVIRONMENT CONFIGURATION
5+
# Service Configuration
36
# =============================================================================
4-
# Copy this file to .env and configure the values according to your environment
7+
8+
# Service port (default: 3001)
9+
PORT=3001
10+
11+
# Environment mode: development or production (default: production)
12+
ENVIRONMENT=production
13+
14+
# Path to enum configuration YAML file (default: config/enums.yaml)
15+
# This file defines allowed values for eventType, eventAction, actorType, and targetType
16+
AUDIT_ENUMS_CONFIG=config/enums.yaml
517

618
# =============================================================================
7-
# SERVER CONFIGURATION
19+
# Database Configuration
820
# =============================================================================
9-
# Environment: development, production
10-
ENVIRONMENT=development
1121

12-
# Port for the audit service to listen on
13-
PORT=3001
22+
# Database type: sqlite or postgres (default: sqlite)
23+
# Set to "postgres" to use PostgreSQL instead of SQLite
24+
DB_TYPE=sqlite
1425

1526
# =============================================================================
16-
# DATABASE CONFIGURATION - CHOREO (Primary)
27+
# SQLite Configuration (used when DB_TYPE=sqlite)
1728
# =============================================================================
18-
# Primary database configuration for Choreo cloud environment
19-
CHOREO_DB_AUDIT_HOSTNAME=your-choreo-db-hostname.com
20-
CHOREO_DB_AUDIT_PORT=5432
21-
CHOREO_DB_AUDIT_USERNAME=your-choreo-username
22-
CHOREO_DB_AUDIT_PASSWORD=your-choreo-password
23-
CHOREO_DB_AUDIT_DATABASENAME=audit_db
2429

25-
# Database SSL mode (require, prefer, disable)
26-
DB_SSLMODE=require
30+
# Path to SQLite database file (default: ./data/audit.db)
31+
# The directory will be created automatically if it doesn't exist
32+
DB_PATH=./data/audit.db
33+
34+
# Maximum number of open database connections (default: 1 for SQLite)
35+
# SQLite best practice: use 1 to prevent lock contention
36+
DB_MAX_OPEN_CONNS=1
37+
38+
# Maximum number of idle database connections (default: 1 for SQLite)
39+
DB_MAX_IDLE_CONNS=1
2740

2841
# =============================================================================
29-
# DATABASE CONNECTION POOL SETTINGS
42+
# PostgreSQL Configuration (used when DB_TYPE=postgres)
3043
# =============================================================================
31-
# Maximum number of open connections to the database
32-
DB_MAX_OPEN_CONNS=25
3344

34-
# Maximum number of idle connections in the pool
35-
DB_MAX_IDLE_CONNS=5
45+
# Database host (default: localhost)
46+
DB_HOST=localhost
3647

37-
# Maximum lifetime of a connection (e.g., 1h, 30m, 45s)
38-
DB_CONN_MAX_LIFETIME=1h
48+
# Database port (default: 5432)
49+
DB_PORT=5432
3950

40-
# Maximum idle time of a connection (e.g., 30m, 15m, 300s)
41-
DB_CONN_MAX_IDLE_TIME=30m
51+
# Database username (default: postgres)
52+
DB_USERNAME=postgres
4253

43-
# Timeout for individual database queries (e.g., 30s, 1m)
44-
DB_QUERY_TIMEOUT=30s
54+
# Database password (required for PostgreSQL)
55+
DB_PASSWORD=
4556

46-
# Timeout for initial database connection (e.g., 10s, 5s)
47-
DB_CONNECT_TIMEOUT=10s
57+
# Database name (default: audit_db)
58+
DB_NAME=audit_db
4859

49-
# Number of retry attempts for database connection
50-
DB_RETRY_ATTEMPTS=10
60+
# SSL mode: disable, require, prefer, verify-full (default: disable for local)
61+
DB_SSLMODE=disable
5162

52-
# Delay between retry attempts (e.g., 2s, 1s, 500ms)
53-
DB_RETRY_DELAY=2s
63+
# Maximum number of open database connections (default: 25 for PostgreSQL)
64+
DB_MAX_OPEN_CONNS=25
65+
66+
# Maximum number of idle database connections (default: 5 for PostgreSQL)
67+
DB_MAX_IDLE_CONNS=5
5468

5569
# =============================================================================
56-
# CORS CONFIGURATION
70+
# Connection Pool Settings (applies to both SQLite and PostgreSQL)
5771
# =============================================================================
58-
# Comma-separated list of allowed origins for CORS
59-
# Example: http://localhost:3000,http://localhost:5173,https://yourdomain.com
60-
CORS_ALLOWED_ORIGINS=http://localhost:5173
72+
73+
# Maximum amount of time a connection may be reused (default: 1h)
74+
# Accepts formats like "1h", "30m", "15s", etc.
75+
DB_CONN_MAX_LIFETIME=1h
76+
77+
# Maximum amount of time a connection may be idle before being closed (default: 15m)
78+
# Accepts formats like "1h", "30m", "15s", etc.
79+
DB_CONN_MAX_IDLE_TIME=15m
6180

6281
# =============================================================================
63-
# LOGGING & MONITORING
82+
# CORS Configuration
6483
# =============================================================================
65-
# Log level (debug, info, warn, error)
66-
LOG_LEVEL=info
84+
85+
# Comma-separated list of allowed CORS origins (default: http://localhost:5173)
86+
# Examples:
87+
# - Single origin: CORS_ALLOWED_ORIGINS=http://localhost:5173
88+
# - Multiple origins: CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
89+
# - Allow all: CORS_ALLOWED_ORIGINS=*
90+
CORS_ALLOWED_ORIGINS=http://localhost:5173

audit-service/.env.local.example

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

audit-service/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ FROM alpine:3.17
2929
# Install runtime dependencies
3030
RUN apk --no-cache add ca-certificates tzdata wget
3131

32-
# Create non-root user with specific UID for WSO2 Choreo compliance
32+
# Create non-root user
3333
RUN adduser -D -s /bin/sh -u 10001 appuser
3434

3535
# Set working directory

0 commit comments

Comments
 (0)