authelia/server/test/notifiers/NotifierFactory.test.ts

43 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-05-20 07:49:05 +00:00
import * as sinon from "sinon";
import * as BluebirdPromise from "bluebird";
import * as assert from "assert";
import { NotifierFactory } from "../../src/lib/notifiers/NotifierFactory";
import { EMailNotifier } from "../../src/lib/notifiers/EMailNotifier";
import { SmtpNotifier } from "../../src/lib/notifiers/SmtpNotifier";
import { MailSenderBuilderStub } from "../mocks/notifiers/MailSenderBuilderStub";
2017-05-20 07:49:05 +00:00
describe("test notifier factory", function () {
let mailSenderBuilderStub: MailSenderBuilderStub;
it("should build a Email Notifier", function () {
2017-05-20 07:49:05 +00:00
const options = {
email: {
2017-05-20 07:49:05 +00:00
username: "abc",
password: "password",
sender: "admin@example.com",
service: "gmail"
2017-05-20 07:49:05 +00:00
}
};
mailSenderBuilderStub = new MailSenderBuilderStub();
assert(NotifierFactory.build(options, mailSenderBuilderStub) instanceof EMailNotifier);
2017-05-20 07:49:05 +00:00
});
it("should build a SMTP Notifier", function () {
2017-05-20 07:49:05 +00:00
const options = {
2017-09-24 18:55:11 +00:00
smtp: {
username: "user",
password: "pass",
secure: true,
host: "localhost",
port: 25,
sender: "admin@example.com"
2017-05-20 07:49:05 +00:00
}
};
mailSenderBuilderStub = new MailSenderBuilderStub();
assert(NotifierFactory.build(options, mailSenderBuilderStub) instanceof SmtpNotifier);
2017-05-20 07:49:05 +00:00
});
});