Skip to content

Commit

Permalink
fix sorting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tlimoncelli committed Dec 28, 2024
1 parent cb48444 commit 830b749
Show file tree
Hide file tree
Showing 57 changed files with 914 additions and 398 deletions.
11 changes: 6 additions & 5 deletions pkg/js/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ func TestParsedFiles(t *testing.T) {
// normalize.UpdateNameSplitHorizon(dc)
// }

errs := normalize.ValidateAndNormalizeConfig(conf)
if len(errs) != 0 {
t.Fatal(errs[0])
}

for _, dc := range conf.Domains {
//fmt.Printf("DEBUG: PrettySort: domain=%q #rec=%d\n", dc.Name, len(dc.Records))
//fmt.Printf("DEBUG: records = %d %v\n", len(dc.Records), dc.Records)
ps := prettyzone.PrettySort(dc.Records, dc.Name, 0, nil)
dc.Records = ps.Records
Expand Down Expand Up @@ -101,11 +107,6 @@ func TestParsedFiles(t *testing.T) {

// For each domain, if there is a zone file, test against it:

errs := normalize.ValidateAndNormalizeConfig(conf)
if len(errs) != 0 {
t.Fatal(errs[0])
}

var dCount int
for _, dc := range conf.Domains {
zoneFile := filepath.Join(testDir, testName, dc.Name+".zone")
Expand Down
5 changes: 5 additions & 0 deletions pkg/js/parse_tests/001-basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
"dnsProviders": {
"Cloudflare": -1
},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"name": "@",
"target": "1.2.3.4",
"ttl": 300,
"type": "A"
}
],
Expand Down
4 changes: 4 additions & 0 deletions pkg/js/parse_tests/002-ttl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"dnsProviders": {
"Cloudflare": -1
},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
Expand Down
5 changes: 5 additions & 0 deletions pkg/js/parse_tests/003-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
Expand All @@ -11,6 +15,7 @@
},
"name": "@",
"target": "1.2.3.4",
"ttl": 300,
"type": "A"
}
],
Expand Down
7 changes: 7 additions & 0 deletions pkg/js/parse_tests/004-ips.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,28 @@
"dnsProviders": {
"Cloudflare": 0
},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"name": "@",
"target": "1.2.3.4",
"ttl": 300,
"type": "A"
},
{
"name": "p1",
"target": "1.2.3.5",
"ttl": 300,
"type": "A"
},
{
"name": "p255",
"target": "1.2.4.3",
"ttl": 300,
"type": "A"
}
],
Expand Down
8 changes: 8 additions & 0 deletions pkg/js/parse_tests/005-ignored-records.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [],
"registrar": "none",
Expand Down Expand Up @@ -51,6 +55,10 @@
},
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "diff2.com"
},
"name": "diff2.com",
"records": [],
"registrar": "none",
Expand Down
25 changes: 24 additions & 1 deletion pkg/js/parse_tests/006-transforms.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,37 @@
"dnsProviders": {
"Cloudflare": -1
},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"meta": {
"transform": "0.0.0.0 ~ 1.1.1.1 ~ 2.2.2.2 ~ ; 1.1.1.1 ~ 2.2.2.2 ~ 3.3.3.3,4.4.4.4,5.5.5.5 ~ ; 1.1.1.1 ~ 2.2.2.2 ~ ~ 3.3.3.3,4.4.4.4,5.5.5.5"
},
"name": "@",
"target": "1.2.3.4",
"target": "3.4.5.6",
"ttl": 300,
"type": "A"
},
{
"meta": {
"transform": "0.0.0.0 ~ 1.1.1.1 ~ 2.2.2.2 ~ ; 1.1.1.1 ~ 2.2.2.2 ~ 3.3.3.3,4.4.4.4,5.5.5.5 ~ ; 1.1.1.1 ~ 2.2.2.2 ~ ~ 3.3.3.3,4.4.4.4,5.5.5.5"
},
"name": "@",
"target": "4.5.6.7",
"ttl": 300,
"type": "A"
},
{
"meta": {
"transform": "0.0.0.0 ~ 1.1.1.1 ~ 2.2.2.2 ~ ; 1.1.1.1 ~ 2.2.2.2 ~ 3.3.3.3,4.4.4.4,5.5.5.5 ~ ; 1.1.1.1 ~ 2.2.2.2 ~ ~ 3.3.3.3,4.4.4.4,5.5.5.5"
},
"name": "@",
"target": "5.6.7.8",
"ttl": 300,
"type": "A"
}
],
Expand Down
37 changes: 14 additions & 23 deletions pkg/js/parse_tests/007-importTransformTTL.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,32 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo1.com"
},
"name": "foo1.com",
"records": [],
"registrar": "reg"
},
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo2.com"
},
"name": "foo2.com",
"records": [
{
"meta": {
"transform_table": "0.0.0.0 ~ 1.1.1.1 ~ 4.4.4.4 ~ ; 7.7.7.7 ~ 8.8.8.8 ~ 9.9.9.9 ~ "
},
"name": "@",
"target": "foo1.com",
"ttl": 60,
"type": "IMPORT_TRANSFORM"
}
],
"records": [],
"registrar": "reg"
},
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo3.com"
},
"name": "foo3.com",
"records": [
{
"meta": {
"transform_suffixstrip": ".com",
"transform_table": "0.0.0.0 ~ 1.1.1.1 ~ ~ 2.2.2.2"
},
"name": "@",
"target": "foo1.com",
"ttl": 99,
"type": "IMPORT_TRANSFORM"
}
],
"records": [],
"registrar": "reg"
}
],
Expand Down
5 changes: 5 additions & 0 deletions pkg/js/parse_tests/008-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"name": "@",
"target": "1.2.3.4",
"ttl": 300,
"type": "A"
}
],
Expand Down
4 changes: 4 additions & 0 deletions pkg/js/parse_tests/009-reverse.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "2.1.in-addr.arpa"
},
"name": "2.1.in-addr.arpa",
"records": [],
"registrar": "none"
Expand Down
5 changes: 5 additions & 0 deletions pkg/js/parse_tests/010-alias.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"name": "@",
"target": "foo.com.",
"ttl": 300,
"type": "ALIAS"
}
],
Expand Down
12 changes: 12 additions & 0 deletions pkg/js/parse_tests/011-cfRedirect.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"meta": {
"orig_custom_type": "CF_REDIRECT"
},
"name": "@",
"target": "test.foo.com,https://goo.com/$1",
"ttl": 300,
"type": "CF_REDIRECT"
},
{
"meta": {
"orig_custom_type": "CF_TEMP_REDIRECT"
},
"name": "@",
"target": "test.foo.com,https://goo.com/$1",
"ttl": 300,
"type": "CF_TEMP_REDIRECT"
}
],
Expand Down
4 changes: 4 additions & 0 deletions pkg/js/parse_tests/012-duration.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
Expand Down
5 changes: 5 additions & 0 deletions pkg/js/parse_tests/013-mx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"mxpreference": 15,
"name": "@",
"target": "foo.com.",
"ttl": 300,
"type": "MX"
}
],
Expand Down
9 changes: 9 additions & 0 deletions pkg/js/parse_tests/014-caa.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,47 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"caaflag": 128,
"caatag": "iodef",
"name": "@",
"target": "https://example.com",
"ttl": 300,
"type": "CAA"
},
{
"caaflag": 128,
"caatag": "iodef",
"name": "@",
"target": "mailto:[email protected]",
"ttl": 300,
"type": "CAA"
},
{
"caatag": "iodef",
"name": "@",
"target": "http://example.com",
"ttl": 300,
"type": "CAA"
},
{
"caatag": "issue",
"name": "@",
"target": "letsencrypt.org",
"ttl": 300,
"type": "CAA"
},
{
"caatag": "issuewild",
"name": "@",
"target": ";",
"ttl": 300,
"type": "CAA"
}
],
Expand Down
7 changes: 6 additions & 1 deletion pkg/js/parse_tests/015-tlsa.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
"domains": [
{
"dnsProviders": {},
"meta": {
"dnscontrol_tag": "",
"dnscontrol_uniquename": "foo.com"
},
"name": "foo.com",
"records": [
{
"name": "_443._tcp",
"target": "MDFiYTQ3MTljODBiNmZlOTExYjA5MWE3YzA1MTI0YjY0ZWVlY2U5NjRlMDljMDU4ZWY4Zjk4MDVkYWNhNTQ2YiAgLQo=",
"target": "mdfiytq3mtljodbinmzlotexyja5mwe3yza1mti0yjy0zwvly2u5njrlmdljmdu4zwy4zjk4mdvkywnhntq2yiaglqo=",
"tlsamatchingtype": 1,
"tlsaselector": 1,
"tlsausage": 3,
"ttl": 300,
"type": "TLSA"
}
],
Expand Down
Loading

0 comments on commit 830b749

Please sign in to comment.