Debian Codegraph @

cmd/atomdns/handlers/tsig/setup_test.go

raw
1 package tsig
2
3 import (
4 "testing"
5
6 "codeberg.org/miekg/dns"
7 "codeberg.org/miekg/dns/cmd/atomdns/internal/dnsserver"
8 )
9
10 func TestSetup(t *testing.T) {
11 testcases := []struct {
12 input string
13 exp *dns.TSIG
14 scr string
15 }{
16 {
17 `tsig example.org hmac-sha512 NoTCJU+DMqFWywaPyxSijrDEA/eC3nK0xi3AMEZuPVk=`,
18 dns.NewTSIG("example.org.", "hmac-sha512.", 0), "NoTCJU+DMqFWywaPyxSijrDEA/eC3nK0xi3AMEZuPVk=",
19 },
20 }
21 for i, tc := range testcases {
22 tsig := new(Tsig)
23 co := dnsserver.NewTestController(tc.input)
24 tsig.Setup(co)
25
26 if tc.scr != tsig.TSIGSecret {
27 t.Errorf("test %d: expected %s, got %s", i, tc.scr, tsig.TSIGSecret)
28 }
29
30 if !dns.Equal(tc.exp, tsig.TSIG) {
31 t.Errorf("test %d: expected %s, got %s", i, tc.exp, tsig.TSIG)
32 }
33 }
34 }