mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Add integration test for SOA (#1147)
* Add integration test for SOA * Add docs for SOA record * MAINT: Rename SoaInfo to SoaDefaults. gorename -v -from '"github.com/StackExchange/dnscontrol/v3/providers/bind".SoaInfo' -to SoaDefaults
This commit is contained in:
@@ -16,7 +16,7 @@ func mkRC(target string, rec *models.RecordConfig) *models.RecordConfig {
|
||||
func Test_makeSoa(t *testing.T) {
|
||||
origin := "example.com"
|
||||
var tests = []struct {
|
||||
def *SoaInfo
|
||||
def *SoaDefaults
|
||||
existing *models.RecordConfig
|
||||
desired *models.RecordConfig
|
||||
expectedSoa *models.RecordConfig
|
||||
@@ -24,7 +24,7 @@ func Test_makeSoa(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
// If everything is blank, the hard-coded defaults should kick in.
|
||||
&SoaInfo{"", "", 0, 0, 0, 0, 0, models.DefaultTTL},
|
||||
&SoaDefaults{"", "", 0, 0, 0, 0, 0, models.DefaultTTL},
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "", SoaSerial: 0, SoaRefresh: 0, SoaRetry: 0, SoaExpire: 0, SoaMinttl: 0}),
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "", SoaSerial: 0, SoaRefresh: 0, SoaRetry: 0, SoaExpire: 0, SoaMinttl: 0}),
|
||||
mkRC("DEFAULT_NOT_SET.", &models.RecordConfig{SoaMbox: "DEFAULT_NOT_SET.", SoaSerial: 1, SoaRefresh: 3600, SoaRetry: 600, SoaExpire: 604800, SoaMinttl: 1440}),
|
||||
@@ -32,7 +32,7 @@ func Test_makeSoa(t *testing.T) {
|
||||
},
|
||||
{
|
||||
// If everything is filled, leave the desired values in place.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&SoaDefaults{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
mkRC("a", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 10, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 15, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 15, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
@@ -40,7 +40,7 @@ func Test_makeSoa(t *testing.T) {
|
||||
},
|
||||
{
|
||||
// Test incrementing serial.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&SoaDefaults{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
mkRC("a", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 2019022301, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 0, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 2019022301, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
@@ -48,7 +48,7 @@ func Test_makeSoa(t *testing.T) {
|
||||
},
|
||||
{
|
||||
// Test incrementing serial_2.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&SoaDefaults{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
mkRC("a", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 12, SoaExpire: 13, SoaMinttl: 14}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 2019022304, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "bb", SoaSerial: 2019022304, SoaRefresh: 16, SoaRetry: 17, SoaExpire: 18, SoaMinttl: 19}),
|
||||
@@ -56,7 +56,7 @@ func Test_makeSoa(t *testing.T) {
|
||||
},
|
||||
{
|
||||
// If there are gaps in existing or desired, fill in as appropriate.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&SoaDefaults{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 0, SoaExpire: 13, SoaMinttl: 0}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "", SoaSerial: 15, SoaRefresh: 0, SoaRetry: 17, SoaExpire: 0, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 15, SoaRefresh: 11, SoaRetry: 17, SoaExpire: 13, SoaMinttl: 19}),
|
||||
@@ -64,7 +64,7 @@ func Test_makeSoa(t *testing.T) {
|
||||
},
|
||||
{
|
||||
// Gaps + existing==nil
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&SoaDefaults{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
nil,
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "", SoaSerial: 15, SoaRefresh: 0, SoaRetry: 17, SoaExpire: 0, SoaMinttl: 19}),
|
||||
mkRC("b", &models.RecordConfig{SoaMbox: "root.example.com", SoaSerial: 15, SoaRefresh: 2, SoaRetry: 17, SoaExpire: 4, SoaMinttl: 19}),
|
||||
@@ -73,7 +73,7 @@ func Test_makeSoa(t *testing.T) {
|
||||
{
|
||||
// Gaps + desired==nil
|
||||
// NB(tom): In the code as of 2020-02-23, desired will never be nil.
|
||||
&SoaInfo{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
&SoaDefaults{"ns.example.com", "root.example.com", 1, 2, 3, 4, 5, models.DefaultTTL},
|
||||
mkRC("", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 0, SoaRefresh: 11, SoaRetry: 0, SoaExpire: 13, SoaMinttl: 0}),
|
||||
nil,
|
||||
mkRC("ns.example.com", &models.RecordConfig{SoaMbox: "aa", SoaSerial: 1, SoaRefresh: 11, SoaRetry: 3, SoaExpire: 13, SoaMinttl: 5}),
|
||||
|
Reference in New Issue
Block a user