-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtestConnection.js
More file actions
28 lines (25 loc) · 1.1 KB
/
testConnection.js
File metadata and controls
28 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const { getExternalBrowserUrl, connect } = require('../../reverse_engineering/api');
const logInfo = require('../../reverse_engineering/helpers/logInfo');
const { logDatabaseVersion } = require('../../reverse_engineering/reverseEngineeringService/reverseEngineeringService');
async function getExternalBrowserUrlLocal(connectionInfo, logger, cb, app) {
return getExternalBrowserUrl(connectionInfo, logger, cb, app);
}
async function testConnection(connectionInfo, logger, callback, app) {
try {
logInfo('Test connection', connectionInfo, logger);
if (connectionInfo.authMethod === 'Azure Active Directory (MFA)') {
await getExternalBrowserUrlLocal(connectionInfo, logger, callback, app);
} else {
const client = await connect(connectionInfo, logger, () => {}, app);
await logDatabaseVersion({ client, logger });
}
callback(null);
} catch (error) {
logger.log('error', { message: error.message, stack: error.stack, error }, 'Test connection');
callback({ message: error.message, stack: error.stack });
}
}
module.exports = {
testConnection,
getExternalBrowserUrl: getExternalBrowserUrlLocal,
};