feat: add more auth providers and cleanup google auth

it's no longer needed to use stunnel ;-)
This commit is contained in:
simon
2020-02-23 20:42:36 +01:00
parent 5e5005cf6b
commit 3f600c664f
22 changed files with 1351 additions and 152 deletions

View File

@@ -0,0 +1,21 @@
import 'mocha';
import { expect } from 'chai';
import * as fs from 'fs';
import { GoogleLDAPAuth } from '../../src/auth/GoogleLDAPAuth';
describe('test google ldap auth', function() {
this.timeout(10000);
it('authenticate against ldap server', async () => {
const auth = new GoogleLDAPAuth({
base: 'dc=hokify,dc=com',
tlsOptions: {
key: fs.readFileSync('./ldap.gsuite.hokify.com.40567.key'),
cert: fs.readFileSync('./ldap.gsuite.hokify.com.40567.crt')
}
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});

View File

@@ -0,0 +1,18 @@
import 'mocha';
import { expect } from 'chai';
import { IMAPAuth } from '../../src/auth/IMAPAuth';
describe('test imap auth', () => {
it('authenticate against imap server', async () => {
const auth = new IMAPAuth({
host: 'imap.gmail.com',
port: 993,
useSecureTransport: true,
validHosts: ['gmail.com']
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});

View File

@@ -0,0 +1,23 @@
import 'mocha';
import { expect } from 'chai';
import * as fs from 'fs';
import { LDAPAuth } from '../../src/auth/LDAPAuth';
describe('test ldap auth', function() {
this.timeout(10000);
it('authenticate against ldap server', async () => {
const auth = new LDAPAuth({
url: 'ldaps://ldap.google.com:636',
base: 'dc=hokify,dc=com',
tlsOptions: {
servername: 'ldap.google.com',
key: fs.readFileSync('./ldap.gsuite.hokify.com.40567.key'),
cert: fs.readFileSync('./ldap.gsuite.hokify.com.40567.crt'),
}
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});

View File

@@ -0,0 +1,18 @@
import 'mocha';
import { expect } from 'chai';
import { SMTPAuth } from '../../src/auth/SMTPAuth';
describe('test smtp auth', () => {
it('authenticate against smtp server', async () => {
const auth = new SMTPAuth({
host: 'smtp.gmail.com',
port: 465,
useSecureTransport: true,
validHosts: ['gmail.com']
});
const result = await auth.authenticate('username', 'password');
expect(result).to.equal(true);
});
});