Remove edge_broker_client.php and related unit tests. Add new dependencies and configuration files for edge-agent, including build scripts and package-lock updates.
This commit is contained in:
@@ -15,7 +15,6 @@ function with_edge_gateway_server_state(array $server, callable $callback): void
|
||||
{
|
||||
$originalServer = $_SERVER;
|
||||
$originalPublicApiUrl = getenv('EDGE_PUBLIC_API_URL');
|
||||
$originalBrokerPublicUrl = getenv('EDGE_BROKER_PUBLIC_URL');
|
||||
|
||||
$_SERVER = $server;
|
||||
|
||||
@@ -28,11 +27,6 @@ function with_edge_gateway_server_state(array $server, callable $callback): void
|
||||
} else {
|
||||
putenv('EDGE_PUBLIC_API_URL=' . $originalPublicApiUrl);
|
||||
}
|
||||
if ($originalBrokerPublicUrl === false) {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL');
|
||||
} else {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL=' . $originalBrokerPublicUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +47,9 @@ it('builds install script urls with forwarded https scheme when proxied', functi
|
||||
expect($script)->toContain('curl -fsSL "https://api.truckwash.io:4433/edge-agent/artifacts/package.json" -o "$INSTALL_DIR/package.json"');
|
||||
expect($script)->toContain('curl -fsSL "https://api.truckwash.io:4433/edge-agent/artifacts/agent.mjs" -o "$INSTALL_DIR/agent.mjs"');
|
||||
expect($script)->toContain('"apiUrl":"https://api.truckwash.io:4433"');
|
||||
expect($script)->toContain('"brokerUrl":"https://api.truckwash.io:4433"');
|
||||
expect($script)->toContain('"commandPollTimeoutSeconds":20');
|
||||
expect($script)->toContain('"shellActionPollTimeoutSeconds":20');
|
||||
expect($script)->not->toContain('"brokerUrl"');
|
||||
expect($script)->not->toContain('Undefined variable $INSTALL_DIR');
|
||||
});
|
||||
});
|
||||
@@ -80,11 +76,11 @@ it('infers https for the staging api host when only the https port is present',
|
||||
|
||||
expect($manager->getApiBaseUrl())->toBe('https://api.truckwash.io:4433');
|
||||
expect($script)->toContain('"apiUrl":"https://api.truckwash.io:4433"');
|
||||
expect($script)->toContain('"brokerUrl":"https://api.truckwash.io:4433"');
|
||||
expect($script)->not->toContain('"brokerUrl"');
|
||||
});
|
||||
});
|
||||
|
||||
it('prefers EDGE_PUBLIC_API_URL when explicitly configured and derives the broker from the api origin', function (): void {
|
||||
it('prefers EDGE_PUBLIC_API_URL when explicitly configured', function (): void {
|
||||
with_edge_gateway_server_state([
|
||||
'HTTP_HOST' => 'localhost',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'http',
|
||||
@@ -94,37 +90,7 @@ it('prefers EDGE_PUBLIC_API_URL when explicitly configured and derives the broke
|
||||
$manager = new EdgeGatewayManagerUrlHarness();
|
||||
|
||||
expect($manager->getApiBaseUrl())->toBe('https://edge.example.test/api');
|
||||
expect($manager->getBrokerPublicUrl())->toBe('https://edge.example.test');
|
||||
expect($manager->buildInstallScriptUrl('token-1'))->toBe('https://edge.example.test/api/edge-agent/install.sh?token=token-1');
|
||||
expect($manager->buildBrowserShellWsUrl('token-1'))->toBe('wss://edge.example.test/ws/browser-shell?token=token-1');
|
||||
});
|
||||
});
|
||||
|
||||
it('normalizes public broker overrides to https, strips paths, and browser shell urls to wss', function (): void {
|
||||
with_edge_gateway_server_state([
|
||||
'HTTP_HOST' => 'localhost',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'http',
|
||||
], function (): void {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL=http://api.truckwash.io:4300/edge-broker');
|
||||
|
||||
$manager = new EdgeGatewayManagerUrlHarness();
|
||||
|
||||
expect($manager->getBrokerPublicUrl())->toBe('https://api.truckwash.io:4300');
|
||||
expect($manager->buildBrowserShellWsUrl('shell-token'))->toBe('wss://api.truckwash.io:4300/ws/browser-shell?token=shell-token');
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps localhost broker overrides on plain http and ws for local development', function (): void {
|
||||
with_edge_gateway_server_state([
|
||||
'HTTP_HOST' => 'localhost:5173',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'http',
|
||||
], function (): void {
|
||||
putenv('EDGE_BROKER_PUBLIC_URL=http://localhost:4300');
|
||||
|
||||
$manager = new EdgeGatewayManagerUrlHarness();
|
||||
|
||||
expect($manager->getBrokerPublicUrl())->toBe('http://localhost:4300');
|
||||
expect($manager->buildBrowserShellWsUrl('shell-token'))->toBe('ws://localhost:4300/ws/browser-shell?token=shell-token');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user