feat: expose canonical dual-stack instance network
parent
c0ee66f369
commit
46c5a7b51b
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cloud;
|
||||
|
||||
/**
|
||||
* Browser-safe projection of the immutable public-network snapshot.
|
||||
*
|
||||
* The canonical snapshot is the sole public identity for a new instance.
|
||||
* Flat IPv4 fields returned here are presentation aliases only; callers must
|
||||
* never read similarly named values from the stored specification.
|
||||
*/
|
||||
final class CloudInstancePublicNetworkProjection
|
||||
{
|
||||
public static function fromSpec(array $spec): array
|
||||
{
|
||||
try {
|
||||
$snapshot = CloudPublicNetworkSnapshot::fromArray(
|
||||
$spec['public_network'] ?? null
|
||||
)->toArray();
|
||||
} catch (\InvalidArgumentException) {
|
||||
return self::invalid();
|
||||
}
|
||||
|
||||
$ipv4 = self::leg($snapshot['ipv4']);
|
||||
$ipv6 = self::leg($snapshot['ipv6']);
|
||||
$network = [
|
||||
'contract' => 1,
|
||||
'network_selector' => $snapshot['network_selector'],
|
||||
'ipv4' => $ipv4,
|
||||
'ipv6' => $ipv6,
|
||||
'dns_servers' => $snapshot['dns_servers'],
|
||||
];
|
||||
|
||||
return [
|
||||
'public_network_valid' => true,
|
||||
'public_network' => $network,
|
||||
'public_ipv4' => $ipv4['address'],
|
||||
'public_ipv4_cidr' => $ipv4['address_cidr'],
|
||||
'public_ipv6' => $ipv6['address'],
|
||||
'public_ipv6_cidr' => $ipv6['address_cidr'],
|
||||
// Compatibility aliases remain derived from the immutable
|
||||
// snapshot while IPv4-only mutation paths are retired in C10.
|
||||
'public_ip' => $ipv4['address'],
|
||||
'public_ip_cidr' => $ipv4['address_cidr'],
|
||||
'gateway' => $ipv4['gateway'],
|
||||
'dns_servers' => $network['dns_servers'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-validate a browser-safe projection before a cached snapshot is
|
||||
* decorated with live Agent metadata. Aliases are always re-derived from
|
||||
* the nested network object, never copied from the caller.
|
||||
*/
|
||||
public static function fromProjection(array $projection): array
|
||||
{
|
||||
if (!array_key_exists('public_network_valid', $projection)) {
|
||||
return [];
|
||||
}
|
||||
if ($projection['public_network_valid'] !== true) {
|
||||
return self::invalid();
|
||||
}
|
||||
|
||||
$network = $projection['public_network'] ?? null;
|
||||
if (!is_array($network) || array_is_list($network)
|
||||
|| !self::exactKeys($network, [
|
||||
'contract', 'network_selector', 'ipv4', 'ipv6',
|
||||
'dns_servers',
|
||||
])) {
|
||||
return self::invalid();
|
||||
}
|
||||
|
||||
$raw = [
|
||||
'contract' => $network['contract'] ?? null,
|
||||
'network_selector' => $network['network_selector'] ?? null,
|
||||
'ipv4' => self::rawLeg($network['ipv4'] ?? null,
|
||||
str_repeat('1', 32)),
|
||||
'ipv6' => self::rawLeg($network['ipv6'] ?? null,
|
||||
str_repeat('2', 32)),
|
||||
'dns_servers' => $network['dns_servers'] ?? null,
|
||||
];
|
||||
if ($raw['ipv4'] === null || $raw['ipv6'] === null) {
|
||||
return self::invalid();
|
||||
}
|
||||
$result = self::fromSpec(['public_network' => $raw]);
|
||||
return ($result['public_network_valid'] ?? false) === true
|
||||
&& ($result['public_network'] ?? null) === $network
|
||||
? $result
|
||||
: self::invalid();
|
||||
}
|
||||
|
||||
private static function leg(array $leg): array
|
||||
{
|
||||
return [
|
||||
'address_cidr' => $leg['address_cidr'],
|
||||
'address' => explode('/', $leg['address_cidr'], 2)[0],
|
||||
'pool_cidr' => $leg['pool_cidr'],
|
||||
'gateway' => $leg['gateway'],
|
||||
'gateway_on_link' => $leg['gateway_on_link'],
|
||||
];
|
||||
}
|
||||
|
||||
private static function rawLeg(mixed $leg, string $poolKey): ?array
|
||||
{
|
||||
if (!is_array($leg) || array_is_list($leg)
|
||||
|| !self::exactKeys($leg, [
|
||||
'address_cidr', 'address', 'pool_cidr', 'gateway',
|
||||
'gateway_on_link',
|
||||
])) {
|
||||
return null;
|
||||
}
|
||||
return [
|
||||
'pool_key' => $poolKey,
|
||||
'pool_cidr' => $leg['pool_cidr'] ?? null,
|
||||
'address_cidr' => $leg['address_cidr'] ?? null,
|
||||
'gateway' => $leg['gateway'] ?? null,
|
||||
'gateway_on_link' => $leg['gateway_on_link'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
private static function exactKeys(array $value, array $expected): bool
|
||||
{
|
||||
$actual = array_keys($value);
|
||||
sort($actual, SORT_STRING);
|
||||
sort($expected, SORT_STRING);
|
||||
return $actual === $expected;
|
||||
}
|
||||
|
||||
private static function invalid(): array
|
||||
{
|
||||
return [
|
||||
'public_network_valid' => false,
|
||||
'public_network' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
$read = static function (string $path) use ($root): string {
|
||||
$value = file_get_contents($root . '/' . $path);
|
||||
if (!is_string($value)) {
|
||||
throw new RuntimeException('Unable to read ' . $path);
|
||||
}
|
||||
return $value;
|
||||
};
|
||||
$assert = static function ($condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
$controller = $read('app/Controllers/CloudPageController.php');
|
||||
$instances = $read('resources/views/venix/cloud/pages/instances.tpl');
|
||||
$detail = $read('resources/views/venix/cloud/pages/detail.tpl');
|
||||
$instanceJs = $read('public/cloud/instances.js');
|
||||
$detailJs = $read('public/cloud/detail.js');
|
||||
$runtimeJs = $read('public/cloud/runtime.js');
|
||||
$styles = $read('public/cloud/styles.css');
|
||||
$adminTemplate = $read('resources/views/venix/admin/cloud/instances.tpl');
|
||||
$adminJs = $read('public/cloud/admin-instance-detail.js');
|
||||
$vpcTemplate = $read('resources/views/venix/cloud/pages/vpcs.tpl');
|
||||
$vpcJs = $read('public/cloud/vpcs.js');
|
||||
$ticketUser = $read('resources/views/venix/user/ticket_view.tpl');
|
||||
$ticketAdmin = $read('resources/views/venix/admin/ticket/view.tpl');
|
||||
$adminService = $read('app/Services/Cloud/CloudAdminInstanceService.php');
|
||||
|
||||
$assert(str_contains($controller, "'ipv4' => \$this->vmIp(\$vm, 4)")
|
||||
&& str_contains($controller, "'ipv6' => \$this->vmIp(\$vm, 6)")
|
||||
&& str_contains($controller,
|
||||
"=== 'configuration_invalid') {\n return ['网络配置异常'"),
|
||||
'The user page DTO does not expose separate IPv4 and IPv6 values.');
|
||||
$assert(str_contains($instances, '公网 IPv4')
|
||||
&& str_contains($instances, '公网 IPv6')
|
||||
&& str_contains($instances, 'data-copy-label="公网 IPv4"')
|
||||
&& str_contains($instances, 'data-copy-label="公网 IPv6"'),
|
||||
'The instance list lacks separate dual-stack labels or copy controls.');
|
||||
$assert(str_contains($styles,
|
||||
'.vm-table td[data-label="公网地址"]{grid-column:1/-1}')
|
||||
&& str_contains($styles, '.vm-public-addresses{min-width:0;width:100%}'),
|
||||
'The dual-stack instance list does not preserve a full-width mobile address row.');
|
||||
$assert(str_contains($detail, 'id="vm-detail-ipv4"')
|
||||
&& str_contains($detail, 'id="vm-detail-ipv6"')
|
||||
&& str_contains($detail, 'id="vm-detail-ipv4-copy"')
|
||||
&& str_contains($detail, 'id="vm-detail-ipv6-copy"'),
|
||||
'The instance detail lacks separate dual-stack fields or copy controls.');
|
||||
$assert(str_contains($instanceJs, 'public_ipv4')
|
||||
&& str_contains($instanceJs, 'public_ipv6')
|
||||
&& !str_contains($instanceJs,
|
||||
'return vm.public_network_valid !== true')
|
||||
&& str_contains($detailJs, 'vm-detail-ipv${family}-copy')
|
||||
&& str_contains($detailJs, 'for (const family of [4, 6])')
|
||||
&& !str_contains($detailJs,
|
||||
'return vm.public_network_valid !== true')
|
||||
&& str_contains($runtimeJs,
|
||||
"configuration_invalid: ['网络配置异常,请联系管理员', 'stopped']"),
|
||||
'The user JavaScript does not retain or render both public address families.');
|
||||
|
||||
$assert(str_contains($adminTemplate, '公网 IPv4')
|
||||
&& str_contains($adminTemplate, '公网 IPv6')
|
||||
&& str_contains($adminJs, "['公网 IPv4'")
|
||||
&& str_contains($adminJs, "['公网 IPv6'"),
|
||||
'The administrator list/detail does not render dual-stack public addresses.');
|
||||
$assert(str_contains($vpcTemplate, '公网 IPv4')
|
||||
&& str_contains($vpcTemplate, '公网 IPv6')
|
||||
&& str_contains($vpcJs, 'publicIpv6'),
|
||||
'The VPC member view does not show both public families.');
|
||||
$assert(str_contains($ticketUser, '$ticket_instance->public_ipv4')
|
||||
&& str_contains($ticketUser, '$ticket_instance->public_ipv6')
|
||||
&& str_contains($ticketAdmin, '$ticket_instance->public_ipv4')
|
||||
&& str_contains($ticketAdmin, '$ticket_instance->public_ipv6'),
|
||||
'Ticket-linked instance summaries do not show both public families.');
|
||||
|
||||
$assert(!str_contains($adminService, 'JSON_EXTRACT(')
|
||||
&& str_contains($adminService, 'CloudInstanceMetadata::publicSpec(')
|
||||
&& str_contains($adminService,
|
||||
"from('cloud_public_ips as searched_public_ip')")
|
||||
&& str_contains($adminService,
|
||||
"where('searched_public_ip.state', 'assigned')"),
|
||||
'Administrator search/read-model still depends on dialect-specific JSON or flat IP parsing.');
|
||||
|
||||
echo "Cloud dual-stack instance UI contracts passed.\n";
|
||||
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use App\Services\Cloud\CloudInstancePublicNetworkProjection;
|
||||
use App\Services\Cloud\CloudInstanceMetadata;
|
||||
|
||||
$assert = static function ($condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
$snapshot = [
|
||||
'contract' => 1,
|
||||
'network_selector' => 'bridge:br0',
|
||||
'ipv4' => [
|
||||
'pool_key' => str_repeat('1', 32),
|
||||
'pool_cidr' => '8.8.8.0/24',
|
||||
'address_cidr' => '8.8.8.20/24',
|
||||
'gateway' => '8.8.8.1',
|
||||
'gateway_on_link' => false,
|
||||
],
|
||||
'ipv6' => [
|
||||
'pool_key' => str_repeat('2', 32),
|
||||
'pool_cidr' => '2404:c140:156:3a::/64',
|
||||
'address_cidr' => '2404:c140:156:3a::20/64',
|
||||
'gateway' => '2404:c140:156::1',
|
||||
'gateway_on_link' => true,
|
||||
],
|
||||
'dns_servers' => ['1.1.1.1', '2606:4700:4700::1111'],
|
||||
];
|
||||
|
||||
$projection = CloudInstancePublicNetworkProjection::fromSpec([
|
||||
'public_network' => $snapshot,
|
||||
// Flat values are attacker-controlled legacy input and must never win.
|
||||
'public_ip' => '9.9.9.9',
|
||||
'public_ip_cidr' => '9.9.9.9/32',
|
||||
'gateway' => '9.9.9.1',
|
||||
]);
|
||||
|
||||
$assert(($projection['public_network_valid'] ?? null) === true,
|
||||
'A canonical dual-stack snapshot was not accepted.');
|
||||
$assert(($projection['public_network'] ?? null) === [
|
||||
'contract' => 1,
|
||||
'network_selector' => 'bridge:br0',
|
||||
'ipv4' => [
|
||||
'address_cidr' => '8.8.8.20/24',
|
||||
'address' => '8.8.8.20',
|
||||
'pool_cidr' => '8.8.8.0/24',
|
||||
'gateway' => '8.8.8.1',
|
||||
'gateway_on_link' => false,
|
||||
],
|
||||
'ipv6' => [
|
||||
'address_cidr' => '2404:c140:156:3a::20/64',
|
||||
'address' => '2404:c140:156:3a::20',
|
||||
'pool_cidr' => '2404:c140:156:3a::/64',
|
||||
'gateway' => '2404:c140:156::1',
|
||||
'gateway_on_link' => true,
|
||||
],
|
||||
'dns_servers' => ['1.1.1.1', '2606:4700:4700::1111'],
|
||||
], 'The browser projection was not derived exactly from the canonical snapshot.');
|
||||
$assert(($projection['public_ipv4'] ?? null) === '8.8.8.20'
|
||||
&& ($projection['public_ipv4_cidr'] ?? null) === '8.8.8.20/24'
|
||||
&& ($projection['public_ipv6'] ?? null) === '2404:c140:156:3a::20'
|
||||
&& ($projection['public_ipv6_cidr'] ?? null) === '2404:c140:156:3a::20/64'
|
||||
&& ($projection['public_ip'] ?? null) === '8.8.8.20'
|
||||
&& ($projection['public_ip_cidr'] ?? null) === '8.8.8.20/24'
|
||||
&& ($projection['gateway'] ?? null) === '8.8.8.1'
|
||||
&& ($projection['dns_servers'] ?? null)
|
||||
=== ['1.1.1.1', '2606:4700:4700::1111'],
|
||||
'Presentation aliases were not derived from the snapshot in one place.');
|
||||
|
||||
foreach ([
|
||||
[],
|
||||
['public_ip' => '8.8.8.20', 'public_ip_cidr' => '8.8.8.20/24'],
|
||||
['public_network' => array_replace($snapshot, [
|
||||
'ipv6' => array_replace($snapshot['ipv6'], [
|
||||
'address_cidr' => 'not-an-address',
|
||||
]),
|
||||
])],
|
||||
] as $invalidSpec) {
|
||||
$invalid = CloudInstancePublicNetworkProjection::fromSpec($invalidSpec);
|
||||
$assert($invalid === [
|
||||
'public_network_valid' => false,
|
||||
'public_network' => null,
|
||||
], 'A missing or damaged canonical snapshot did not fail closed.');
|
||||
}
|
||||
|
||||
$publicSpec = CloudInstanceMetadata::publicSpec([
|
||||
'region' => 'Hong Kong',
|
||||
'public_network' => $snapshot,
|
||||
'public_ip' => '9.9.9.9',
|
||||
'public_ip_cidr' => '9.9.9.9/32',
|
||||
]);
|
||||
$assert(($publicSpec['region'] ?? null) === 'Hong Kong'
|
||||
&& ($publicSpec['public_network_valid'] ?? null) === true
|
||||
&& ($publicSpec['public_ipv4'] ?? null) === '8.8.8.20'
|
||||
&& ($publicSpec['public_ipv6'] ?? null) === '2404:c140:156:3a::20'
|
||||
&& ($publicSpec['public_ip'] ?? null) === '8.8.8.20',
|
||||
'The public instance specification did not use the canonical projection.');
|
||||
|
||||
$closedSpec = CloudInstanceMetadata::publicSpec([
|
||||
'region' => 'Hong Kong',
|
||||
'public_ip' => '8.8.8.20',
|
||||
'public_ip_cidr' => '8.8.8.20/24',
|
||||
]);
|
||||
$assert(($closedSpec['public_network_valid'] ?? null) === false
|
||||
&& array_key_exists('public_network', $closedSpec)
|
||||
&& $closedSpec['public_network'] === null
|
||||
&& !isset($closedSpec['public_ip'], $closedSpec['public_ip_cidr']),
|
||||
'Legacy flat fields were trusted after the canonical snapshot was missing.');
|
||||
|
||||
$merged = CloudInstanceMetadata::merge([
|
||||
'plan_id' => 5,
|
||||
'public_network' => $snapshot,
|
||||
'public_ip' => '9.9.9.9',
|
||||
'public_ip_cidr' => '9.9.9.9/32',
|
||||
'gateway' => '9.9.9.1',
|
||||
'dns_servers' => ['9.9.9.9'],
|
||||
], [
|
||||
'public_ip_cidr' => '1.1.1.20/24',
|
||||
'public_network' => array_replace($snapshot, [
|
||||
'network_selector' => 'bridge:evil0',
|
||||
]),
|
||||
'vcpu' => 4,
|
||||
]);
|
||||
$assert(($merged['public_network'] ?? null) === $snapshot
|
||||
&& ($merged['vcpu'] ?? null) === 4
|
||||
&& !isset($merged['public_ip'], $merged['public_ip_cidr'],
|
||||
$merged['gateway'], $merged['dns_servers']),
|
||||
'Agent or legacy flat metadata replaced or duplicated the frozen snapshot.');
|
||||
|
||||
$view = CloudInstanceMetadata::publicView(array_merge($publicSpec, [
|
||||
'id' => '7',
|
||||
'api_id' => '7',
|
||||
'uuid' => '77777777-7777-4777-8777-777777777777',
|
||||
'name' => 'dual-stack-vm',
|
||||
]), [
|
||||
'uuid' => '77777777-7777-4777-8777-777777777777',
|
||||
'public_ip_cidr' => '1.1.1.20/24',
|
||||
'vcpu' => 8,
|
||||
]);
|
||||
$assert(($view['public_network_valid'] ?? null) === true
|
||||
&& ($view['public_ipv4'] ?? null) === '8.8.8.20'
|
||||
&& ($view['public_ipv6'] ?? null) === '2404:c140:156:3a::20'
|
||||
&& ($view['vcpu'] ?? null) === 8,
|
||||
'The live metadata view discarded or replaced the PHP-owned network projection.');
|
||||
|
||||
$tamperedAliases = CloudInstanceMetadata::publicView(array_merge($publicSpec, [
|
||||
'id' => '7', 'uuid' => '77777777-7777-4777-8777-777777777777',
|
||||
'name' => 'dual-stack-vm', 'public_ipv4' => '9.9.9.9',
|
||||
'public_ipv6' => '2606:4700:4700::9999',
|
||||
]), []);
|
||||
$assert(($tamperedAliases['public_ipv4'] ?? null) === '8.8.8.20'
|
||||
&& ($tamperedAliases['public_ipv6'] ?? null) === '2404:c140:156:3a::20',
|
||||
'Cached aliases were trusted instead of being re-derived by the projection helper.');
|
||||
|
||||
$damagedProjection = $publicSpec;
|
||||
$damagedProjection['public_network']['ipv6']['address'] = '2606:4700:4700::9999';
|
||||
$closedView = CloudInstanceMetadata::publicView(array_merge($damagedProjection, [
|
||||
'id' => '7', 'uuid' => '77777777-7777-4777-8777-777777777777',
|
||||
'name' => 'dual-stack-vm',
|
||||
]), []);
|
||||
$assert($closedView['public_network_valid'] === false
|
||||
&& $closedView['public_network'] === null
|
||||
&& !isset($closedView['public_ipv4'], $closedView['public_ipv6']),
|
||||
'A damaged cached network projection was not rejected before display.');
|
||||
|
||||
echo "Cloud instance public-network projection tests passed.\n";
|
||||
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use App\Controllers\CloudApiController;
|
||||
use App\Models\CloudInstance;
|
||||
|
||||
$assert = static function (bool $condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
global $System_Config;
|
||||
$System_Config = [];
|
||||
|
||||
$canonicalNetwork = [
|
||||
'contract' => 1,
|
||||
'network_selector' => 'bridge:br0',
|
||||
'ipv4' => [
|
||||
'pool_key' => str_repeat('1', 32),
|
||||
'pool_cidr' => '8.8.4.0/24',
|
||||
'address_cidr' => '8.8.4.10/24',
|
||||
'gateway' => '8.8.4.1',
|
||||
'gateway_on_link' => false,
|
||||
],
|
||||
'ipv6' => [
|
||||
'pool_key' => str_repeat('2', 32),
|
||||
'pool_cidr' => '2404:c140:156:3a::/64',
|
||||
'address_cidr' => '2404:c140:156:3a::10/64',
|
||||
'gateway' => '2404:c140:156::1',
|
||||
'gateway_on_link' => true,
|
||||
],
|
||||
'dns_servers' => ['1.1.1.1', '2606:4700:4700::1111'],
|
||||
];
|
||||
|
||||
$instance = static function (int $id, array $spec): CloudInstance {
|
||||
$row = new CloudInstance();
|
||||
$row->id = $id;
|
||||
$row->uuid = sprintf('11111111-1111-4111-8111-%012d', $id);
|
||||
$row->host_id = 1;
|
||||
$row->user_id = 7;
|
||||
$row->name = 'vm-' . $id;
|
||||
$row->status = 'active';
|
||||
$row->service_status = 'exempt';
|
||||
$row->network_status = 'active';
|
||||
$row->expires_at = null;
|
||||
$row->spec_json = json_encode($spec, JSON_THROW_ON_ERROR);
|
||||
$row->traffic_download_bytes = 0;
|
||||
$row->traffic_upload_bytes = 0;
|
||||
$row->traffic_quota_bytes = 0;
|
||||
$row->renewal_days = 0;
|
||||
$row->renewal_traffic_bytes = 0;
|
||||
$row->renewal_price = null;
|
||||
$row->sealed_credential = null;
|
||||
$row->created_at = $row->updated_at = time();
|
||||
return $row;
|
||||
};
|
||||
|
||||
$controller = new CloudApiController();
|
||||
$method = new ReflectionMethod($controller, 'vmData');
|
||||
$actor = [
|
||||
'user_id' => 7,
|
||||
'is_admin' => false,
|
||||
'is_super_admin' => false,
|
||||
'can_manage' => false,
|
||||
];
|
||||
$context = static fn (CloudInstance $row): array => [
|
||||
'vm' => [
|
||||
'uuid' => (string) $row->uuid,
|
||||
'state' => 'running',
|
||||
// Authenticated Agent metadata still cannot replace the immutable
|
||||
// panel snapshot or revive an invalid one.
|
||||
'public_ip' => '203.0.113.250',
|
||||
'public_network' => ['forged' => true],
|
||||
],
|
||||
'period' => null,
|
||||
'future_periods' => 0,
|
||||
'traffic_accounting' => [
|
||||
'traffic_accounting_mode' => 'legacy',
|
||||
'traffic_pool' => null,
|
||||
],
|
||||
];
|
||||
|
||||
$valid = $instance(1, [
|
||||
'os_source' => 'cloud_template',
|
||||
'public_network' => $canonicalNetwork,
|
||||
]);
|
||||
$validDto = $method->invoke($controller, $valid, $actor, $context($valid));
|
||||
$assert(($validDto['public_network_valid'] ?? null) === true
|
||||
&& ($validDto['public_ipv4'] ?? null) === '8.8.4.10'
|
||||
&& ($validDto['public_ipv6'] ?? null) === '2404:c140:156:3a::10'
|
||||
&& ($validDto['public_ip'] ?? null) === '8.8.4.10'
|
||||
&& ($validDto['network_status'] ?? null) === 'active'
|
||||
&& ($validDto['can_operate'] ?? null) === true,
|
||||
'The legacy VM API did not preserve the validated dual-stack projection.');
|
||||
|
||||
$invalid = $instance(2, [
|
||||
'os_source' => 'cloud_template',
|
||||
'public_ip' => '192.0.2.20',
|
||||
'public_ip_cidr' => '192.0.2.20/24',
|
||||
'gateway' => '192.0.2.1',
|
||||
]);
|
||||
$invalidDto = $method->invoke(
|
||||
$controller,
|
||||
$invalid,
|
||||
$actor,
|
||||
$context($invalid)
|
||||
);
|
||||
$assert(($invalidDto['public_network_valid'] ?? null) === false
|
||||
&& array_key_exists('public_network', $invalidDto)
|
||||
&& $invalidDto['public_network'] === null
|
||||
&& !array_key_exists('public_ipv4', $invalidDto)
|
||||
&& !array_key_exists('public_ipv6', $invalidDto)
|
||||
&& ($invalidDto['network_status'] ?? null) === 'configuration_invalid'
|
||||
&& ($invalidDto['can_operate'] ?? null) === false,
|
||||
'The legacy VM API trusted flat/Agent network fields or left invalid network mutations enabled.');
|
||||
|
||||
echo "Legacy VM API public-network projection behavior passed.\n";
|
||||
Loading…
Reference in New Issue