smartacme/test/test.ts

45 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

2019-01-06 19:41:21 +00:00
import { tap, expect } from '@pushrocks/tapbundle';
2019-01-08 19:45:35 +00:00
import { Qenv } from '@pushrocks/qenv';
const testQenv = new Qenv('./', './.nogit/');
2016-11-01 17:27:57 +00:00
import * as smartacme from '../ts/index';
2017-01-22 20:50:04 +00:00
let smartAcmeInstance: smartacme.SmartAcme;
2016-11-01 17:27:57 +00:00
2018-08-12 18:58:59 +00:00
tap.test('should create a valid instance of SmartAcme', async () => {
2019-01-08 19:45:35 +00:00
smartAcmeInstance = new smartacme.SmartAcme({
2019-01-06 19:41:21 +00:00
accountEmail: 'domains@lossless.org',
accountPrivateKey: null,
2019-01-08 23:01:01 +00:00
mongoDescriptor: {
mongoDbName: testQenv.getEnvVarOnDemand('MONGODB_DATABASE'),
mongoDbPass: testQenv.getEnvVarOnDemand('MONGODB_PASSWORD'),
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGODB_URL')
},
2019-01-06 19:41:21 +00:00
removeChallenge: async (...args) => {
console.log(args);
},
setChallenge: async (...args) => {
console.log(args);
2019-01-08 19:45:35 +00:00
},
2019-01-08 23:01:01 +00:00
validateRemoteRequest: async () => {
return true;
2019-01-08 19:45:35 +00:00
}
2019-01-06 19:41:21 +00:00
});
2019-01-08 19:45:35 +00:00
await smartAcmeInstance.init();
2019-01-08 23:01:01 +00:00
// await smartAcmeInstance.getCertificateForDomain('bleu.de');
2018-08-12 18:58:59 +00:00
});
2017-01-22 20:50:04 +00:00
2019-01-13 01:10:00 +00:00
tap.test('certmatcher should correctly match domains', async () => {
const certMatcherMod = await import('../ts/smartacme.classes.certmatcher');
const certMatcher = new certMatcherMod.CertMatcher();
const matchedCert = certMatcher.getCertificateDomainNameByDomainName('level3.level2.level1');
expect(matchedCert).to.equal('level2.level1');
});
2019-01-12 20:06:29 +00:00
tap.test('should stop correctly', async () => {
await smartAcmeInstance.stop();
});
2018-08-12 18:58:59 +00:00
tap.start();