now works for most things

This commit is contained in:
Philipp Kunz 2016-06-21 19:04:43 +02:00
parent 9cb3c1508e
commit 757a9acd09
5 changed files with 77 additions and 21 deletions

File diff suppressed because one or more lines are too long

View File

@ -25,12 +25,12 @@
"beautylog": "^5.0.12",
"q": "^1.4.1",
"request": "^2.72.0",
"smartstring": "^2.0.6",
"smartstring": "^2.0.9",
"typings-global": "^1.0.3"
},
"devDependencies": {
"npmts-g": "^5.2.6",
"qenv": "^1.0.6",
"qenv": "^1.0.8",
"should": "^9.0.2",
"typings-test": "^1.0.1"
}

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@ import cflare = require("../dist/index");
let should = require("should");
import {Qenv} from "qenv";
let testQenv = new Qenv(process.cwd(),process.cwd() + "/.nogit");
console.log(testQenv.missingEnvVars);
let testCflareAccount = new cflare.CflareAccount();
testCflareAccount.auth({
email: process.env.CF_EMAIL,
@ -13,7 +13,7 @@ testCflareAccount.auth({
describe("cflare",function(){
describe(".CflareAccount",function(){
describe(".listZones()",function(){
it("should display an account",function(done){
it("should display an entire account",function(done){
this.timeout(10000);
testCflareAccount.listZones()
.then((responseArg)=>{
@ -59,14 +59,30 @@ describe("cflare",function(){
});
});
});
describe(".removeRecord",function(){
/*it("should remove a record from Cloudflare",function(done){
testCflareAccount.removeRecord()
describe(".getRecord",function(){
it("should get a record from Cloudflare",function(done){
testCflareAccount.getRecord("bleu.de","A")
.then(function(responseArg){
console.log(responseArg);
done();
});
});*/
});
});
describe(".removeRecord",function(){
it("should remove a record from Cloudflare",function(done){
testCflareAccount.removeRecord("bleu.de","A")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
it("should remove a subdomain record from Cloudflare",function(done){
testCflareAccount.removeRecord("subdomain.bleu.de","A")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
});
})
});

View File

@ -39,6 +39,7 @@ export class CflareAccount {
let filteredResponse = responseArg.result.filter((recordArg) => {
return (recordArg.type == typeArg && recordArg.name == domainNameArg);
})
done.resolve(filteredResponse[0]);
})
return done.promise;
};
@ -62,9 +63,17 @@ export class CflareAccount {
removeRecord(domainNameArg:string,typeArg:string){
let done = plugins.q.defer();
let domain = new plugins.smartstring.Domain(domainNameArg);
this.getRecord(domain.zoneName,typeArg)
this.getRecord(domain.fullName,typeArg)
.then((responseArg) => {
if(responseArg){
let requestRoute:string = "/zones/" + responseArg.zone_id + "/dns_records/" + responseArg.id;
this.request("DELETE",requestRoute)
.then((responseArg) => {
done.resolve(responseArg);
});
} else {
done.reject();
}
});
return done.promise;
};
@ -110,6 +119,7 @@ export class CflareAccount {
},
body:jsonArg
};
//console.log(options);
plugins.request(options,function(err, res, body){
if (!err && res.statusCode == 200) {
var responseObj = JSON.parse(body);