-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: generate test connections COMPASS-7546 (#25)
* generate test connections * Update scripts/generate-connections.js Co-authored-by: Rhys <[email protected]>
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
await 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(); |