import XCTest @testable import UCVLZonghengjia final class ClientConfigResponseTests: XCTestCase { func testDecodesVersionedGatewayContract() throws { let data = Data(#"{"config_contract":2,"gateway":{"host":"vpn.toplc.cn","ipv4":"192.0.2.1"},"node":{"slug":"n1","name":"VPN001","region":"东京","status":"online"},"route_mode":"smart","config":{}}"#.utf8) let response = try JSONDecoder().decode(ClientConfigResponse.self, from: data) XCTAssertEqual(response.configContract, 2) XCTAssertEqual(response.gateway?.host, "vpn.toplc.cn") XCTAssertEqual(response.gateway?.ipv4, "192.0.2.1") } func testOldBackendPayloadRemainsCompatible() throws { let data = Data(#"{"node":{"slug":"n1","name":"VPN001","region":"东京","status":"online"},"route_mode":"smart","config":{}}"#.utf8) let response = try JSONDecoder().decode(ClientConfigResponse.self, from: data) XCTAssertNil(response.configContract) XCTAssertNil(response.gateway) } }