Fi the tests too

This commit is contained in:
Miek Gieben 2014-01-27 14:45:34 +00:00
parent 39a8e2b8af
commit 9c75b3cdc2
2 changed files with 6 additions and 5 deletions

View File

@ -428,12 +428,12 @@ func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error {
// ValidityPeriod uses RFC1982 serial arithmetic to calculate
// if a signature period is valid. If t is the zero time, the
// current time is taken other t is.
func (rr *RRSIG) ValidityPeriod(t time.Tim) bool {
func (rr *RRSIG) ValidityPeriod(t time.Time) bool {
var utc int64
if t == time.Zero {
if t.IsZero() {
utc = time.Now().UTC().Unix()
} else {
utc = t.Now().UTC().Unix()
utc = t.UTC().Unix()
}
modi := (int64(rr.Inception) - utc) / year68
mode := (int64(rr.Expiration) - utc) / year68

View File

@ -8,6 +8,7 @@ import (
"crypto/rsa"
"strings"
"testing"
"time"
)
func getKey() *DNSKEY {
@ -124,14 +125,14 @@ func TestSignature(t *testing.T) {
sig.Signature = "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ"
// Should not be valid
if sig.ValidityPeriod() {
if sig.ValidityPeriod(time.Now()) {
t.Log("Should not be valid")
t.Fail()
}
sig.Inception = 315565800 //Tue Jan 1 10:10:00 CET 1980
sig.Expiration = 4102477800 //Fri Jan 1 10:10:00 CET 2100
if !sig.ValidityPeriod() {
if !sig.ValidityPeriod(time.Now()) {
t.Log("Should be valid")
t.Fail()
}