Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): keep an unreadable connection catalog instead of overwriting it #23488

Closedrbansal42(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/23488/headopened View on GitHub

Showing 2 changed files with 196 additions and 1 deletion.

x
0 of 2 viewed, 2 left
120 additions and 0 deletionsapps/desktop/src/app/DesktopConnectionCatalogStore.test.tsModified
View file
@@ -301,4 +301,124 @@
assert.deepStrictEqual(yield* store.get, Option.some('{"schemaVersion":1,"targets":[]}'));
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
+​
+ const emptyCatalog =
+ '{"schemaVersion":1,"targets":[],"profiles":[],"credentials":[],"remoteDpopTokens":[],"disabledEnvironmentIds":[]}';
+ const savedCatalog = emptyCatalog.replace(
+ '"disabledEnvironmentIds":[]',
+ '"disabledEnvironmentIds":["environment-1"]',
+ );
+​
+ const savedCatalogFiles = Effect.fn("test.savedCatalogFiles")(function* (stateDir: string) {
+ const fileSystem = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const names = yield* fileSystem.readDirectory(stateDir);
+ return yield* Effect.forEach(
+ names.filter((name) => name.startsWith("connection-catalog.json.")).toSorted(),
+ (name) => fileSystem.readFileString(path.join(stateDir, name)),
+ );
+ });
+​
+ it.effect("keeps an undecryptable catalog when a new catalog is saved over it", () =>
+ Effect.gen(function* () {
+ const path = yield* Path.Path;
+ const fileSystem = yield* FileSystem.FileSystem;
+ const baseDir = yield* fileSystem.makeTempDirectoryScoped({
+ prefix: "t3-desktop-connection-catalog-test-",
+ });
+ const stateDir = path.join(baseDir, "userdata");