Skip to content

Commit afa901b

Browse files
authored
fix(connection-storage): store useApplicationLevelProxy flag to disk COMPASS-8219 (#6158)
1 parent 36ab985 commit afa901b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/connection-storage/src/compass-main-connection-storage.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,36 @@ describe('ConnectionStorage', function () {
786786
expect(JSON.parse(content).connectionInfo.id).to.be.equal(id);
787787
});
788788

789+
it('saves a connection with all ConnectionOptions set', async function () {
790+
const id = new UUID().toString();
791+
const connectionOptions: Required<ConnectionInfo['connectionOptions']> = {
792+
connectionString: 'mongodb://localhost:27017/',
793+
sshTunnel: { host: 'localhost', port: 2222, username: 'foobar' },
794+
useApplicationLevelProxy: true,
795+
oidc: {},
796+
fleOptions: { storeCredentials: false },
797+
lookup: () => ({} as any),
798+
};
799+
await connectionStorage.save({
800+
connectionInfo: {
801+
id,
802+
connectionOptions,
803+
},
804+
});
805+
delete (connectionOptions as any).lookup; // intentionally not stored
806+
807+
const content = await fs.readFile(
808+
getConnectionFilePath(tmpDir, id),
809+
'utf-8'
810+
);
811+
expect(
812+
JSON.parse(content).connectionInfo.connectionOptions
813+
).to.deep.equal(connectionOptions);
814+
expect(
815+
(await connectionStorage.load({ id }))?.connectionOptions
816+
).to.deep.equal(connectionOptions);
817+
});
818+
789819
it('saves a connection with arbitrary authMechanism', async function () {
790820
const id = new UUID().toString();
791821
await connectionStorage.save({

packages/connection-storage/src/compass-main-connection-storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const ConnectionSchema: z.Schema<ConnectionWithLegacyProps> = z
7777
useSystemCA: z.boolean().optional(), // Unused but may be present in legacy files
7878
oidc: z.any().optional(),
7979
fleOptions: z.any().optional(),
80+
useApplicationLevelProxy: z.boolean().optional(),
8081
}),
8182
})
8283
.optional(),

0 commit comments

Comments
 (0)