aboutsummaryrefslogtreecommitdiff
path: root/plugin/sign/file_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-08-29 15:41:59 +0100
committerGravatar GitHub <noreply@github.com> 2019-08-29 15:41:59 +0100
commitb8a0b52a5edc05145588598e7a5e2f00b82bb84d (patch)
tree64c8cb1a06028a4ea69a3df6d74c6f233055e70a /plugin/sign/file_test.go
parenteec24cb0138e74eb63f59521681f3e3b3555d4f0 (diff)
downloadcoredns-b8a0b52a5edc05145588598e7a5e2f00b82bb84d.tar.gz
coredns-b8a0b52a5edc05145588598e7a5e2f00b82bb84d.tar.zst
coredns-b8a0b52a5edc05145588598e7a5e2f00b82bb84d.zip
plugin/sign: a plugin that signs zone (#2993)
* plugin/sign: a plugin that signs zones Sign is a plugin that signs zone data (on disk). The README.md details what exactly happens to should be accurate related to the code. Signs are signed with a CSK, resigning and first time signing is all handled by *sign* plugin. Logging with a test zone looks something like this: ~~~ txt [INFO] plugin/sign: Signing "miek.nl." because open plugin/sign/testdata/db.miek.nl.signed: no such file or directory [INFO] plugin/sign: Signed "miek.nl." with key tags "59725" in 11.670985ms, saved in "plugin/sign/testdata/db.miek.nl.signed". Next: 2019-07-20T15:49:06.560Z [INFO] plugin/file: Successfully reloaded zone "miek.nl." in "plugin/sign/testdata/db.miek.nl.signed" with serial 1563636548 [INFO] plugin/sign: Signing "miek.nl." because resign was: 10m0s ago [INFO] plugin/sign: Signed "miek.nl." with key tags "59725" in 2.055895ms, saved in "plugin/sign/testdata/db.miek.nl.signed". Next: 2019-07-20T16:09:06.560Z [INFO] plugin/file: Successfully reloaded zone "miek.nl." in "plugin/sign/testdata/db.miek.nl.signed" with serial 1563637748 ~~~ Signed-off-by: Miek Gieben <miek@miek.nl> * Adjust readme and remove timestamps Signed-off-by: Miek Gieben <miek@miek.nl> * Comment on the newline Signed-off-by: Miek Gieben <miek@miek.nl> * Update plugin/sign/README.md Co-Authored-By: Michael Grosser <development@stp-ip.net>
Diffstat (limited to 'plugin/sign/file_test.go')
-rw-r--r--plugin/sign/file_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugin/sign/file_test.go b/plugin/sign/file_test.go
new file mode 100644
index 000000000..72d2b02ac
--- /dev/null
+++ b/plugin/sign/file_test.go
@@ -0,0 +1,43 @@
+package sign
+
+import (
+ "os"
+ "testing"
+
+ "github.com/miekg/dns"
+)
+
+func TestFileParse(t *testing.T) {
+ f, err := os.Open("testdata/db.miek.nl")
+ if err != nil {
+ t.Fatal(err)
+ }
+ z, err := Parse(f, "miek.nl.", "testdata/db.miek.nl")
+ if err != nil {
+ t.Fatal(err)
+ }
+ s := &Signer{
+ directory: ".",
+ signedfile: "db.miek.nl.test",
+ }
+
+ s.write(z)
+ defer os.Remove("db.miek.nl.test")
+
+ f, err = os.Open("db.miek.nl.test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ z, err = Parse(f, "miek.nl.", "db.miek.nl.test")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if x := z.Apex.SOA.Header().Name; x != "miek.nl." {
+ t.Errorf("Expected SOA name to be %s, got %s", x, "miek.nl.")
+ }
+ apex, _ := z.Search("miek.nl.")
+ key := apex.Type(dns.TypeDNSKEY)
+ if key != nil {
+ t.Errorf("Expected no DNSKEYs, but got %d", len(key))
+ }
+}