修复:支持生产私有上游端点覆盖

This commit is contained in:
WuYongJie 2026-07-24 13:00:12 +08:00
parent 9a65836e3f
commit e92ccfa376
2 changed files with 28 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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');