2017-01-29 16:27:48 +00:00
|
|
|
import 'typings-test'
|
|
|
|
import cflare = require('../dist/index')
|
|
|
|
import { expect } from 'smartchai'
|
|
|
|
import { Qenv } from 'qenv'
|
|
|
|
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit')
|
|
|
|
console.log(testQenv.missingEnvVars)
|
|
|
|
let testCflareAccount = new cflare.CflareAccount()
|
2016-05-15 17:51:48 +00:00
|
|
|
testCflareAccount.auth({
|
2016-06-20 20:56:09 +00:00
|
|
|
email: process.env.CF_EMAIL,
|
|
|
|
key: process.env.CF_KEY
|
2017-01-29 16:27:48 +00:00
|
|
|
})
|
2016-05-15 17:51:48 +00:00
|
|
|
|
2017-01-29 17:05:39 +00:00
|
|
|
let randomPrefix = Math.floor(Math.random() * 2000)
|
|
|
|
|
2017-01-29 16:27:48 +00:00
|
|
|
describe('cflare', function () {
|
|
|
|
describe('.CflareAccount', function () {
|
|
|
|
describe('.listZones()', function () {
|
|
|
|
it('should display an entire account', function (done) {
|
2017-01-29 16:45:48 +00:00
|
|
|
this.timeout(600000)
|
2016-05-16 01:29:29 +00:00
|
|
|
testCflareAccount.listZones()
|
2017-01-29 16:27:48 +00:00
|
|
|
.then((responseArg) => {
|
|
|
|
done()
|
2016-05-16 01:29:29 +00:00
|
|
|
})
|
2017-01-29 16:27:48 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
describe('.getZoneId(domainName)', function () {
|
|
|
|
it('should get an Cloudflare Id for a domain string', function (done) {
|
2017-01-29 16:45:48 +00:00
|
|
|
this.timeout(600000)
|
2017-01-29 16:27:48 +00:00
|
|
|
testCflareAccount.getZoneId('bleu.de')
|
2016-05-16 01:29:29 +00:00
|
|
|
.then((responseArg) => {
|
2017-01-29 16:27:48 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
describe('.listRecords(domainName)', function () {
|
|
|
|
it('should list all records for a specific Domain Name', function (done) {
|
2017-01-29 16:45:48 +00:00
|
|
|
this.timeout(600000)
|
2017-01-29 16:27:48 +00:00
|
|
|
testCflareAccount.listRecords('bleu.de')
|
|
|
|
.then((responseArg) => {
|
|
|
|
console.log(responseArg)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
describe('.createRecord', function () {
|
|
|
|
it('should create a valid record for a subdomain', function (done) {
|
2017-01-29 16:45:48 +00:00
|
|
|
this.timeout(600000)
|
2017-01-29 17:05:39 +00:00
|
|
|
testCflareAccount.createRecord(`${randomPrefix}subdomain.bleu.de`, 'A', '127.0.0.1')
|
2017-01-29 16:27:48 +00:00
|
|
|
.then(function (responseArg) {
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
describe('.getRecord', function () {
|
|
|
|
it('should get a record from Cloudflare', function (done) {
|
2017-01-29 16:45:48 +00:00
|
|
|
this.timeout(600000)
|
2017-01-29 16:27:48 +00:00
|
|
|
testCflareAccount.getRecord('bleu.de', 'A')
|
|
|
|
.then(function (responseArg) {
|
|
|
|
console.log(responseArg)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
describe('.removeRecord', function () {
|
|
|
|
it('should remove a subdomain record from Cloudflare', function (done) {
|
2017-01-29 16:45:48 +00:00
|
|
|
this.timeout(600000)
|
2017-01-29 17:05:39 +00:00
|
|
|
testCflareAccount.removeRecord(`${randomPrefix}subdomain.bleu.de`, 'A')
|
2017-01-29 16:27:48 +00:00
|
|
|
.then(function (responseArg) {
|
|
|
|
console.log(responseArg)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2016-05-16 01:29:29 +00:00
|
|
|
})
|
|
|
|
})
|
2017-01-29 16:27:48 +00:00
|
|
|
})
|