Jarl 0.1.0: manage BIND through a web UI, REST API and CLI

Jarl keeps a BIND 9.20 server's whole configuration (views, ACLs, TSIG
keys, zones of every type, records, named.conf options) in SQLite and
renders named.conf, keys.conf and zone files from it.

Every change goes through one changeset pipeline: whole-configuration
validation, named-checkconf -z and named-checkzone in a staging
directory, atomic install, rndc reconfig/reload, serial verification
with rndc zonestatus, and rollback if named does not load the change.
Changes apply one at a time by default or are bundled and applied
together. Applied changesets can be reverted.

- jarld: the daemon with the REST API and an embedded web UI, plus import,
  adopt, check, resync, backup and local user recovery commands
- jarl: the CLI, including ACME DNS-01 hooks for certbot and acme.sh
- users with argon2id passwords and CSRF-protected sessions; hashed API
  tokens with granular grants and roles; an audit log
- systemd unit, sysusers.d/tmpfiles.d files, Makefile
- unit tests, integration tests against a real named, scripts/e2e.sh
- docs/ guides, README and CHANGELOG

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abrown38andClaude Opus 5.5 committed 2026-10-07 15:03:13 +00:00
commit bd6b8778e4
122 files changed
+29217

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
package main
import (
"encoding/json"
"testing"
"go.yaml.in/yaml/v3"
)
func TestBatchFile(t *testing.T) {
src := `
description: test
changes:
- add: {zone: example.com, name: www, type: A, data: 192.0.2.1, ptr: true}
- delete: {zone: example.com, name: old, type: A}
- delete: {id: 12}
- set: {zone: example.com, name: api, type: A, data: 192.0.2.5}
- set: {zone: example.com, name: gone, type: TXT}
- update: {id: 13, data: 192.0.2.9}
- op: zone.create
data: {name: lab.example.com}
`
var b batchFile
if err := yaml.Unmarshal([]byte(src), &b); err != nil {
t.Fatal(err)
}
reqs, err := b.requests()
if err != nil {
t.Fatal(err)
}
want := []struct {
op string
id int64
data string
}{
{"record.create", 0, `{"data":"192.0.2.1","name":"www","ptr":true,"type":"A","zone":"example.com"}`},
{"record.delete", 0, `{"name":"old","type":"A","zone":"example.com"}`},
{"record.delete", 12, `{}`},
{"rrset.replace", 0, `{"data":["192.0.2.5"],"name":"api","type":"A","zone":"example.com"}`},
{"rrset.replace", 0, `{"data":[],"name":"gone","type":"TXT","zone":"example.com"}`},
{"record.update", 13, `{"data":"192.0.2.9"}`},
{"zone.create", 0, `{"name":"lab.example.com"}`},
}
if len(reqs) != len(want) {
t.Fatalf("got %d requests, want %d", len(reqs), len(want))
}
for i, w := range want {
r := reqs[i]
// Compare data as parsed JSON so key order doesn't matter.
var got, exp any
json.Unmarshal(r.Data, &got)
json.Unmarshal([]byte(w.data), &exp)
gb, _ := json.Marshal(got)
eb, _ := json.Marshal(exp)
if r.Op != w.op || r.ID != w.id || string(gb) != string(eb) {
t.Errorf("request %d = %s %d %s, want %s %d %s", i, r.Op, r.ID, gb, w.op, w.id, eb)
}
}
}
func TestBatchFileErrors(t *testing.T) {
for _, src := range []string{
"changes: [{add: {name: a}, delete: {name: b}}]", // two actions in one entry
"changes: [{}]", // no action
"changes: [{update: {data: x}}]", // update without id
} {
var b batchFile
if err := yaml.Unmarshal([]byte(src), &b); err != nil {
t.Fatal(err)
}
if _, err := b.requests(); err == nil {
t.Errorf("%s: expected an error", src)
}
}
}
func TestChallengeName(t *testing.T) {
for _, tc := range []struct {
domain string
exact bool
want string
}{
{"example.com", false, "_acme-challenge.example.com."},
{"*.example.com", false, "_acme-challenge.example.com."},
{"WWW.Example.com.", false, "_acme-challenge.www.example.com."},
{"_acme-challenge.www.example.com", false, "_acme-challenge.www.example.com."}, // acme.sh passes the full name
{"www.acme.example.com", true, "www.acme.example.com."},
} {
o := &acmeOptions{exact: tc.exact}
got, err := o.challengeName(tc.domain)
if err != nil || got != tc.want {
t.Errorf("challengeName(%q, exact=%v) = %q, %v; want %q", tc.domain, tc.exact, got, err, tc.want)
}
}
if _, err := (&acmeOptions{}).challengeName(" "); err == nil {
t.Error("empty domain accepted")
}
}
func TestListValue(t *testing.T) {
if got := listValue([]string{"192.0.2.1", " 192.0.2.2; ", "key xfer"}); got != "{ 192.0.2.1; 192.0.2.2; key xfer; }" {
t.Errorf("listValue = %q", got)
}
}