@@ -295,6 +295,7 @@ func TestConfig_Validate_ProductionRequiresSecureStorageAndRedisWhenMultiTenant(
295295 cfg .MultiTenantURL = "https://tenant-manager.internal"
296296 cfg .MultiTenantCircuitBreakerThreshold = 5
297297 cfg .MultiTenantCircuitBreakerTimeoutSec = 30
298+ cfg .MultiTenantServiceAPIKey = "test-api-key"
298299 cfg .RedisHost = "redis:6379"
299300 cfg .RedisTLS = false
300301 cfg .RedisPassword = ""
@@ -309,6 +310,37 @@ func TestConfig_Validate_ProductionRequiresSecureStorageAndRedisWhenMultiTenant(
309310 assert .Contains (t , err .Error (), "OBJECT_STORAGE_ENDPOINT must use HTTPS in production" )
310311}
311312
313+ func TestConfig_Validate_MultiTenantRequiresServiceAPIKey (t * testing.T ) {
314+ t .Parallel ()
315+
316+ cfg := validWorkerConfig ()
317+ cfg .MultiTenantEnabled = true
318+ cfg .MultiTenantURL = "http://tenant-manager:8080"
319+ cfg .MultiTenantCircuitBreakerThreshold = 5
320+ cfg .MultiTenantCircuitBreakerTimeoutSec = 30
321+ cfg .RedisHost = "redis:6379"
322+ cfg .MultiTenantServiceAPIKey = ""
323+
324+ err := cfg .Validate ()
325+ require .Error (t , err )
326+ assert .Contains (t , err .Error (), "MULTI_TENANT_SERVICE_API_KEY is required when MULTI_TENANT_ENABLED=true" )
327+ }
328+
329+ func TestConfig_Validate_MultiTenantValidWithServiceAPIKey (t * testing.T ) {
330+ t .Parallel ()
331+
332+ cfg := validWorkerConfig ()
333+ cfg .MultiTenantEnabled = true
334+ cfg .MultiTenantURL = "http://tenant-manager:8080"
335+ cfg .MultiTenantCircuitBreakerThreshold = 5
336+ cfg .MultiTenantCircuitBreakerTimeoutSec = 30
337+ cfg .RedisHost = "redis:6379"
338+ cfg .MultiTenantServiceAPIKey = "test-api-key"
339+
340+ err := cfg .Validate ()
341+ require .NoError (t , err )
342+ }
343+
312344func TestConfig_Validate_ProductionRequiresSecureRabbitMQScheme (t * testing.T ) {
313345 t .Parallel ()
314346
0 commit comments