From e92ccfa3761b4adc580f5dc6944f229cce23cdd4 Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Fri, 24 Jul 2026 13:00:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=A7=81=E6=9C=89=E4=B8=8A=E6=B8=B8=E7=AB=AF?= =?UTF-8?q?=E7=82=B9=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/UpstreamSourceRegistry.php | 3 +-- .../SystemSettings/UpstreamDatabasesTest.php | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) 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');