mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
NS1 Fix URLFWD implementation by being more consistent (#2320)
This commit is contained in:
@@ -206,7 +206,7 @@ func checkTargets(rec *models.RecordConfig, domain string) (errs []error) {
|
||||
if label == "@" {
|
||||
check(fmt.Errorf("cannot create NS record for bare domain. Use NAMESERVER instead"))
|
||||
}
|
||||
case "URLFWD":
|
||||
case "NS1_URLFWD":
|
||||
if len(strings.Fields(target)) != 5 {
|
||||
check(fmt.Errorf("record should follow format: \"from to redirectType pathForwardingMode queryForwarding\""))
|
||||
}
|
||||
|
||||
@@ -198,25 +198,25 @@ func TestNSAtRoot(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestURLFWDValid(t *testing.T) {
|
||||
rec := &models.RecordConfig{Type: "URLFWD"}
|
||||
func TestNS1URLFWDValid(t *testing.T) {
|
||||
rec := &models.RecordConfig{Type: "NS1_URLFWD"}
|
||||
rec.SetLabel("test1", "foo.com")
|
||||
rec.SetTarget("/ http://example.com 302 2 0")
|
||||
|
||||
errs := checkTargets(rec, "foo.com")
|
||||
if len(errs) > 0 {
|
||||
t.Error("Expect no error with valid URLFWD target")
|
||||
t.Error("Expect no error with valid NS1_URLFWD target")
|
||||
}
|
||||
}
|
||||
|
||||
func TestURLFWDInvalid(t *testing.T) {
|
||||
rec := &models.RecordConfig{Type: "URLFWD"}
|
||||
func TestNS1URLFWDInvalid(t *testing.T) {
|
||||
rec := &models.RecordConfig{Type: "NS1_URLFWD"}
|
||||
rec.SetLabel("test2", "foo.com")
|
||||
rec.SetTarget("/ http://example.com 302 2")
|
||||
|
||||
errs := checkTargets(rec, "foo.com")
|
||||
if len(errs) == 0 {
|
||||
t.Error("Expect error with invalid URLFWD target")
|
||||
t.Error("Expect error with invalid NS1_URLFWD target")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user