mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
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>
This commit is contained in:
42
plugin/sign/resign_test.go
Normal file
42
plugin/sign/resign_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package sign
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestResignInception(t *testing.T) {
|
||||
then := time.Date(2019, 7, 18, 22, 50, 0, 0, time.UTC)
|
||||
// signed yesterday
|
||||
zr := strings.NewReader(`miek.nl. 1800 IN RRSIG SOA 13 2 1800 20190808191936 20190717161936 59725 miek.nl. eU6gI1OkSEbyt`)
|
||||
if x := resign(zr, then); x != nil {
|
||||
t.Errorf("Expected RRSIG to be valid for %s, got invalid: %s", then.Format(timeFmt), x)
|
||||
}
|
||||
|
||||
// inception starts after this date.
|
||||
zr = strings.NewReader(`miek.nl. 1800 IN RRSIG SOA 13 2 1800 20190808191936 20190731161936 59725 miek.nl. eU6gI1OkSEbyt`)
|
||||
if x := resign(zr, then); x == nil {
|
||||
t.Errorf("Expected RRSIG to be invalid for %s, got valid", then.Format(timeFmt))
|
||||
}
|
||||
}
|
||||
|
||||
func TestResignExpire(t *testing.T) {
|
||||
then := time.Date(2019, 7, 18, 22, 50, 0, 0, time.UTC)
|
||||
// expires tomorrow
|
||||
zr := strings.NewReader(`miek.nl. 1800 IN RRSIG SOA 13 2 1800 20190717191936 20190717161936 59725 miek.nl. eU6gI1OkSEbyt`)
|
||||
if x := resign(zr, then); x == nil {
|
||||
t.Errorf("Expected RRSIG to be invalid for %s, got valid", then.Format(timeFmt))
|
||||
}
|
||||
// expire too far away
|
||||
zr = strings.NewReader(`miek.nl. 1800 IN RRSIG SOA 13 2 1800 20190731191936 20190717161936 59725 miek.nl. eU6gI1OkSEbyt`)
|
||||
if x := resign(zr, then); x != nil {
|
||||
t.Errorf("Expected RRSIG to be valid for %s, got invalid: %s", then.Format(timeFmt), x)
|
||||
}
|
||||
|
||||
// expired yesterday
|
||||
zr = strings.NewReader(`miek.nl. 1800 IN RRSIG SOA 13 2 1800 20190721191936 20190717161936 59725 miek.nl. eU6gI1OkSEbyt`)
|
||||
if x := resign(zr, then); x == nil {
|
||||
t.Errorf("Expected RRSIG to be invalid for %s, got valid", then.Format(timeFmt))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user