Skip to content

Commit

Permalink
generate test connections
Browse files Browse the repository at this point in the history
  • Loading branch information
mabaasit committed Dec 18, 2023
1 parent 0799920 commit b38b1d6
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,9 @@ lib
**/*.js.map
!**/initdb/*.js
!.eslintrc.js
!scripts/generate-connections.js
*.tgz


# Ignore the generated connections
compass-connections.json
72 changes: 72 additions & 0 deletions scripts/generate-connections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const { default: createTestEnvironments } = require('./../src');
const { v4 } = require('uuid');
const path = require('path');
const fs = require('fs/promises');

const FILE_PATH = path.resolve(__dirname, '..', 'compass-connections.json');
const connectionsWithVariants = {
enterprise: ['enterprise'],
ldap: ['ldap'],
scram: [
'scramReadWriteAnyDatabase',
'scramReadWriteAnyDatabaseScramSha1',
'scramReadWriteAnyDatabaseScramSha256',
'scramOnlyScramSha1',
'scramOnlyScramSha256',
'scramEncodedPassword',
'scramPrivilegesOnNonExistingDatabases',
'scramPrivilegesOnNonExistingCollections',
'scramAlternateAuthDb',
],
sharded: ['sharded'],
ssh: [
'sshPassword',
'sshIdentityKey',
'sshIdentityKeyWithPassphrase',
'sshReplicaSetSeedlist',
'sshReplicaSetByReplSetName',
],
tls: [
'tlsUnvalidated',
'tlsServerValidation',
'tlsServerValidationSsh',
'tlsServerAndClientValidation',
'tlsServerAndClientValidationKeyCrt',
'tlsX509',
'tlsX509WithSsh',
],
kerberos: ['kerberos', 'kerberosAlternate', 'kerberosCrossRealm'],
};

function generateConnections() {
const connections = [];
for (const [env, variants] of Object.entries(connectionsWithVariants)) {
const envConnections = createTestEnvironments([env]);
for (const variant of variants) {
connections.push({
id: v4(),
favorite: {
name: variant,
},
connectionOptions: envConnections.getConnectionOptions(variant),
});
}
}
return {
type: 'Compass Connections',
version: 1,
connections,
};
}

async function writeConnections() {
const data = generateConnections();
fs.writeFile(FILE_PATH, JSON.stringify(data, null, 2));
}

/**
* Creates a file with the connections for the Compass app,
* based on the test environments. These connections can be
* directly imported into Compass.
*/
void writeConnections();

0 comments on commit b38b1d6

Please sign in to comment.