smartcert/test/test.ts

49 lines
1.7 KiB
TypeScript
Raw Normal View History

2016-06-21 18:02:57 +00:00
import "typings-test";
import "should";
import {Qenv} from "qenv";
2016-06-28 07:32:01 +00:00
import path = require("path");
2016-07-21 12:58:05 +00:00
import q = require("q");
2016-06-22 11:22:09 +00:00
import {startInstall} from "../dist/install";
import * as cert from "../dist/index";
2016-06-21 19:08:04 +00:00
let testQenv = new Qenv(process.cwd(), process.cwd() + "/.nogit");
2016-06-22 11:22:09 +00:00
let testCert:cert.Cert;
describe("cert",function(){
describe("install",function(){
it("should download letsencrypt.sh",function(done){
this.timeout(5000);
startInstall().then(() => {
done();
})
})
})
describe("Cert",function(){
it("should create a new Cert object from class",function(){
2016-07-13 14:06:16 +00:00
this.timeout(40000);
2016-06-22 11:22:09 +00:00
testCert = new cert.Cert({
cfEmail: process.env.CF_EMAIL,
cfKey: process.env.CF_KEY,
2016-07-04 02:56:49 +00:00
sslDir: path.join(process.cwd(),"test/assets"),
2016-07-04 06:41:58 +00:00
gitOriginRepo:"git@gitlab.com:sandboxzone/sandbox-sslorigin.git",
testMode:true
2016-06-22 11:22:09 +00:00
});
testCert.should.be.instanceof(cert.Cert);
})
it("should get a valid certificate",function(done){
2016-07-24 17:56:32 +00:00
this.timeout(1200000);
2016-07-21 12:58:05 +00:00
let promiseArray = [];
2016-07-22 01:28:30 +00:00
function getRandomArbitrary(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
2016-07-21 12:58:05 +00:00
q.all(promiseArray).then(() => {
2016-06-22 11:22:09 +00:00
done();
});
})
})
});