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/incubator-trafficcontrol.git
commit 2b8f29218154456ee0c0543a36d793b3ab2f8788 Author: Dewayne Richardson <dewr...@apache.org> AuthorDate: Mon Mar 5 11:54:51 2018 -0700 added support for the Portal User --- traffic_ops/testing/api/conf/traffic-ops-test.conf | 3 ++- traffic_ops/testing/api/config/config.go | 5 ++++- traffic_ops/testing/api/v13/parameters_test.go | 13 ++++++++++++- traffic_ops/traffic_ops_golang/parameter/parameters.go | 17 ++++++++++++++--- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/traffic_ops/testing/api/conf/traffic-ops-test.conf b/traffic_ops/testing/api/conf/traffic-ops-test.conf index 0300bb3..83fc86a 100644 --- a/traffic_ops/testing/api/conf/traffic-ops-test.conf +++ b/traffic_ops/testing/api/conf/traffic-ops-test.conf @@ -14,7 +14,8 @@ "trafficOps": { "password": "twelve", "URL": "https://localhost:8443", - "user": "admin" + "adminUser": "admin", + "portalUser": "portal" }, "trafficOpsDB": { "dbname": "to_test", diff --git a/traffic_ops/testing/api/config/config.go b/traffic_ops/testing/api/config/config.go index 2e6ee21..c2bac5f 100644 --- a/traffic_ops/testing/api/config/config.go +++ b/traffic_ops/testing/api/config/config.go @@ -39,11 +39,14 @@ type TrafficOps struct { URL string `json:"URL" envconfig:"TO_URL" default:"https://localhost:8443"` // User - The Traffic Ops test user hitting the API - User string `json:"user" envconfig:"TO_USER"` + AdminUser string `json:"adminUser" envconfig:"TO_ADMIN_USER"` // UserPassword - The Traffic Ops test user password hitting the API UserPassword string `json:"password" envconfig:"TO_USER_PASSWORD"` + // User - The Traffic Ops Portal user hitting the API + PortalUser string `json:"portalUser" envconfig:"TO_PORTAL_USER"` + // Insecure - ignores insecure ssls certs that were self-generated Insecure bool `json:"sslInsecure" envconfig:"SSL_INSECURE"` } diff --git a/traffic_ops/testing/api/v13/parameters_test.go b/traffic_ops/testing/api/v13/parameters_test.go index 7c59e1d..93941c9 100644 --- a/traffic_ops/testing/api/v13/parameters_test.go +++ b/traffic_ops/testing/api/v13/parameters_test.go @@ -16,7 +16,9 @@ package v13 import ( + "fmt" "testing" + "time" "github.com/apache/incubator-trafficcontrol/lib/go-log" tc "github.com/apache/incubator-trafficcontrol/lib/go-tc" @@ -24,10 +26,18 @@ import ( func TestParameters(t *testing.T) { + toReqTimeout := time.Second * time.Duration(Config.Default.Session.TimeoutInSecs) + //TOSession, _, err = SetupSession(toReqTimeout, Config.TrafficOps.URL, Config.TrafficOps.User, Config.TrafficOps.UserPassword) + //if err != nil { + //t.Errorf("could not CREATE session: %v\n", err) + //} + TeardownSession(toReqTimeout, Config.TrafficOps.URL, Config.TrafficOps.AdminUser, Config.TrafficOps.UserPassword) + SetupSession(toReqTimeout, Config.TrafficOps.URL, Config.TrafficOps.PortalUser, Config.TrafficOps.UserPassword) + CreateTestParameters(t) UpdateTestParameters(t) GetTestParameters(t) - DeleteTestParameters(t) + //DeleteTestParameters(t) } @@ -76,6 +86,7 @@ func GetTestParameters(t *testing.T) { for _, pl := range testData.Parameters { resp, _, err := TOSession.GetParameterByName(pl.Name) + fmt.Printf("resp ---> %v\n", resp) if err != nil { t.Errorf("cannot GET Parameter by name: %v - %v\n", err, resp) } diff --git a/traffic_ops/traffic_ops_golang/parameter/parameters.go b/traffic_ops/traffic_ops_golang/parameter/parameters.go index 73b87d1..eb4bbb6 100644 --- a/traffic_ops/traffic_ops_golang/parameter/parameters.go +++ b/traffic_ops/traffic_ops_golang/parameter/parameters.go @@ -174,6 +174,8 @@ secure) VALUES ( func (parameter *TOParameter) Read(db *sqlx.DB, parameters map[string]string, user auth.CurrentUser) ([]interface{}, []error, tc.ApiErrorType) { var rows *sqlx.Rows + privLevel := user.PrivLevel + // Query Parameters to Database Query column mappings // see the fields mapped in the SQL query queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{ @@ -200,13 +202,22 @@ func (parameter *TOParameter) Read(db *sqlx.DB, parameters map[string]string, us defer rows.Close() params := []interface{}{} + hiddenField := "********" for rows.Next() { - var s tc.ParameterNullable - if err = rows.StructScan(&s); err != nil { + var p tc.ParameterNullable + if err = rows.StructScan(&p); err != nil { log.Errorf("error parsing Parameter rows: %v", err) return nil, []error{tc.DBError}, tc.SystemError } - params = append(params, s) + var isSecure bool + if p.Secure != nil { + isSecure = *p.Secure + } + + if isSecure && (privLevel < auth.PrivLevelAdmin) { + p.Value = &hiddenField + } + params = append(params, p) } return params, []error{}, tc.NoError -- To stop receiving notification emails like this one, please contact dang...@apache.org.