mirror of
https://github.com/miekg/dns.git
synced 2025-09-25 01:51:01 +02:00
These strings are domain names, so we should lowercase them before using them. Also add some tests for Tsig generation and verification. (/ht ldns release).
38 lines
748 B
Go
38 lines
748 B
Go
package dns
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func newTsig(algo string) *Msg {
|
|
m := new(Msg)
|
|
m.SetQuestion("example.org.", TypeA)
|
|
m.SetTsig("example.", algo, 300, time.Now().Unix())
|
|
return m
|
|
}
|
|
|
|
func TestTsig(t *testing.T) {
|
|
m := newTsig(HmacMD5)
|
|
buf, _, err := TsigGenerate(m, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
err = TsigVerify(buf, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestTsigCase(t *testing.T) {
|
|
m := newTsig("HmAc-mD5.sig-ALg.rEg.int.") // HmacMD5
|
|
buf, _, err := TsigGenerate(m, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
err = TsigVerify(buf, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|