Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

onboarding.test.ts

648 lines23.6 KB

1import {
2 AuthAdministrativeScopes,
3 AuthStandardClientScopes,
4 EnvironmentId,
5 type AuthEnvironmentScope,
6 ORCHESTRATION_PROTOCOL_VERSION,
7} from "@t3tools/contracts";
8import { describe, expect, it } from "@effect/vitest";
9import * as Effect from "effect/Effect";
10import * as Layer from "effect/Layer";
11import * as Option from "effect/Option";
12import * as Stream from "effect/Stream";
13import * as SubscriptionRef from "effect/SubscriptionRef";
14​
15import * as RpcHttp from "../rpc/http.ts";
16import * as ClientCapabilities from "../platform/capabilities.ts";
17import * as Persistence from "../platform/persistence.ts";
18import { fetchRemoteSessionState } from "../authorization/remote.ts";
19import {
20 BearerConnectionCredential,
21 BearerConnectionProfile,
22 BearerConnectionRegistration,
23 PrimaryConnectionRegistration,
24} from "./catalog.ts";
25import * as Connectivity from "./connectivity.ts";
26import * as ConnectionCredentialStore from "./credentialStore.ts";
27import * as ConnectionDriver from "./driver.ts";
28import {
29 BearerConnectionTarget,
30 ConnectionBlockedError,
31 PrimaryConnectionTarget,
32} from "./model.ts";
33import * as Onboarding from "./onboarding.ts";
34import {
35 prepareBearerConnectionUpdate,
36 preparePairingRegistration,
37 prepareSshRegistration,
38} from "./onboarding.ts";
39import * as EnvironmentRegistry from "./registry.ts";
40import * as ConnectionProfileStore from "./profileStore.ts";
41import * as ConnectionWakeups from "./wakeups.ts";
42​
43const layerClientPresentation = Layer.succeed(
44 ClientCapabilities.ClientPresentation,
45 ClientCapabilities.ClientPresentation.of({
46 metadata: {
47 label: "T3 Code Test",
48 deviceType: "desktop",
49 os: "Test OS",
50 },
51 }),
52);
53​
54function layerPairingHttp(
55 calls: Array<{ readonly url: string; readonly init: RequestInit }>,
56 options?: {
57 readonly failDescriptor?: boolean;
58 readonly failExchange?: boolean;
59 readonly protocolVersion?: number;
60 readonly selfUpdate?: boolean;
61 readonly grantScopes?: ReadonlyArray<AuthEnvironmentScope>;
62 },
63) {
64 const grantScopes = options?.grantScopes ?? AuthStandardClientScopes;
65 let sessionScopes: ReadonlyArray<string> = [];
66 const fetchFn = ((input, init = {}) => {
67 const url = String(input);
68 calls.push({ url, init });
69​
70 if (url.endsWith("/.well-known/t3/environment")) {
71 if (options?.failDescriptor === true) {
72 return Promise.resolve(
73 Response.json({ message: "descriptor unavailable" }, { status: 503 }),
74 );
75 }
76 return Promise.resolve(
77 Response.json({
78 environmentId: "environment-paired",
79 label: "Paired environment",
80 platform: {
81 os: "linux",
82 arch: "x64",
83 },
84 serverVersion: "0.0.0-test",
85 orchestrationProtocolVersion: options?.protocolVersion ?? ORCHESTRATION_PROTOCOL_VERSION,
86 capabilities: {
87 repositoryIdentity: true,
88 ...(options?.selfUpdate === true ? { serverSelfUpdate: "boot-service" } : {}),
89 },
90 }),
91 );
92 }
93​
94 if (url.endsWith("/oauth/token")) {
95 if (options?.failExchange === true) {
96 return Promise.resolve(
97 Response.json(
98 {
99 _tag: "EnvironmentAuthInvalidError",
100 code: "auth_invalid",
101 reason: "invalid_credential",
102 traceId: "trace-pairing-test",
103 },
104 { status: 401 },
105 ),
106 );
107 }
108 const body =
109 init.body instanceof Uint8Array ? new TextDecoder().decode(init.body) : String(init.body);
110 const requestedScope = new URLSearchParams(body).get("scope");
111 sessionScopes = requestedScope === null ? grantScopes : requestedScope.split(" ");
112 if (!sessionScopes.every((scope) => grantScopes.some((granted) => granted === scope))) {
113 return Promise.resolve(
114 Response.json(
115 {
116 _tag: "EnvironmentRequestInvalidError",
117 code: "invalid_request",
118 reason: "scope_not_granted",
119 traceId: "pairing-scope-test",
120 },
121 { status: 400 },
122 ),
123 );
124 }
125 return Promise.resolve(
126 Response.json({
127 access_token: "bearer-token",
128 issued_token_type: "urn:ietf:params:oauth:token-type:access_token",
129 token_type: "Bearer",
130 expires_in: 3600,
131 scope: sessionScopes.join(" "),
132 }),
133 );
134 }
135​
136 if (url.endsWith("/api/auth/session")) {
137 return Promise.resolve(
138 Response.json({
139 authenticated: true,
140 auth: {
141 policy: "remote-reachable",
142 bootstrapMethods: ["one-time-token"],
143 sessionMethods: ["bearer-access-token"],
144 sessionCookieName: "t3_session",
145 },
146 scopes: sessionScopes,
147 sessionMethod: "bearer-access-token",
148 }),
149 );
150 }
151​
152 return Promise.reject(new Error(`Unexpected request: ${url}`));
153 }) satisfies typeof fetch;
154​
155 return RpcHttp.layerRemoteHttpClient(fetchFn);
157​
158function layerPairingOnboarding(options?: Parameters<typeof layerPairingHttp>[1]) {
159 const dependencies = Layer.mergeAll(
160 layerClientPresentation,
161 layerPairingHttp([], options),
162 Layer.mock(Persistence.ConnectionTargetStore)({
163 list: Effect.succeed([]),
164 listDisabled: Effect.succeed([]),
165 }),
166 Layer.mock(Persistence.ConnectionRegistrationStore)({
167 register: () => Effect.void,
168 setEnabled: () => Effect.void,
169 }),
170 Layer.mock(Persistence.EnvironmentCacheStore)({}),
171 Layer.mock(ConnectionProfileStore.ConnectionProfileStore)({}),
172 Layer.mock(ConnectionCredentialStore.ConnectionCredentialStore)({}),
173 Layer.mock(ClientCapabilities.SshEnvironmentGateway)({}),
174 Layer.succeed(
175 Connectivity.Connectivity,
176 Connectivity.Connectivity.of({ status: Effect.succeed("online"), changes: Stream.never }),
177 ),
178 Layer.mock(ConnectionDriver.ConnectionDriver)({ connect: () => Effect.never }),
179 Layer.succeed(
180 ConnectionWakeups.ConnectionWakeups,
181 ConnectionWakeups.ConnectionWakeups.of({ changes: Stream.never }),
182 ),
183 );
184 return Onboarding.layer.pipe(
185 Layer.provideMerge(EnvironmentRegistry.layer.pipe(Layer.provideMerge(dependencies))),
186 );
188​
189const PAIRED_ENVIRONMENT_ID = EnvironmentId.make("environment-paired");
190const PAIRING_INPUT = { host: "remote.example.test", pairingCode: "pairing-token" };
191const PAIRED_PROFILE = new BearerConnectionProfile({
192 connectionId: "bearer:environment-paired:https://remote.example.test",
193 environmentId: PAIRED_ENVIRONMENT_ID,
194 label: "Paired environment",
195 httpBaseUrl: "https://remote.example.test/",
196 wsBaseUrl: "wss://remote.example.test/",
197});
198const UNSUPPORTED_ERROR = new ConnectionBlockedError({
199 reason: "unsupported",
200 detail: "The saved server used an incompatible orchestration protocol.",
201});
202​
203const registerSwitchedOffEnvironment = Effect.gen(function* () {
204 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
205 const registration = new BearerConnectionRegistration({
206 target: new BearerConnectionTarget({
207 environmentId: PAIRED_ENVIRONMENT_ID,
208 connectionId: PAIRED_PROFILE.connectionId,
209 label: "Old label",
210 }),
211 // Keep the endpoint unchanged: registration alone must retain the stale reason.
212 profile: new BearerConnectionProfile({ ...PAIRED_PROFILE, label: "Old label" }),
213 credential: new BearerConnectionCredential({ token: "old-token" }),
214 });
215 yield* registry.register(registration);
216 yield* registry.setEnabled(PAIRED_ENVIRONMENT_ID, false);
217 yield* registry.setCompatibility(PAIRED_ENVIRONMENT_ID, UNSUPPORTED_ERROR);
218 const entries = yield* SubscriptionRef.get(registry.entries);
219 expect(entries.get(PAIRED_ENVIRONMENT_ID)).toEqual({
220 target: registration.target,
221 profile: Option.some(registration.profile),
222 enabled: false,
223 unsupportedReason: UNSUPPORTED_ERROR.message,
224 });
225 return entries;
226});
227​
228describe("connection onboarding", () => {
229 it.effect("prepares a persisted bearer registration from pairing details", () =>
230 Effect.gen(function* () {
231 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
232 const registration = yield* preparePairingRegistration({
233 host: "remote.example.test",
234 pairingCode: "pairing-token",
235 }).pipe(Effect.provide(Layer.mergeAll(layerClientPresentation, layerPairingHttp(calls))));
236​
237 expect(registration).toMatchObject({
238 _tag: "BearerConnectionRegistration",
239 target: {
240 environmentId: "environment-paired",
241 label: "Paired environment",
242 connectionId: "bearer:environment-paired:https://remote.example.test",
243 },
244 profile: {
245 environmentId: "environment-paired",
246 label: "Paired environment",
247 connectionId: "bearer:environment-paired:https://remote.example.test",
248 httpBaseUrl: "https://remote.example.test/",
249 wsBaseUrl: "wss://remote.example.test/",
250 },
251 credential: {
252 token: "bearer-token",
253 },
254 });
255 expect(calls.map((call) => call.url)).toEqual([
256 "https://remote.example.test/.well-known/t3/environment",
257 "https://remote.example.test/oauth/token",
258 ]);
259​
260 const tokenRequest = calls.find((call) => call.url.endsWith("/oauth/token"));
261 const tokenBody =
262 tokenRequest?.init.body instanceof Uint8Array
263 ? new TextDecoder().decode(tokenRequest.init.body)
264 : String(tokenRequest?.init.body);
265 const tokenParams = new URLSearchParams(tokenBody);
266 expect(tokenParams.get("subject_token")).toBe("pairing-token");
267 expect(tokenParams.has("scope")).toBe(false);
268 expect(tokenParams.get("client_label")).toBe("T3 Code Test");
269 expect(tokenParams.get("client_device_type")).toBe("desktop");
270 expect(tokenParams.get("client_os")).toBe("Test OS");
271 }),
272 );
273​
274 it.effect("turns a switched-off environment back on when it is paired again", () =>
275 Effect.gen(function* () {
276 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
277 const onboarding = yield* Onboarding.ConnectionOnboarding;
278 yield* registerSwitchedOffEnvironment;
279​
280 const environmentId = yield* onboarding.registerPairing(PAIRING_INPUT);
281​
282 expect(environmentId).toBe(PAIRED_ENVIRONMENT_ID);
283 const entries = yield* SubscriptionRef.get(registry.entries);
284 const entry = entries.get(environmentId);
285 expect(entries.size).toBe(1);
286 expect(entry?.enabled).toBe(true);
287 expect(entry?.unsupportedReason).toBeUndefined();
288 expect(entry?.profile).toEqual(Option.some(PAIRED_PROFILE));
289 expect(entry?.target).toEqual(
290 new BearerConnectionTarget({
291 environmentId,
292 connectionId: PAIRED_PROFILE.connectionId,
293 label: PAIRED_PROFILE.label,
294 }),
295 );
296 }).pipe(Effect.provide(layerPairingOnboarding())),
297 );
298​
299 it.effect(
300 "re-pairs an outdated self-updatable environment so its connection can be rechecked",
301 () =>
302 Effect.gen(function* () {
303 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
304 const onboarding = yield* Onboarding.ConnectionOnboarding;
305 yield* registerSwitchedOffEnvironment;
306 yield* registry.setCompatibility(
307 PAIRED_ENVIRONMENT_ID,
308 new ConnectionBlockedError({
309 reason: "unsupported",
310 detail: "The saved server needs an update.",
311 serverUpdateRequired: true,
312 }),
313 );
314 expect(
315 (yield* SubscriptionRef.get(registry.entries)).get(PAIRED_ENVIRONMENT_ID),
316 ).toMatchObject({
317 enabled: false,
318 serverUpdateRequired: true,
319 });
320​
321 const environmentId = yield* onboarding.registerPairing(PAIRING_INPUT);
322​
323 expect(environmentId).toBe(PAIRED_ENVIRONMENT_ID);
324 const entry = (yield* SubscriptionRef.get(registry.entries)).get(environmentId);
325 expect(entry?.enabled).toBe(true);
326 expect(entry?.unsupportedReason).toBeUndefined();
327 expect(entry?.serverUpdateRequired).toBeUndefined();
328 expect(entry?.profile).toEqual(Option.some(PAIRED_PROFILE));
329 }).pipe(
330 Effect.provide(
331 layerPairingOnboarding({
332 protocolVersion: ORCHESTRATION_PROTOCOL_VERSION - 1,
333 selfUpdate: true,
334 }),
335 ),
336 ),
337 );
338​
339 it.effect("registers an enabled environment on first-time pairing", () =>
340 Effect.gen(function* () {
341 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
342 const onboarding = yield* Onboarding.ConnectionOnboarding;
343 expect((yield* SubscriptionRef.get(registry.entries)).size).toBe(0);
344​
345 const environmentId = yield* onboarding.registerPairing(PAIRING_INPUT);
346​
347 expect(environmentId).toBe(PAIRED_ENVIRONMENT_ID);
348 const entries = yield* SubscriptionRef.get(registry.entries);
349 const entry = entries.get(environmentId);
350 expect(entries.size).toBe(1);
351 expect(entry?.enabled).toBe(true);
352 expect(entry?.unsupportedReason).toBeUndefined();
353 expect(entry?.profile).toEqual(Option.some(PAIRED_PROFILE));
354 }).pipe(Effect.provide(layerPairingOnboarding())),
355 );
356​
357 it.effect("leaves a platform-managed environment untouched when its id is paired", () =>
358 Effect.gen(function* () {
359 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
360 const onboarding = yield* Onboarding.ConnectionOnboarding;
361 yield* registry.registerPlatform(
362 new PrimaryConnectionRegistration({
363 target: new PrimaryConnectionTarget({
364 environmentId: PAIRED_ENVIRONMENT_ID,
365 label: "Host environment",
366 httpBaseUrl: "http://127.0.0.1:3773",
367 wsBaseUrl: "ws://127.0.0.1:3773",
368 }),
369 }),
370 );
371 yield* registry.setCompatibility(PAIRED_ENVIRONMENT_ID, UNSUPPORTED_ERROR);
372 const before = yield* SubscriptionRef.get(registry.entries);
373 expect(before.get(PAIRED_ENVIRONMENT_ID)?.enabled).toBe(false);
374​
375 const environmentId = yield* onboarding.registerPairing(PAIRING_INPUT);
376​
377 expect(environmentId).toBe(PAIRED_ENVIRONMENT_ID);
378 const after = yield* SubscriptionRef.get(registry.entries);
379 expect(after).toEqual(before);
380 expect(after.get(PAIRED_ENVIRONMENT_ID)?.unsupportedReason).toBe(UNSUPPORTED_ERROR.message);
381 }).pipe(Effect.provide(layerPairingOnboarding())),
382 );
383​
384 it.effect("leaves a switched-off environment unchanged when the pairing exchange fails", () =>
385 Effect.gen(function* () {
386 const registry = yield* EnvironmentRegistry.EnvironmentRegistry;
387 const onboarding = yield* Onboarding.ConnectionOnboarding;
388 const before = yield* registerSwitchedOffEnvironment;
389​
390 const error = yield* onboarding.registerPairing(PAIRING_INPUT).pipe(Effect.flip);
391​
392 expect(error).toMatchObject({
393 _tag: "ConnectionBlockedError",
394 reason: "authentication",
395 traceId: "trace-pairing-test",
396 });
397 const after = yield* SubscriptionRef.get(registry.entries);
398 expect(after).toEqual(before);
399 expect(after.get(PAIRED_ENVIRONMENT_ID)?.enabled).toBe(false);
400 expect(after.get(PAIRED_ENVIRONMENT_ID)?.unsupportedReason).toBe(UNSUPPORTED_ERROR.message);
401 }).pipe(Effect.provide(layerPairingOnboarding({ failExchange: true }))),
402 );
403​
404 it.effect("rejects an incompatible server without consuming the pairing credential", () =>
405 Effect.gen(function* () {
406 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
407 const error = yield* preparePairingRegistration({
408 host: "remote.example.test",
409 pairingCode: "pairing-token",
410 }).pipe(
411 Effect.provide(
412 Layer.mergeAll(
413 layerClientPresentation,
414 layerPairingHttp(calls, { protocolVersion: ORCHESTRATION_PROTOCOL_VERSION + 1 }),
415 ),
416 ),
417 Effect.flip,
418 );
419 expect(error).toMatchObject({ reason: "unsupported" });
420 expect(calls.map((call) => call.url)).toEqual([
421 "https://remote.example.test/.well-known/t3/environment",
422 ]);
423 }),
424 );
425 it.effect.each([
426 { label: "read-only", scopes: ["orchestration:read"] },
427 { label: "administrative", scopes: AuthAdministrativeScopes },
428 ] as const)("preserves the $label grant when pairing a remote environment", ({ scopes }) =>
429 Effect.gen(function* () {
430 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
431 const httpLayer = layerPairingHttp(calls, { grantScopes: scopes });
432 const registration = yield* preparePairingRegistration({
433 host: "remote.example.test",
434 pairingCode: "pairing-token",
435 }).pipe(Effect.provide(Layer.mergeAll(layerClientPresentation, httpLayer)));
436​
437 const session = yield* fetchRemoteSessionState({
438 httpBaseUrl: registration.profile.httpBaseUrl,
439 bearerToken: registration.credential.token,
440 }).pipe(Effect.provide(httpLayer));
441​
442 expect(session.authenticated).toBe(true);
443 expect(session.scopes).toEqual(scopes);
444 }),
445 );
446​
447 it.effect("refuses to add a route that reaches a different machine, keeping the code", () =>
448 Effect.gen(function* () {
449 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
450 const error = yield* preparePairingRegistration({
451 host: "remote.example.test",
452 pairingCode: "pairing-token",
453 expectedEnvironmentId: EnvironmentId.make("some-other-machine"),
454 }).pipe(
455 Effect.provide(Layer.mergeAll(layerClientPresentation, layerPairingHttp(calls))),
456 Effect.flip,
457 );
458 expect(error).toMatchObject({ reason: "configuration" });
459 expect(error.message).toContain("different machine");
460 expect(calls.map((call) => call.url)).toEqual([
461 "https://remote.example.test/.well-known/t3/environment",
462 ]);
463 }),
464 );
465​
466 it.effect("pairs an outdated server so it can be updated from this client", () =>
467 Effect.gen(function* () {
468 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
469 const registration = yield* preparePairingRegistration({
470 host: "remote.example.test",
471 pairingCode: "pairing-token",
472 }).pipe(
473 Effect.provide(
474 Layer.mergeAll(
475 layerClientPresentation,
476 layerPairingHttp(calls, {
477 protocolVersion: ORCHESTRATION_PROTOCOL_VERSION - 1,
478 selfUpdate: true,
479 }),
480 ),
481 ),
482 );
483 expect(registration.target.environmentId).toBe("environment-paired");
484 expect(calls.map((call) => call.url)).toContain("https://remote.example.test/oauth/token");
485 }),
486 );
487​
488 it.effect("refuses an outdated server that cannot update itself", () =>
489 Effect.gen(function* () {
490 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
491 const error = yield* preparePairingRegistration({
492 host: "remote.example.test",
493 pairingCode: "pairing-token",
494 }).pipe(
495 Effect.provide(
496 Layer.mergeAll(
497 layerClientPresentation,
498 layerPairingHttp(calls, { protocolVersion: ORCHESTRATION_PROTOCOL_VERSION - 1 }),
499 ),
500 ),
501 Effect.flip,
502 );
503 expect(error).toMatchObject({ reason: "unsupported" });
504 expect(error).not.toHaveProperty("serverUpdateRequired");
505 expect(calls.map((call) => call.url)).toEqual([
506 "https://remote.example.test/.well-known/t3/environment",
507 ]);
508 }),
509 );
510​
511 it.effect("does not consume a pairing credential when descriptor discovery fails", () =>
512 Effect.gen(function* () {
513 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
514​
515 yield* preparePairingRegistration({
516 host: "remote.example.test",
517 pairingCode: "pairing-token",
518 }).pipe(
519 Effect.provide(
520 Layer.mergeAll(
521 layerClientPresentation,
522 layerPairingHttp(calls, { failDescriptor: true }),
523 ),
524 ),
525 Effect.flip,
526 );
527​
528 expect(calls.map((call) => call.url)).toEqual([
529 "https://remote.example.test/.well-known/t3/environment",
530 ]);
531 }),
532 );
533​
534 it.effect("rejects invalid pairing details before making a request", () =>
535 Effect.gen(function* () {
536 const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
537 const error = yield* preparePairingRegistration({
538 host: "",
539 pairingCode: "",
540 }).pipe(
541 Effect.provide(Layer.mergeAll(layerClientPresentation, layerPairingHttp(calls))),
542 Effect.flip,
543 );
544​
545 expect(error).toMatchObject({
546 _tag: "ConnectionBlockedError",
547 reason: "configuration",
548 message: "Enter a backend URL.",
549 });
550 expect(calls).toEqual([]);
551 }),
552 );
553​
554 it.effect("updates bearer metadata while preserving the credential and identity", () =>
555 Effect.gen(function* () {
556 const environmentId = EnvironmentId.make("environment-paired");
557 const registration = yield* prepareBearerConnectionUpdate({
558 input: {
559 environmentId,
560 label: " Renamed environment ",
561 httpBaseUrl: "http://100.65.180.100:3773/path",
562 },
563 entry: Option.some({
564 target: new BearerConnectionTarget({
565 environmentId,
566 label: "Old label",
567 connectionId: "bearer:environment-paired",
568 }),
569 profile: Option.some(
570 new BearerConnectionProfile({
571 connectionId: "bearer:environment-paired",
572 environmentId,
573 label: "Old label",
574 httpBaseUrl: "http://old.example.test/",
575 wsBaseUrl: "ws://old.example.test/",
576 }),
577 ),
578 enabled: true,
579 }),
580 credential: Option.some(new BearerConnectionCredential({ token: "bearer-token" })),
581 });
582​
583 expect(registration).toMatchObject({
584 target: {
585 environmentId,
586 label: "Renamed environment",
587 connectionId: "bearer:environment-paired",
588 },
589 profile: {
590 environmentId,
591 label: "Renamed environment",
592 httpBaseUrl: "http://100.65.180.100:3773/",
593 wsBaseUrl: "ws://100.65.180.100:3773/",
594 },
595 credential: { token: "bearer-token" },
596 });
597 }),
598 );
599​
600 it.effect("prepares an SSH registration from the provisioned platform environment", () =>
601 Effect.gen(function* () {
602 const target = {
603 alias: "devbox",
604 hostname: "devbox.example.test",
605 username: "developer",
606 port: 22,
607 };
608 const registration = yield* prepareSshRegistration({
609 target,
610 }).pipe(
611 Effect.provideService(
612 ClientCapabilities.SshEnvironmentGateway,
613 ClientCapabilities.SshEnvironmentGateway.of({
614 provision: () =>
615 Effect.succeed({
616 environmentId: EnvironmentId.make("environment-ssh"),
617 label: "Remote development box",
618 bootstrap: {
619 target,
620 httpBaseUrl: "http://127.0.0.1:3201",
621 wsBaseUrl: "ws://127.0.0.1:3201",
622 pairingToken: "pairing-token",
623 },
624 bearerToken: "bearer-token",
625 }),
626 prepare: () => Effect.die("unused"),
627 disconnect: () => Effect.die("unused"),
628 }),
629 ),
630 );
631​
632 expect(registration).toMatchObject({
633 _tag: "SshConnectionRegistration",
634 target: {
635 environmentId: "environment-ssh",
636 label: "Remote development box",
637 connectionId: 'ssh:environment-ssh:["devbox","devbox.example.test","developer",22]',
638 },
639 profile: {
640 environmentId: "environment-ssh",
641 label: "Remote development box",
642 connectionId: 'ssh:environment-ssh:["devbox","devbox.example.test","developer",22]',
643 target,
644 },
645 });
646 }),
647 );
648});