mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
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:
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user