1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Support ALIAS records with Cloudflare (#89)

* simple facility for registering provider capabilities

* support for cloudflare. tests.

* js and docs

* docs

* generate
This commit is contained in:
Craig Peterson
2017-04-19 13:13:28 -06:00
committed by GitHub
parent ffb2ee7673
commit fb14cea91e
14 changed files with 265 additions and 89 deletions

View File

@ -97,6 +97,10 @@ func runTests(t *testing.T, prv providers.DNSServiceProvider, domainName string,
break
}
t.Run(fmt.Sprintf("%d: %s", i, tst.Desc), func(t *testing.T) {
if tst.SkipUnless != 0 && !providers.ProviderHasCabability(*providerToRun, tst.SkipUnless) {
t.Log("Skipping because provider does not support test features")
return
}
skipVal := false
if knownFailures[i] {
t.Log("SKIPPING VALIDATION FOR KNOWN FAILURE CASE")
@ -186,8 +190,9 @@ func TestDualProviders(t *testing.T) {
}
type TestCase struct {
Desc string
Records []*rec
Desc string
Records []*rec
SkipUnless providers.Capability
}
type rec models.RecordConfig
@ -200,6 +205,10 @@ func cname(name, target string) *rec {
return makeRec(name, target, "CNAME")
}
func alias(name, target string) *rec {
return makeRec(name, target, "ALIAS")
}
func ns(name, target string) *rec {
return makeRec(name, target, "NS")
}
@ -231,6 +240,11 @@ func tc(desc string, recs ...*rec) *TestCase {
}
}
func (tc *TestCase) IfHasCapability(c providers.Capability) *TestCase {
tc.SkipUnless = c
return tc
}
//ALWAYS ADD TO BOTTOM OF LIST. Order and indexes matter.
var tests = []*TestCase{
// A
@ -274,5 +288,12 @@ var tests = []*TestCase{
tc("Change to other name", mx("@", 5, "foo2.com."), mx("mail", 15, "foo3.com.")),
tc("Change Priority", mx("@", 7, "foo2.com."), mx("mail", 15, "foo3.com.")),
tc("IDN pre-punycoded", cname("xn--o-0gab", "xn--o-0gab.xn--o-0gab.")),
//ALIAS
tc("EMPTY"),
tc("ALIAS at root", alias("@", "foo.com.")).IfHasCapability(providers.CanUseAlias),
tc("change it", alias("@", "foo2.com.")).IfHasCapability(providers.CanUseAlias),
tc("ALIAS at subdomain", alias("test", "foo.com.")).IfHasCapability(providers.CanUseAlias),
//TODO: in validation, check that everything is given in unicode. This case hurts too much.
//tc("IDN pre-punycoded", cname("xn--o-0gab", "xn--o-0gab.xn--o-0gab.")),
}

View File

@ -1,7 +1,17 @@
{
"ACTIVEDIRECTORY_PS": {
"knownFailures": "17,18,19,25,26,27,28,29,30",
"domain": "$AD_DOMAIN",
"ADServer": "$AD_SERVER"
},
"BIND": {
"domain": "example.com"
},
"CLOUDFLAREAPI":{
"domain": "$CF_DOMAIN",
"apiuser": "$CF_USER",
"apikey": "$CF_KEY"
},
"DNSIMPLE": {
//16/17: no ns records managable. Not even for subdomains.
"knownFailures": "17,18",
@ -9,7 +19,7 @@
"token": "$DNSIMPLE_TOKEN",
"baseurl": "https://api.sandbox.dnsimple.com"
},
"GANDI":{
"GANDI": {
//5: gandi does not accept ttls less than 300
"knownFailures": "5",
"domain": "$GANDI_DOMAIN",
@ -25,10 +35,5 @@
"domain": "$R53_DOMAIN",
"KeyId": "$R53_KEY_ID",
"SecretKey": "$R53_KEY"
},
"ACTIVEDIRECTORY_PS":{
"knownFailures": "17,18,19,25,26,27,28,29,30",
"domain": "$AD_DOMAIN",
"ADServer": "$AD_SERVER"
}
}

View File

@ -1,4 +1,2 @@
$TTL 300
@ IN SOA DEFAULT_NOT_SET. DEFAULT_NOT_SET. 2017032394 3600 600 604800 1440
IN MX 7 foo2.com.
mail IN MX 15 foo3.com.
@ IN SOA DEFAULT_NOT_SET. DEFAULT_NOT_SET. 2017041717 3600 600 604800 1440