cloudflare/test/test.ts

55 lines
1.7 KiB
TypeScript
Raw Normal View History

2017-06-04 15:29:19 +00:00
import { expect, tap } from 'tapbundle'
2017-01-29 16:27:48 +00:00
import cflare = require('../dist/index')
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({
2017-06-04 15:29:19 +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-06-04 15:29:19 +00:00
tap.test('.listZones() -> should display an entire account', async (tools) => {
// tools.timeout(600000)
let result = await testCflareAccount.listZones()
console.log(result)
})
tap.test('.getZoneId(domainName) -> should get an Cloudflare Id for a domain string', async (tools) => {
// tools.timeout(600000)
await testCflareAccount.getZoneId('bleu.de')
})
tap.test('.listRecords(domainName) -> should list all records for a specific Domain Name', async (tools) => {
// tools.timeout(600000)
await testCflareAccount.listRecords('bleu.de')
.then(async (responseArg) => {
console.log(responseArg)
2016-05-16 01:29:29 +00:00
})
2017-01-29 16:27:48 +00:00
})
2017-06-04 15:29:19 +00:00
tap.test('should create a valid record for a subdomain', async (tools) => {
// tools.timeout(600000)
await testCflareAccount.createRecord(`${randomPrefix}subdomain.bleu.de`, 'A', '127.0.0.1')
})
tap.test('should get a record from Cloudflare', async (tools) => {
// tools.timeout(600000)
await testCflareAccount.getRecord('bleu.de', 'A')
.then(function (responseArg) {
console.log(responseArg)
})
})
tap.test('should remove a subdomain record from Cloudflare', async (tools) => {
// tools.timeout(600000)
await testCflareAccount.removeRecord(`${randomPrefix}subdomain.bleu.de`, 'A')
.then(async (responseArg) => {
console.log(responseArg)
})
})
tap.start()