diff --git a/modules/EcommerceFinance/Services/UpstreamSourceRegistry.php b/modules/EcommerceFinance/Services/UpstreamSourceRegistry.php index 93e69343..9d79c383 100644 --- a/modules/EcommerceFinance/Services/UpstreamSourceRegistry.php +++ b/modules/EcommerceFinance/Services/UpstreamSourceRegistry.php @@ -65,7 +65,6 @@ class UpstreamSourceRegistry private function usesLocalConfiguration(): bool { - return app()->environment(['local', 'development', 'testing']) - && (bool) config('upstreams.local_configuration.enabled', false); + return (bool) config('upstreams.local_configuration.enabled', false); } } diff --git a/tests/Feature/SystemSettings/UpstreamDatabasesTest.php b/tests/Feature/SystemSettings/UpstreamDatabasesTest.php index fc2bcf4e..d1db8540 100644 --- a/tests/Feature/SystemSettings/UpstreamDatabasesTest.php +++ b/tests/Feature/SystemSettings/UpstreamDatabasesTest.php @@ -132,6 +132,33 @@ class UpstreamDatabasesTest extends FeatureTestCase } } + public function test_private_override_is_honored_when_explicitly_enabled_in_production(): void + { + $connection = $this->connection('shared-secret'); + $connection->update(['source_key' => 'jiansun']); + $this->app->detectEnvironment(fn () => 'production'); + + try { + config([ + 'upstreams.local_configuration.enabled' => true, + 'jiansun.connection.host' => 'private-tunnel.test', + 'jiansun.connection.password' => 'private-secret', + ]); + $sources = new UpstreamSourceRegistry(new UpstreamStoredConfiguration()); + + $this->assertSame( + 'private-tunnel.test', + $sources->value('jiansun', 'connection.host') + ); + $this->assertSame( + 'private-secret', + $sources->value('jiansun', 'connection.password') + ); + } finally { + $this->app->detectEnvironment(fn () => 'testing'); + } + } + public function test_shared_password_is_available_with_a_different_app_key(): void { $connection = $this->connection('shared-secret');