dnscontrol/pkg/js/README-parse_tests.md
Tom Limoncelli 1b2f5d4d34
BUGFIX: IDN support is broken for domain names (#3845)
# Issue

Fixes https://github.com/StackExchange/dnscontrol/issues/3842

CC @das7pad

# Resolution

Convert domain.Name to IDN earlier in the pipeline. Hack the --domains
processing to convert everything to IDN.

* Domain names are now stored 3 ways: The original input from
dnsconfig.js, canonical IDN format (`xn--...`), and Unicode format. All
are downcased. Providers that haven't been updated will receive the IDN
format instead of the original input format. This might break some
providers but only for users with unicode in their D("domain.tld").
PLEASE TEST YOUR PROVIDER.
* BIND filename formatting options have been added to access the new
formats.

# Breaking changes

* BIND zonefiles may change. The default used the name input in the D()
statement. It now defaults to the IDN name + "!tag" if there is a tag.
* Providers that are not IDN-aware may break (hopefully only if they
weren't processing IDN already)

---------

Co-authored-by: Jakob Ackermann <das7pad@outlook.com>
2025-11-29 12:17:44 -05:00

44 lines
1.3 KiB
Markdown

# Parse Tests
The `parse_tests` directory contains test cases for `js_test.go`. `js_test.go`
scans for files named `DDD-*.js` where `DDD` is a three-digit number.
* `parse_tests/001-basic.js` -- The dnsconfig.js file.
* `parse_tests/001-basic.json` -- The EXPECTED output of "print-ir" for the `.js` file.
* `parse_tests/001-basic.json.ACTUAL` -- The ACTUAL output of "print-ir" for the `.js` file (not saved in git)
* `parse_tests/001-basic/foo.com.zone` -- Zonefiles from the domains mentioned in dnsconfig.js
NOTE: The zonefiles are only tested if a matching `DDD-name/DOMAINNAME.zone` file exists.
Any files committed to Git should be in standard format.
# Fix formatting
Fix the `.js` formatting:
```
cd parse_tests
for i in *.js ; do echo ========== $i ; dnscontrol fmt -i $i -o $i ; done
```
Fix the `.json` formatting:
```
cd parse_tests
fmtjson *.json *.json.ACTUAL
```
# Copy actuals to expected.
Back-port the ACTUAL results to the expected results:
(This is dangerous. You may be committing buggy results to the "expected" files. Carefully inspect the resulting PR.)
```
find . -type f -name \*.ACTUAL -print -delete
go test -count=1 ./...
cd parse_tests
fmtjson *.json *.json.ACTUAL
for i in *.ACTUAL ; do f=$(basename $i .ACTUAL) ; cp $i $f ; done
```