mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-10-09 21:14:00 +00:00
feat: custom email vendor (#130)
* feat: custom email vendor * feat: custom email vendor * feat: custom email vendor * feat: custom email vendor --------- Co-authored-by: Quan HL <quanluuhoang8@gmail.com>
This commit is contained in:
@@ -133,4 +133,14 @@ services:
|
||||
- "3100:3000/tcp"
|
||||
networks:
|
||||
jambonz-api:
|
||||
ipv4_address: 172.58.0.9
|
||||
ipv4_address: 172.58.0.9
|
||||
|
||||
webhook-tts-scaffold:
|
||||
image: jambonz/webhook-tts-test-scaffold:latest
|
||||
ports:
|
||||
- "3101:3000/tcp"
|
||||
volumes:
|
||||
- ./test-apps:/tmp
|
||||
networks:
|
||||
jambonz-api:
|
||||
ipv4_address: 172.58.0.10
|
||||
@@ -0,0 +1,29 @@
|
||||
const test = require('tape');
|
||||
const {emailSimpleText} = require('../lib/utils/email-utils');
|
||||
const bent = require('bent');
|
||||
const getJSON = bent('json')
|
||||
const logger = {
|
||||
debug: () =>{},
|
||||
info: () => {}
|
||||
}
|
||||
|
||||
test('email-test', async(t) => {
|
||||
// Prepare env:
|
||||
process.env.CUSTOM_EMAIL_VENDOR_URL = 'http://127.0.0.1:3101/custom_email_vendor';
|
||||
process.env.CUSTOM_EMAIL_VENDOR_USERNAME = 'USERNAME';
|
||||
process.env.CUSTOM_EMAIL_VENDOR_PASSWORD = 'PASSWORD';
|
||||
|
||||
await emailSimpleText(logger, 'test@gmail.com', 'subject', 'body text');
|
||||
|
||||
const obj = await getJSON(`http://127.0.0.1:3101/lastRequest/custom_email_vendor`);
|
||||
t.ok(obj.headers['Content-Type'] == 'application/json');
|
||||
t.ok(obj.headers.Authorization == 'Basic VVNFUk5BTUU6UEFTU1dPUkQ=');
|
||||
t.ok(obj.body.from == 'jambonz Support <support@jambonz.org>');
|
||||
t.ok(obj.body.to == 'test@gmail.com');
|
||||
t.ok(obj.body.subject == 'subject');
|
||||
t.ok(obj.body.text == 'body text');
|
||||
|
||||
process.env.CUSTOM_EMAIL_VENDOR_URL = null;
|
||||
process.env.CUSTOM_EMAIL_VENDOR_USERNAME = null;
|
||||
process.env.CUSTOM_EMAIL_VENDOR_PASSWORD = null;
|
||||
});
|
||||
@@ -17,4 +17,5 @@ require('./webapp_tests');
|
||||
// require('./homer');
|
||||
require('./call-test');
|
||||
require('./password-settings');
|
||||
require('./email_utils');
|
||||
require('./docker_stop');
|
||||
|
||||
Reference in New Issue
Block a user