mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
Merge pull request #158 from clems4ever/anonymous-smtp
Allow anonymous user in SMTP notifier
This commit is contained in:
commit
6e3a9494ce
|
@ -73,8 +73,8 @@ export interface GmailNotifierConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmtpNotifierConfiguration {
|
export interface SmtpNotifierConfiguration {
|
||||||
username: string;
|
username?: string;
|
||||||
password: string;
|
password?: string;
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
secure: boolean;
|
secure: boolean;
|
||||||
|
|
|
@ -28,11 +28,15 @@ export class MailSenderBuilder implements IMailSenderBuilder {
|
||||||
host: options.host,
|
host: options.host,
|
||||||
port: options.port,
|
port: options.port,
|
||||||
secure: options.secure, // upgrade later with STARTTLS
|
secure: options.secure, // upgrade later with STARTTLS
|
||||||
auth: {
|
};
|
||||||
|
|
||||||
|
if (options.username && options.password) {
|
||||||
|
smtpOptions.auth = {
|
||||||
user: options.username,
|
user: options.username,
|
||||||
pass: options.password
|
pass: options.password
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
return new MailSender(smtpOptions, this.nodemailer);
|
return new MailSender(smtpOptions, this.nodemailer);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,24 +25,41 @@ describe("test MailSenderBuilder", function() {
|
||||||
Assert.equal(createTransportStub.getCall(0).args[0].auth.pass, "pass_gmail");
|
Assert.equal(createTransportStub.getCall(0).args[0].auth.pass, "pass_gmail");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create a smtp mail sender", function() {
|
describe("build smtp mail sender", function() {
|
||||||
const mailSenderBuilder = new MailSenderBuilder(Nodemailer);
|
it("should create a smtp mail sender with authenticated user", function() {
|
||||||
mailSenderBuilder.buildSmtp({
|
const mailSenderBuilder = new MailSenderBuilder(Nodemailer);
|
||||||
host: "mail.example.com",
|
mailSenderBuilder.buildSmtp({
|
||||||
password: "password",
|
host: "mail.example.com",
|
||||||
port: 25,
|
password: "password",
|
||||||
secure: true,
|
port: 25,
|
||||||
username: "user",
|
secure: true,
|
||||||
sender: "admin@example.com"
|
username: "user",
|
||||||
|
sender: "admin@example.com"
|
||||||
|
});
|
||||||
|
Assert.deepStrictEqual(createTransportStub.getCall(0).args[0], {
|
||||||
|
host: "mail.example.com",
|
||||||
|
auth: {
|
||||||
|
pass: "password",
|
||||||
|
user: "user"
|
||||||
|
},
|
||||||
|
port: 25,
|
||||||
|
secure: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Assert.deepStrictEqual(createTransportStub.getCall(0).args[0], {
|
|
||||||
host: "mail.example.com",
|
it("should create a smtp mail sender with anonymous user", function() {
|
||||||
auth: {
|
const mailSenderBuilder = new MailSenderBuilder(Nodemailer);
|
||||||
pass: "password",
|
mailSenderBuilder.buildSmtp({
|
||||||
user: "user"
|
host: "mail.example.com",
|
||||||
},
|
port: 25,
|
||||||
port: 25,
|
secure: true,
|
||||||
secure: true,
|
sender: "admin@example.com"
|
||||||
|
});
|
||||||
|
Assert.deepStrictEqual(createTransportStub.getCall(0).args[0], {
|
||||||
|
host: "mail.example.com",
|
||||||
|
port: 25,
|
||||||
|
secure: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user