You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/07/24 16:53:41 UTC

[trafficcontrol] branch master updated (dca0338 -> b18bd99)

This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git.


    from dca0338  Make anonymousBlockingEnabled an optional field in the DS API
     new 41a19ac  Fixes #2575
     new b659434  added validation rules for the address field
     new ce04068  added more stringent validation rules around the host and the address
     new b18bd99  updated the validation rules to require typeId and deliveryserviceId

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../testing/api/v13/staticdnsentries_test.go       |  8 ++++----
 traffic_ops/testing/api/v13/tc-fixtures.json       | 14 +++++++-------
 .../staticdnsentry/staticdnsentry.go               | 22 ++++++++++++++++------
 3 files changed, 27 insertions(+), 17 deletions(-)


[trafficcontrol] 03/04: added more stringent validation rules around the host and the address

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit ce04068823e78607929b9a7049805f4b190dc9a8
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Mon Jul 23 14:48:41 2018 -0600

    added more stringent validation rules around the host and the address
---
 traffic_ops/testing/api/v13/tc-fixtures.json                    | 2 +-
 traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/traffic_ops/testing/api/v13/tc-fixtures.json b/traffic_ops/testing/api/v13/tc-fixtures.json
index 256b9bd..e1b2212 100644
--- a/traffic_ops/testing/api/v13/tc-fixtures.json
+++ b/traffic_ops/testing/api/v13/tc-fixtures.json
@@ -1024,7 +1024,7 @@
     ],
     "staticdnsentries": [
         {
-            "address": "192.168.0.1",
+            "address": "this.is.a.hostname.",
             "cachegroup": "cachegroup1",
             "deliveryservice": "ds1",
             "host": "host1",
diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
index 7006b99..b1af93f 100644
--- a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
@@ -82,8 +82,8 @@ func (staticDNSEntry *TOStaticDNSEntry) SetKeys(keys map[string]interface{}) {
 // Validate fulfills the api.Validator interface
 func (staticDNSEntry TOStaticDNSEntry) Validate() error {
 	errs := validation.Errors{
-		"host":    validation.Validate(staticDNSEntry.Host, validation.Required),
-		"address": validation.Validate(staticDNSEntry.Address, validation.Required, is.IP),
+		"host":    validation.Validate(staticDNSEntry.Host, validation.Required, is.DNSName),
+		"address": validation.Validate(staticDNSEntry.Address, validation.Required, is.Host),
 		"dsname":  validation.Validate(staticDNSEntry.DeliveryService, validation.Required),
 		"ttl":     validation.Validate(staticDNSEntry.TTL, validation.Required),
 		"type":    validation.Validate(staticDNSEntry.Type, validation.Required),


[trafficcontrol] 02/04: added validation rules for the address field

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit b65943460439da16705b53a8f6b5564817630dcb
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Mon Jul 23 14:28:09 2018 -0600

    added validation rules for the address field
---
 traffic_ops/testing/api/v13/staticdnsentries_test.go       |  2 +-
 traffic_ops/testing/api/v13/tc-fixtures.json               | 14 +++++++-------
 .../traffic_ops_golang/staticdnsentry/staticdnsentry.go    |  3 ++-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/traffic_ops/testing/api/v13/staticdnsentries_test.go b/traffic_ops/testing/api/v13/staticdnsentries_test.go
index ca21937..3ca74cb 100644
--- a/traffic_ops/testing/api/v13/staticdnsentries_test.go
+++ b/traffic_ops/testing/api/v13/staticdnsentries_test.go
@@ -97,7 +97,7 @@ func UpdateTestStaticDNSEntries(t *testing.T) {
 		t.Errorf("cannot GET StaticDNSEntries by name: '%s', %v\n", firstStaticDNSEntry.Host, err)
 	}
 	remoteStaticDNSEntry := resp[0]
-	expectedAddress := "address2"
+	expectedAddress := "192.168.0.1"
 	remoteStaticDNSEntry.Address = expectedAddress
 	var alert tc.Alerts
 	alert, _, err = TOSession.UpdateStaticDNSEntryByID(remoteStaticDNSEntry.ID, remoteStaticDNSEntry)
diff --git a/traffic_ops/testing/api/v13/tc-fixtures.json b/traffic_ops/testing/api/v13/tc-fixtures.json
index e6b7c37..256b9bd 100644
--- a/traffic_ops/testing/api/v13/tc-fixtures.json
+++ b/traffic_ops/testing/api/v13/tc-fixtures.json
@@ -1024,7 +1024,7 @@
     ],
     "staticdnsentries": [
         {
-            "address": "address1",
+            "address": "192.168.0.1",
             "cachegroup": "cachegroup1",
             "deliveryservice": "ds1",
             "host": "host1",
@@ -1032,7 +1032,7 @@
             "ttl": 10
         },
         {
-            "address": "address2",
+            "address": "192.168.0.1",
             "cachegroup": "cachegroup2",
             "deliveryservice": "ds1",
             "host": "host2",
@@ -1040,12 +1040,12 @@
             "ttl": 10
         },
         {
-            "host": "host3",
-            "deliveryservice": "ds1",
+            "address": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
             "cachegroup": "cachegroup2",
-            "address": "127.0.0.1",
-            "type": "CNAME_RECORD",
-            "ttl": 10
+            "deliveryservice": "ds1",
+            "host": "host3",
+            "ttl": 10,
+            "type": "CNAME_RECORD"
         }
     ],
     "statuses": [
diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
index 0e162b2..7006b99 100644
--- a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
@@ -32,6 +32,7 @@ import (
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
 	"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
 	validation "github.com/go-ozzo/ozzo-validation"
+	"github.com/go-ozzo/ozzo-validation/is"
 	"github.com/lib/pq"
 )
 
@@ -82,7 +83,7 @@ func (staticDNSEntry *TOStaticDNSEntry) SetKeys(keys map[string]interface{}) {
 func (staticDNSEntry TOStaticDNSEntry) Validate() error {
 	errs := validation.Errors{
 		"host":    validation.Validate(staticDNSEntry.Host, validation.Required),
-		"address": validation.Validate(staticDNSEntry.Address, validation.Required),
+		"address": validation.Validate(staticDNSEntry.Address, validation.Required, is.IP),
 		"dsname":  validation.Validate(staticDNSEntry.DeliveryService, validation.Required),
 		"ttl":     validation.Validate(staticDNSEntry.TTL, validation.Required),
 		"type":    validation.Validate(staticDNSEntry.Type, validation.Required),


[trafficcontrol] 01/04: Fixes #2575

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 41a19ac7565a8183c312c8be3785673fda825b66
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Mon Jul 23 14:04:25 2018 -0600

    Fixes #2575
---
 traffic_ops/testing/api/v13/staticdnsentries_test.go          |  6 +++---
 .../traffic_ops_golang/staticdnsentry/staticdnsentry.go       | 11 ++++++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/traffic_ops/testing/api/v13/staticdnsentries_test.go b/traffic_ops/testing/api/v13/staticdnsentries_test.go
index 3dc8a6a..ca21937 100644
--- a/traffic_ops/testing/api/v13/staticdnsentries_test.go
+++ b/traffic_ops/testing/api/v13/staticdnsentries_test.go
@@ -37,8 +37,8 @@ func TestStaticDNSEntries(t *testing.T) {
 	CreateTestStaticDNSEntries(t)
 	GetTestStaticDNSEntries(t)
 	UpdateTestStaticDNSEntries(t)
-	DeleteTestDeliveryServices(t)
 	DeleteTestStaticDNSEntries(t)
+	DeleteTestDeliveryServices(t)
 	DeleteTestServers(t)
 	DeleteTestCacheGroups(t)
 	DeleteTestPhysLocations(t)
@@ -140,10 +140,10 @@ func DeleteTestStaticDNSEntries(t *testing.T) {
 
 			_, _, err := TOSession.DeleteStaticDNSEntryByID(respStaticDNSEntry.ID)
 			if err != nil {
-				t.Errorf("cannot DELETE StaticDNSEntrie by name: '%s' %v\n", respStaticDNSEntry.Host, err)
+				t.Errorf("cannot DELETE StaticDNSEntry by name: '%s' %v\n", respStaticDNSEntry.Host, err)
 			}
 
-			// Retrieve the StaticDNSEntrie to see if it got deleted
+			// Retrieve the StaticDNSEntry to see if it got deleted
 			staticDNSEntries, _, err := TOSession.GetStaticDNSEntriesByHost(staticDNSEntry.Host)
 			if err != nil {
 				t.Errorf("error deleting StaticDNSEntrie name: %s\n", err.Error())
diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
index 5f213b0..0e162b2 100644
--- a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
@@ -92,7 +92,16 @@ func (staticDNSEntry TOStaticDNSEntry) Validate() error {
 
 func (staticDNSEntry *TOStaticDNSEntry) Read(parameters map[string]string) ([]interface{}, []error, tc.ApiErrorType) {
 	queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
-		"deliveryservice": dbhelpers.WhereColumnInfo{"deliveryservice", nil}, // order by
+		"address":           dbhelpers.WhereColumnInfo{"sde.address", nil},
+		"cachegroup":        dbhelpers.WhereColumnInfo{"cg.name", nil},
+		"cachegroupId":      dbhelpers.WhereColumnInfo{"cg.id", nil},
+		"deliveryservice":   dbhelpers.WhereColumnInfo{"ds.xml_id", nil},
+		"deliveryserviceId": dbhelpers.WhereColumnInfo{"sde.deliveryservice", nil},
+		"host":              dbhelpers.WhereColumnInfo{"sde.host", nil},
+		"id":                dbhelpers.WhereColumnInfo{"sde.id", nil},
+		"ttl":               dbhelpers.WhereColumnInfo{"sde.ttl", nil},
+		"type":              dbhelpers.WhereColumnInfo{"tp.name", nil},
+		"typeId":            dbhelpers.WhereColumnInfo{"tp.id", nil},
 	}
 	where, orderBy, queryValues, errs := dbhelpers.BuildWhereAndOrderBy(parameters, queryParamsToQueryCols)
 	if len(errs) > 0 {


[trafficcontrol] 04/04: updated the validation rules to require typeId and deliveryserviceId

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit b18bd994f5635210cfe3beaea91e147c32dd9f8a
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Tue Jul 24 09:32:51 2018 -0600

    updated the validation rules to require typeId and deliveryserviceId
---
 .../traffic_ops_golang/staticdnsentry/staticdnsentry.go        | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
index b1af93f..744514b 100644
--- a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
@@ -82,11 +82,11 @@ func (staticDNSEntry *TOStaticDNSEntry) SetKeys(keys map[string]interface{}) {
 // Validate fulfills the api.Validator interface
 func (staticDNSEntry TOStaticDNSEntry) Validate() error {
 	errs := validation.Errors{
-		"host":    validation.Validate(staticDNSEntry.Host, validation.Required, is.DNSName),
-		"address": validation.Validate(staticDNSEntry.Address, validation.Required, is.Host),
-		"dsname":  validation.Validate(staticDNSEntry.DeliveryService, validation.Required),
-		"ttl":     validation.Validate(staticDNSEntry.TTL, validation.Required),
-		"type":    validation.Validate(staticDNSEntry.Type, validation.Required),
+		"host":              validation.Validate(staticDNSEntry.Host, validation.Required, is.DNSName),
+		"address":           validation.Validate(staticDNSEntry.Address, validation.Required, is.Host),
+		"deliveryserviceId": validation.Validate(staticDNSEntry.DeliveryServiceID, validation.Required),
+		"ttl":               validation.Validate(staticDNSEntry.TTL, validation.Required),
+		"typeId":            validation.Validate(staticDNSEntry.TypeID, validation.Required),
 	}
 	return util.JoinErrs(tovalidate.ToErrors(errs))
 }