-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdnssec_test.go
159 lines (114 loc) · 4.08 KB
/
dnssec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Copyright 2019 nic.at GmbH. All rights reserved.
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package rc0go
import (
"encoding/json"
"fmt"
"net/http"
"reflect"
"testing"
)
func TestDNSSECService_Sign(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
want := &StatusResponse{Status: "ok", Message: "Zone testzone1.at signed successfully"}
mux.HandleFunc(RC0ZoneDNSSecSign, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
_json, _ := json.Marshal(want)
_, _ = fmt.Fprint(w, string(_json))
})
status, err := client.DNSSEC.Sign("testzone1.at")
if err != nil {
t.Errorf("DNSSEC.Sign returned error: %v", err)
}
if !reflect.DeepEqual(status, want) {
t.Errorf("DNSSEC.Sign returned %+v, want %+v", status, want)
}
}
func TestDNSSECService_Unsign(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
want := &StatusResponse{Status: "ok", Message: "Zone testzone1.at unsigned successfully"}
mux.HandleFunc(RC0ZoneDNSSecUnsign, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
_json, _ := json.Marshal(want)
_, _ = fmt.Fprint(w, string(_json))
})
status, err := client.DNSSEC.Unsign("testzone1.at")
if err != nil {
t.Errorf("DNSSEC.Unsign returned error: %v", err)
}
if !reflect.DeepEqual(status, want) {
t.Errorf("DNSSEC.Ubsign returned %+v, want %+v", status, want)
}
}
func TestDNSSECService_KeyRollover(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
want := &StatusResponse{Status: "ok", Message: "Key rollover started successfully."}
mux.HandleFunc(RC0ZoneDNSSecKeyRollover, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
_json, _ := json.Marshal(want)
_, _ = fmt.Fprint(w, string(_json))
})
status, err := client.DNSSEC.KeyRollover("testzone1.at")
if err != nil {
t.Errorf("DNSSEC.KeyRollover returned error: %v", err)
}
if !reflect.DeepEqual(status, want) {
t.Errorf("DNSSEC.KeyRollover returned %+v, want %+v", status, want)
}
}
func TestDNSSECService_DSUpdate(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
want := &StatusResponse{Status: "ok", Message: "Acknowledged KSK for domain 'testzone1.at'."}
mux.HandleFunc(RC0ZoneDNSSecDSUpdate, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
_json, _ := json.Marshal(want)
_, _ = fmt.Fprint(w, string(_json))
})
status, err := client.DNSSEC.DSUpdate("testzone1.at")
if err != nil {
t.Errorf("DNSSEC.DSUpdate returned error: %v", err)
}
if !reflect.DeepEqual(status, want) {
t.Errorf("DNSSEC.DSUpdate returned %+v, want %+v", status, want)
}
}
func TestDNSSECService_SimulateDSSEENEvent(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
want := &StatusResponse{Status: "ok", Message: "simulate ok: Simulated DSSSEN. Had to update 1 keys for zone 'testzone1.at'"}
mux.HandleFunc(RC0ZoneDNSSecDSSEEN, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
_json, _ := json.Marshal(want)
_, _ = fmt.Fprint(w, string(_json))
})
status, err := client.DNSSEC.SimulateDSSEENEvent("testzone1.at")
if err != nil {
t.Errorf("DNSSEC.SimulateDSSEENEvent returned error: %v", err)
}
if !reflect.DeepEqual(status, want) {
t.Errorf("DNSSEC.SimulateDSSEENEvent returned %+v, want %+v", status, want)
}
}
func TestDNSSECService_SimulateDSREMOVEDEvent(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
want := &StatusResponse{Status: "ok", Message: "simulate ok: Simulated DSREMOVED. Had to update 1 keys for zone 'testzone1.at'"}
mux.HandleFunc(RC0ZoneDNSSecDSREMOVED, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
_json, _ := json.Marshal(want)
_, _ = fmt.Fprint(w, string(_json))
})
status, err := client.DNSSEC.SimulateDSREMOVEDEvent("testzone1.at")
if err != nil {
t.Errorf("DNSSEC.SimulateDSREMOVEDEvent returned error: %v", err)
}
if !reflect.DeepEqual(status, want) {
t.Errorf("DNSSEC.SimulateDSREMOVEDEvent returned %+v, want %+v", status, want)
}
}