smartcert/test/test.ts

45 lines
1.6 KiB
TypeScript
Raw Normal View History

2016-10-23 22:35:00 +00:00
import 'typings-test'
import * as should from 'should'
import {Qenv} from 'qenv'
import path = require('path')
import q = require('q')
import * as cert from '../dist/index'
2016-06-22 11:22:09 +00:00
2016-10-23 22:35:00 +00:00
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit')
2016-06-21 19:08:04 +00:00
2016-10-23 22:35:00 +00:00
let testCert: cert.Cert
2016-06-22 11:22:09 +00:00
2016-10-23 22:35:00 +00:00
describe('cert',function(){
describe('Cert',function(){
it('should create a new Cert object from class',function(){
2016-06-22 11:22:09 +00:00
testCert = new cert.Cert({
cfEmail: process.env.CF_EMAIL,
cfKey: process.env.CF_KEY,
2016-10-23 22:35:00 +00:00
sslDirPath: path.join(process.cwd(),'test/assets'),
gitOriginRepo: 'git@gitlab.com:sandboxzone/sandbox-sslorigin.git',
leEnv: 'staging'
})
should(testCert).be.instanceof(cert.Cert)
2016-06-22 11:22:09 +00:00
})
2017-01-01 04:18:50 +00:00
it('should run class Cert.setup() successful', function(done){
this.timeout(40000)
testCert.setup().then(() => {
done()
})
})
2016-10-23 22:35:00 +00:00
it('should get a valid certificate',function(done){
this.timeout(1200000)
let promiseArray = []
2016-07-22 01:28:30 +00:00
function getRandomArbitrary(min, max) {
2016-10-23 22:35:00 +00:00
return Math.floor(Math.random() * (max - min) + min)
2016-07-22 01:28:30 +00:00
}
2016-10-23 22:35:00 +00:00
promiseArray.push(testCert.addCertificate(`testing${getRandomArbitrary(1,100000)}.bleu.de`))
// promiseArray.push(testCert.addCertificate(`testing${getRandomArbitrary(1,100000)}.bleu.de`))
// promiseArray.push(testCert.addCertificate(`testing${getRandomArbitrary(1,100000)}.bleu.de`))
2016-07-21 12:58:05 +00:00
q.all(promiseArray).then(() => {
2016-10-23 22:35:00 +00:00
done()
})
2016-06-22 11:22:09 +00:00
})
})
2016-10-23 22:35:00 +00:00
})