Skip to content

Commit

Permalink
fix(connection-storage): store useApplicationLevelProxy flag to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax authored Aug 27, 2024
1 parent 36ab985 commit afa901b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,36 @@ describe('ConnectionStorage', function () {
expect(JSON.parse(content).connectionInfo.id).to.be.equal(id);
});

it('saves a connection with all ConnectionOptions set', async function () {
const id = new UUID().toString();
const connectionOptions: Required<ConnectionInfo['connectionOptions']> = {
connectionString: 'mongodb://localhost:27017/',
sshTunnel: { host: 'localhost', port: 2222, username: 'foobar' },
useApplicationLevelProxy: true,
oidc: {},
fleOptions: { storeCredentials: false },
lookup: () => ({} as any),
};
await connectionStorage.save({
connectionInfo: {
id,
connectionOptions,
},
});
delete (connectionOptions as any).lookup; // intentionally not stored

const content = await fs.readFile(
getConnectionFilePath(tmpDir, id),
'utf-8'
);
expect(
JSON.parse(content).connectionInfo.connectionOptions
).to.deep.equal(connectionOptions);
expect(
(await connectionStorage.load({ id }))?.connectionOptions
).to.deep.equal(connectionOptions);
});

it('saves a connection with arbitrary authMechanism', async function () {
const id = new UUID().toString();
await connectionStorage.save({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const ConnectionSchema: z.Schema<ConnectionWithLegacyProps> = z
useSystemCA: z.boolean().optional(), // Unused but may be present in legacy files
oidc: z.any().optional(),
fleOptions: z.any().optional(),
useApplicationLevelProxy: z.boolean().optional(),
}),
})
.optional(),
Expand Down

0 comments on commit afa901b

Please sign in to comment.