From 3c11f0acda597be75bfe905d4764c1a69bfc3a54 Mon Sep 17 00:00:00 2001 From: badrAZ Date: Wed, 9 Nov 2016 14:55:08 +0100 Subject: [PATCH] feat(test): this plugin is now testable (#9) See vatesfr/xo-web#1749 --- .../xo-server-transport-email/src/index.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/xo-server-transport-email/src/index.js b/packages/xo-server-transport-email/src/index.js index fb425abee..2e8255d4c 100644 --- a/packages/xo-server-transport-email/src/index.js +++ b/packages/xo-server-transport-email/src/index.js @@ -93,6 +93,20 @@ export const configurationSchema = { required: ['from', 'transport'] } +export const testSchema = { + type: 'object', + + properties: { + to: { + type: 'string', + description: 'recipient of the test mail' + } + }, + + additionalProperties: false, + required: ['to'] +} + // =================================================================== class TransportEmailPlugin { @@ -141,6 +155,16 @@ class TransportEmailPlugin { this._unset() } + test ({to}) { + return this._sendEmail({ + to, + subject: '[Xen Orchestra] Test of transport-email plugin', + markdown: `Hi there, + +The transport-email plugin for Xen Orchestra server seems to be working fine, nicely done :)` + }) + } + _sendEmail ({ from = this._conf.from, to, cc, bcc,