Commit Graph
37 Commits
Author SHA1 Message Date
nutcas3 393685846c fix: Convert Status field to string in ListSubscribers database request
- Cast req.Status to string when passing to database.ListSubscribersRequest
- Ensure type compatibility between service and database layer status fields
2026-04-29 03:31:29 +03:00
nutcas3 f6ec659fe9 refactor: Fix race condition in chaos service and update Redis rate limiter test mocks
- Add copy method to Experiment struct to create deep copy with proper Finished pointer handling
- Return experiment copy from RunExperiment to prevent race condition with JSON marshaling
- Update mock Eval calls to use float64 for window parameter instead of int64 in redis_ratelimit_test.go
- Update comments to reflect correct parameter types: now (int64), window (float64), limit (int64)
2026-04-25 06:54:29 +03:00
nutcas3 6cf546712b refactor: Replace interface{} with any type alias across codebase
- Replace interface{} with any in api_integration_test.go makeRequest method and test response maps
- Replace interface{} with any in logging.go WithField method and all logging function signatures
- Replace interface{} with any in middleware etag.go sync.Map.Range callback
- Replace interface{} with any in middleware redis_ratelimit.go RedisClientInterface and result parsing
- Replace interface{} with any in middleware redis_ratelimit_
2026-04-25 06:31:02 +03:00
nutcas3 653f23ff24 feat: Wrap all Kubernetes API operations with circuit breaker protection and improve error handling
- Add strings import to kubernetes.go
- Wrap ListDeployments with circuitBreaker.Execute and move result building inside closure
- Wrap GetDeployment with circuitBreaker.Execute and move result assignment inside closure
- Wrap ScaleDeployment with circuitBreaker.Execute and simplify error messages
- Wrap RestartDeployment with circuitBreaker.Execute
- Wrap PodLogs with circuitBreaker.Execute and add streaming
2026-04-25 06:12:40 +03:00
nutcas3 12513943cc feat: Add circuit breaker protection to Kubernetes service with configurable thresholds and timeout
- Add circuitbreaker import to kubernetes.go
- Add circuitBreaker field to KubernetesService struct
- Add circuit breaker initialization in NewKubernetesService with Config struct
- Add K8S_CB_FAILURE_THRESHOLD environment variable with 5 default
- Add K8S_CB_SUCCESS_THRESHOLD environment variable with 2 default
- Add K8S_CB_TIMEOUT_SECONDS environment variable with 60 second default
- Add getEnvUint helper
2026-04-25 06:04:15 +03:00
nutcas3 d7e83c1f0d feat: Add API key authentication support to charging engine client
- Add APIKey field to ChargingEngineConfig struct
- Add apiKey field to ChargingEngineClient struct
- Add setAPIKeyHeader method to set X-API-Key header when API key is configured
- Call setAPIKeyHeader in CheckCredit, DeductCredit, AddCredit, GetBalance, and HealthCheck methods
2026-04-25 03:43:32 +03:00
nutcas3 9d3b8428bd feat: Remove unused imports across charging engine modules
- Remove unused IntoResponse/warn/error/ChargingError/validate_* imports from api
- Remove unused AsyncCommands/error/ChargingSession/ErrorContext imports from credit_management
- Remove unused ErrorContext/ChargingError imports from engine
- Remove unused ErrorContext import from rating_billing and prefix unused variables with underscore
- Remove unused ErrorContext import from rating_plans_repo
- Remove unused log_error/validate_amount/validate_im
2026-04-25 01:06:30 +03:00
nutcas3 1889e78db2 feat: Refactor SubscriberService to split monolithic service into modular files with method organization by domain
- Remove all method implementations from subscriber.go (CreateSubscriber/GetSubscriber/GetSubscriberByIMSI/UpdateSubscriber/SuspendSubscriber/TerminateSubscriber/ListSubscribers/terminateSubscriberSessions/GetAccount/ListInvoices/GetInvoice/ListRatingPlans/GetRatingPlan/ListAlerts/SearchSubscribers/ResolveAlert/CreateAlert and all other methods)
- Update SubscriberService struct comment
2026-04-24 08:51:13 +03:00
nutcas3 bb8bd808f5 feat: Add comprehensive test suite for authentication service and update charging service tests with SQLite in-memory database
- Add auth_test.go with setupTestDB/setupAuthService helpers using SQLite in-memory database and GORM AutoMigrate
- Add TestAuthService_Register with duplicate username/email validation and invalid role handling
- Add TestAuthService_Login with invalid username/password checks and inactive user validation
- Add TestJWTService_GenerateToken with database session verification and token storage validation
- Add TestJWTService_ValidateToken with invalid
2026-04-23 02:50:48 +03:00
nutcas3 ede12f0abd feat: Add automation service with workflow execution, scheduling, run history, and comprehensive test coverage
- Add AutomationService struct with database dependency and NewAutomationService constructor
- Add AutomationFilter struct with enabled/type fields for filtering automations
- Add List method with enabled/type filtering, created_at DESC ordering, and context support
- Add Get method with ID lookup, gorm.ErrRecordNotFound handling, and error wrapping
- Add CreateAutomationInput struct with name/description/type/enabled
2026-04-23 02:50:23 +03:00
nutcas3 115a10ed66 feat: Add authentication service with JWT token management, session handling, and user operations
- Add JWTService struct with db/secretKey fields and NewJWTService constructor
- Add Claims struct with UserID/Username/Role fields and jwt.RegisteredClaims embedding
- Add GenerateToken method with 15-minute access token, 7-day refresh token, session storage, and inactive session cleanup
- Add ValidateToken method with JWT parsing, HMAC signature verification, and active session validation
- Add validateTokenWithoutSessionCheck for token parsing
2026-04-23 01:55:21 +03:00
nutcas3 9e1a508769 feat: Add configuration store service with database-backed runtime settings, validation, and sensitive value masking
- Add ConfigStoreService struct with database dependency and NewConfigStoreService constructor
- Add List method with optional section filtering, section/key ordering, and sensitive value masking (********)
- Add UpsertConfigInput struct with section/key/value/type/sensitive/description/updated_by fields and required validation
- Add Upsert method with section+key lookup, default
2026-04-21 11:08:06 +03:00
nutcas3 f8d218448d refactor: Replace interface{} with any and add comprehensive plugin service tests with benchmarks
- Replace interface{} with any in sendDeactivationRequest method signature in es2_helpers.go
- Add plugin_service_test.go with setupPluginTest helper using in-memory SQLite and gorm.AutoMigrate
- Add TestPluginService_List with test cases for all/enabled/disabled/by-type filtering and no matches
- Add TestPluginService_Install with tests for successful install, duplicate prevention, and missing fields
2026-04-20 20:08:23 +03:00
nutcas3 14ca3d00e7 feat: Add deployment service with CRUD operations, rollback support, and status tracking
- Add DeploymentService struct with database dependency and NewDeploymentService constructor
- Add DeploymentFilter struct with Service/Environment/Status/Limit/Offset fields for query filtering
- Add List method with context support, filter application (service/environment/status), pagination (default limit: 20), and DESC ordering by created_at
- Add Get method with gorm.ErrRecordNotFound handling and formatted
2026-04-20 20:06:09 +03:00
nutcas3 4875fa7c88 feat: Add Kubernetes service with deployment management, scaling, restart, logs, and pod status monitoring
- Add KubernetesService struct with kubernetes.Clientset/namespace and NewKubernetesService constructor with in-cluster/kubeconfig fallback
- Add getInClusterNamespace helper with /var/run/secrets/kubernetes.io/serviceaccount/namespace reading
- Add Deployment struct with name/namespace/creationTimestamp/labels/replicas/readyReplicas/availableReplicas/updatedReplicas/unavailableReplicas fields
- Add ListDeployments method with AppsV1().Deployments().
2026-04-20 20:05:23 +03:00
nutcas3 501c558b9f feat: Add plugin service with CRUD operations, filtering, and enable/disable functionality
- Add PluginService struct with database dependency and NewPluginService constructor
- Add PluginFilter struct with Enabled/Type/Category fields for query filtering
- Add List method with context support, filter application (enabled/type/category), and DESC ordering by installed_at
- Add Get method with gorm.ErrRecordNotFound handling and formatted error messages
- Add InstallPluginInput struct with name/
2026-04-20 20:04:19 +03:00
NutcaseandGitHub 1b2b9d2412 Revert "Revert "App layer"" (#5) 2026-04-17 16:08:27 +03:00
NutcaseandGitHub efed7e936c Revert "App layer" 2026-04-17 15:59:31 +03:00
nutcas3 dd15ecdb93 feat: Replace placeholder data with database queries in charging service methods
- Update GetSystemStats to query active sessions, total accounts, blocked users, and low balance alerts from database
- Update GetHealthStatus to check database connectivity and set ActiveSync status
- Update GetUsageStats to query usage events by IMSI and period with trend calculation comparing to previous period
- Update GetRealTimeUsage to query current session and today's usage from database
- Update ListUsageEvents to query usage events with
2026-04-17 15:55:41 +03:00
nutcas3 04846c8564 feat: Add chaos engineering service with experiment execution and HTTP middleware
- Add ChaosService with experiment management and concurrent execution tracking
- Add experiment types: latency, kill, crash, partition, flush, and load with configurable duration/probability
- Add experiment status tracking: idle, running, completed, and failed states
- Add RunExperiment to start chaos experiments in background goroutines with automatic cleanup
- Add experiment executors: injectLatency, killConnections, crashService
2026-04-17 15:55:21 +03:00
nutcas3 d5ca53030c feat: Replace placeholder card details with Stripe API integration in AddPaymentMethod
- Add stripeGW field to SubscriberService and initialize in NewSubscriberService with API key and webhook secret
- Add processPaymentToken to call Stripe API and retrieve payment method details from token
- Update AddPaymentMethod to call processPaymentToken and use real card details (last4, brand, expiry dates) from Stripe
- Update AddPaymentMethod to use req.IsDefault instead of hardcoded false value
- Import
2026-04-17 15:53:20 +03:00
nutcas3 cbfe5a4b9f feat: Implement real-time subscription polling for subscriber and alert updates
- Update SubscribeToSubscriberUpdates to poll database every 3 seconds for subscriber changes since last update
- Add buffered channel (size 5) to prevent blocking on subscriber updates
- Track lastUpdatedAt timestamp to query only new subscriber changes
- Add SubscribeToAlertUpdates to poll database every 2 seconds for new alerts
- Add buffered channel (size 10) for alert updates with ID-based filtering
- Support optional
2026-04-17 15:47:47 +03:00
nutcas3 9ce03cf81e feat: Replace placeholder data with database queries in subscriber service methods
- Update GetAccount to query actual usage events and balance from database instead of returning zeros
- Update ListInvoices to query invoices with filters, pagination, and preload subscriber data
- Update GetInvoice to query invoice by ID with line items and subscriber preloading
- Update ListRatingPlans to query active rating plans ordered by monthly fee
- Update GetRatingPlan to query rating plan by ID with active
2026-04-17 15:44:59 +03:00
nutcas3 adbdb40066 feat: Add charging engine HTTP client with credit management and health monitoring
- Add ChargingEngineClient with base URL and HTTP client with configurable timeout
- Add CheckCredit to verify subscriber credit availability by IP with bytes requested
- Add DeductCredit to deduct bytes from subscriber credit balance
- Add AddCredit to add bytes to subscriber credit balance
- Add GetBalance to retrieve current credit balance for subscriber by IP
- Add HealthCheck to verify charging engine availability
2026-04-17 15:43:53 +03:00
nutcas3 99bff17756 feat: Add charging service with usage tracking, system monitoring, and real-time statistics
- Add ChargingService with database and charging engine client dependencies
- Add GetSystemStats to retrieve active sessions, accounts, blocked users, and uptime metrics
- Add GetHealthStatus to check Redis connection, sync status, and memory usage
- Add GetUsageStats to get subscriber usage statistics with data/voice/SMS volumes, costs, and trends
- Add GetRealTimeUsage to track current session and today's usage metrics
2026-04-17 15:41:11 +03:00
nutcas3 d248b9b5e5 feat: Add invoice service with monthly invoice generation, payment tracking, and automated billing
- Add InvoiceService with database dependency for invoice management operations
- Add GenerateMonthlyInvoice to create invoices with plan fees and usage charges from billing period
- Add SendInvoice to update invoice status to pending (email integration TODO)
- Add MarkInvoiceAsPaid to update invoice payment status
- Add GetOverdueInvoices to query invoices past due date with pending status
- Add GetSubscriber
2026-04-17 15:40:57 +03:00
nutcas3 bcc42ae4c3 feat: Add subscriber service methods for account management, invoicing, alerts, and payment operations
- Add GetAccount to retrieve subscriber account information with balance and usage limits
- Add ListInvoices/GetInvoice for invoice management with line items
- Add ListRatingPlans/GetRatingPlan for rating plan queries
- Add ListAlerts/CreateAlert/ResolveAlert for alert management
- Add SearchSubscribers for subscriber search functionality
- Add SubscribeToSubscriberUpdates/SubscribeToAlertUpdates
2026-04-17 15:35:22 +03:00
nutcas3 a335c6754e refactor: Split subscriber service into separate files for better code organization
- Move IMSI allocation logic to subscriber_imsi.go
- Move authentication key generation (generateAuthKeys, getOperatorVariant, generateOPc) to subscriber_auth.go
- Move eSIM profile operations (provisionESIMProfile, deactivateESIMProfile) to subscriber_esim.go
- Keep core subscriber CRUD operations and session management in subscriber.go
- Remove unused crypto/aes, crypto/rand, encoding/hex, and os imports from main
2026-04-14 16:22:22 +03:00
nutcas3 3a3b4d93a0 refactor: Split ES2 client into separate files for better code organization
- Move ES2 request/response types to es2_types.go
- Move profile operations (download, activate, deactivate, delete, status, list) to es2_operations.go
- Move helper methods (send requests, validation, generateRequestID) to es2_helpers.go
- Keep core ES2Service struct and ProvisionProfile in es2_client.go
- Revert sendDeactivationRequest parameter type from any back to interface{}
2026-04-14 16:22:07 +03:00
nutcas3 62cdffee2b feat: Remove unused generateRequestID helper function from AMF client
- Remove generateRequestID function and its fmt/time imports
- Function was not being used in AMF client implementation
2026-04-14 16:21:43 +03:00
nutcas3 1ead99440e feat: Replace interface{} with any type alias for improved code clarity
- Remove omitempty from Plan field in Subscriber model
- Update NotifySubscriberUpdate to use any instead of interface{}
- Update sendDeactivationRequest parameter type from interface{} to any
2026-04-14 16:07:04 +03:00
nutcas3 13355a07e7 feat: Add environment-based operator variant configuration with padding support
- Add os import for environment variable access
- Update getOperatorVariant to read OP from OPERATOR_VARIANT env var
- Add fallback to default "TelecomOP1234567" for development
- Add zero-padding for OP values shorter than 16 bytes
- Update comments to reference environment variable configuration
2026-04-14 16:06:09 +03:00
nutcas3 e260ea3baa feat: Implement proper AES-128 OPc derivation per 3GPP specification
- Replace XOR-based OPc generation with AES-128 ECB encryption
- Add getOperatorVariant for consistent OP across subscribers
- Add AES cipher block creation with error handling
- Add OP length validation for AES-128 block size
- Update generateOPc to use crypto/aes for 3GPP-compliant OPc derivation
- Add hardcoded OP placeholder with production configuration note
2026-04-14 16:03:46 +03:00
nutcas3 a78599fa1f feat: Implement eSIM provisioning and AMF integration in subscriber service
- Add AMFClient and ES2Service dependencies to SubscriberService
- Initialize AMF client with default URL and ES2 service in NewSubscriberService
- Implement provisionESIMProfile with EID validation, profile provisioning, activation, and AMF notification
- Implement deactivateESIMProfile with profile deactivation, status updates, and session termination
- Add generateOPc helper for deriving OPc from OP and K using XOR-based
2026-04-14 16:00:46 +03:00
nutcas3 6e11d40f5e feat: Add AMF client for session termination and subscriber status notifications
- Add AMFClient struct with base URL and HTTP client
- Add NewAMFClient with 30s timeout
- Add TerminateSession for subscriber session termination with reason and timestamp
- Add NotifySubscriberUpdate for subscriber status change notifications
- Add SessionTerminationRequest and SessionTerminationResponse models
- Add generateRequestID helper for request tracking
2026-04-14 16:00:24 +03:00
nutcas3 2e1300282d feat: Add ES2Service for GSMA ES2+ eSIM profile management operations
- Add ES2Service struct with HTTP client and ES2Config
- Add NewES2Service with 30s timeout and TLS configuration
- Add ProvisionProfile for eSIM profile provisioning with metadata support
- Add ActivateProfile, DeactivateProfile, and DeleteProfile for profile lifecycle management
- Add GetProfileStatus for profile state queries
- Add ListProfiles for eUICC profile enumeration
- Add ValidateEID and ValidateICCID for identifier
2026-04-14 16:00:15 +03:00
nutcas3 24baebbf37 feat: Add subscriber service with IMSI allocation, authentication, and lifecycle management
- Add SubscriberService struct with Database and Config dependencies
- Add NewSubscriberService constructor
- Add CreateSubscriber with IMSI allocation, auth key generation, and eSIM provisioning support
- Add GetSubscriber and GetSubscriberByIMSI for subscriber retrieval
- Add UpdateSubscriber for subscriber information updates
- Add SuspendSubscriber with session termination
- Add TerminateSubscriber with session termination and eSIM profile deactivation
- Add ListSubscribers with pagination and
2026-04-14 15:52:23 +03:00