Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions cmuxTests/CLIVMLayoutEnvTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1010,18 +1010,6 @@ extension CLINotifyProcessIntegrationRegressionTests {
XCTAssertTrue(namelessLog.methods.isEmpty, namelessLog.methods.description)
}

func testVMResizeIsNoLongerAVerb() throws {
let (result, log) = try runVMCommandAgainstMock(
"vm-resize-gone",
arguments: ["vm", "resize", "brave-otter", "--disk", "40"]
) { _, _ in nil }
XCTAssertNotEqual(result.status, 0, result.stdout)
XCTAssertTrue(result.stderr.contains("Usage: cmux vm <"), result.stderr)
XCTAssertFalse(result.stderr.contains("resize"), "resize must not be advertised: \(result.stderr)")
XCTAssertTrue(result.stderr.contains("pause|resume"), result.stderr)
XCTAssertTrue(log.methods.isEmpty, "an unknown verb must not reach the app: \(log.methods)")
}

func testVMVerbHelpPrintsThatVerbsUsageWithoutASocket() throws {
let cliPath = try bundledCLIPath()
// Help never resolves a socket: point at a path nothing listens on.
Expand Down
34 changes: 31 additions & 3 deletions cmuxTests/VMSSHCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,19 @@ extension CLINotifyProcessIntegrationRegressionTests {
}
switch method {
case "vm.ssh_info":
// The app reports provider errors as `vm_error` and carries the
// provider's own code in `data.backend_code`, which is what the
// CLI's cmux-remote fallback reads.
return self.v2Response(
id: id,
ok: false,
error: [
"code": "vm_attach_transport_unsupported",
"code": "vm_error",
"message": "Freestyle provider SSH is unmanaged; use cmux-remote for a managed session.",
"data": [
"backend_code": "vm_attach_transport_unsupported",
"http_status": 501,
],
]
)
case "vm.cmux_remote_info":
Expand All @@ -342,6 +349,9 @@ extension CLINotifyProcessIntegrationRegressionTests {
"route": "ws://10.0.0.8:1337/v1/link",
"token": "route-token",
"session": "cloud",
// A machine this CLI has not opened before is only dialed when
// the app reports that it serves the trusted listener.
"trusted_carrier": true,
]
)
case "workspace.create":
Expand All @@ -353,6 +363,21 @@ extension CLINotifyProcessIntegrationRegressionTests {
"workspace_ref": "workspace:cloud",
]
)
case "surface.catalog":
// A freshly created machine is connected and has no remote
// workspaces yet, so the CLI opens a new terminal on it.
return self.v2Response(
id: id,
ok: true,
result: [
"machines": [[
"id": vmID,
"link_state": "connected",
"remote_workspaces": [[String: Any]](),
]],
"resources": [[String: Any]](),
]
)
case "workspace.cloud_vm_bind":
let result: [String: Any] = [
"workspace_id": "workspace-cloud",
Expand Down Expand Up @@ -399,12 +424,15 @@ extension CLINotifyProcessIntegrationRegressionTests {
XCTAssertTrue(result.stdout.contains("terminal=term_cloud"), result.stdout)
XCTAssertEqual(
state.commands.compactMap { self.jsonObject($0)?["method"] as? String },
["vm.ssh_info", "vm.cmux_remote_info", "workspace.create", "workspace.cloud_vm_bind", "surface.new_terminal", "workspace.cloud_vm_bind", "workspace.select"]
["vm.ssh_info", "vm.cmux_remote_info", "workspace.create", "workspace.cloud_vm_bind", "surface.catalog", "surface.new_terminal", "workspace.cloud_vm_bind", "workspace.select"]
)
let bindCommands = state.commands
.compactMap { self.jsonObject($0) }
.filter { $0["method"] as? String == "workspace.cloud_vm_bind" }
XCTAssertEqual(bindCommands.count, 2)
guard bindCommands.count == 2 else {
XCTFail("expected two workspace.cloud_vm_bind requests, got \(bindCommands.count)")
return
}
XCTAssertNil((bindCommands[0]["params"] as? [String: Any])?["remote_workspace_id"])
XCTAssertEqual(
(bindCommands[1]["params"] as? [String: Any])?["remote_workspace_id"] as? String,
Expand Down
Loading