feature: add database and non http credentials test

Add credential testing to Postgres, MySQL, MicrosoftSQL, Redis, FTP, SFTP, IMAP, RabbitMQ and MQTT

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
agobrech
2022-09-01 14:29:15 +02:00
committed by GitHub
parent b5511e5ac7
commit d82e87979d
8 changed files with 438 additions and 3 deletions

View File

@@ -3,8 +3,12 @@ import {
createDeferredPromise,
IBinaryData,
IBinaryKeyData,
ICredentialDataDecryptedObject,
ICredentialsDecrypted,
ICredentialTestFunctions,
IDataObject,
IDeferredPromise,
INodeCredentialTestResult,
INodeExecutionData,
INodeType,
INodeTypeDescription,
@@ -43,6 +47,7 @@ export class EmailReadImap implements INodeType {
{
name: 'imap',
required: true,
testedBy: 'imapConnectionTest',
},
],
properties: [
@@ -171,6 +176,51 @@ export class EmailReadImap implements INodeType {
],
};
methods = {
credentialTest: {
async imapConnectionTest(
this: ICredentialTestFunctions,
credential: ICredentialsDecrypted,
): Promise<INodeCredentialTestResult> {
const credentials = credential.data as ICredentialDataDecryptedObject;
try {
const config: ImapSimpleOptions = {
imap: {
user: credentials.user as string,
password: credentials.password as string,
host: credentials.host as string,
port: credentials.port as number,
tls: credentials.secure as boolean,
authTimeout: 20000,
},
};
const tlsOptions: IDataObject = {};
if (credentials.secure) {
tlsOptions.servername = credentials.host as string;
}
if (!_.isEmpty(tlsOptions)) {
config.imap.tlsOptions = tlsOptions;
}
const conn = imapConnect(config).then(async (conn) => {
return conn;
});
(await conn).getBoxes((err, boxes) => {});
} catch (error) {
console.log(error);
return {
status: 'Error',
message: error.message,
};
}
return {
status: 'OK',
message: 'Connection successful!',
};
},
},
};
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
const credentials = await this.getCredentials('imap');