mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
78f6028c1b
Previously, logs were not very friendly and it was hard to track a request because of the lack of request ID. Now every log message comes with a header containing: method, path request ID, session ID, IP of the user, date. Moreover, the configurations displayed in the logs have their secrets hidden from this commit.
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import * as sinon from "sinon";
|
|
import * as assert from "assert";
|
|
import BluebirdPromise = require("bluebird");
|
|
|
|
import { MailSenderStub } from "../mocks/notifiers/MailSenderStub";
|
|
import GMailNotifier = require("../../src/lib/notifiers/GMailNotifier");
|
|
|
|
|
|
describe("test gmail notifier", function () {
|
|
it("should send an email to given user", function () {
|
|
const mailSender = new MailSenderStub();
|
|
const options = {
|
|
username: "user_gmail",
|
|
password: "pass_gmail"
|
|
};
|
|
|
|
mailSender.sendStub.returns(BluebirdPromise.resolve());
|
|
const sender = new GMailNotifier.GMailNotifier(options, mailSender);
|
|
const subject = "subject";
|
|
|
|
const identity = {
|
|
userid: "user",
|
|
email: "user@example.com"
|
|
};
|
|
|
|
const url = "http://test.com";
|
|
|
|
return sender.notify(identity, subject, url)
|
|
.then(function () {
|
|
assert.equal(mailSender.sendStub.getCall(0).args[0].to, "user@example.com");
|
|
assert.equal(mailSender.sendStub.getCall(0).args[0].subject, "subject");
|
|
return BluebirdPromise.resolve();
|
|
});
|
|
});
|
|
|
|
it("should fail while sending an email", function () {
|
|
const mailSender = new MailSenderStub();
|
|
const options = {
|
|
username: "user_gmail",
|
|
password: "pass_gmail"
|
|
};
|
|
|
|
mailSender.sendStub.returns(BluebirdPromise.reject(new Error("Failed to send mail")));
|
|
const sender = new GMailNotifier.GMailNotifier(options, mailSender);
|
|
const subject = "subject";
|
|
|
|
const identity = {
|
|
userid: "user",
|
|
email: "user@example.com"
|
|
};
|
|
|
|
const url = "http://test.com";
|
|
|
|
return sender.notify(identity, subject, url)
|
|
.then(function () {
|
|
return BluebirdPromise.reject(new Error());
|
|
}, function() {
|
|
return BluebirdPromise.resolve();
|
|
});
|
|
});
|
|
});
|