This is an automated email from the ASF dual-hosted git repository. rob pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push: new 28a1ea9 Added missing struct fields in client to satisfy v11 defintion of a user 28a1ea9 is described below commit 28a1ea9f55234d678648de386b392b3ada941555 Author: moltzaum <matt...@moltzau.net> AuthorDate: Thu Aug 30 13:22:48 2018 -0600 Added missing struct fields in client to satisfy v11 defintion of a user Removed create and delete servers in the tests since the users test doesn't need it, and the server tests were failing at the time I wrote this. I added a small test to verify that the correct struct fields existed, looking at the struct fields in the localhost is insufficient since the only place the `User` struct is used is in the client. Note: The struct I modified will eventually be deprecated because it isn't nullable, but in the meantime a User should still contain all of its fields. --- lib/go-tc/users.go | 34 ++++++++++++++-------- traffic_ops/testing/api/v13/user_test.go | 24 ++++++++++++--- .../testing/api/v13/userdeliveryservices_test.go | 2 -- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/lib/go-tc/users.go b/lib/go-tc/users.go index 7c4e8ce..5bb740f 100644 --- a/lib/go-tc/users.go +++ b/lib/go-tc/users.go @@ -30,18 +30,28 @@ type UsersResponse struct { // User contains information about a given user in Traffic Ops. type User struct { - Username string `json:"username,omitempty"` - PublicSSHKey string `json:"publicSshKey,omitempty"` - Role int `json:"role,omitempty"` - RoleName string `json:"rolename,omitempty"` - ID int `json:"id,omitempty"` - UID int `json:"uid,omitempty"` - GID int `json:"gid,omitempty"` - Company string `json:"company,omitempty"` - Email string `json:"email,omitempty"` - FullName string `json:"fullName,omitempty"` - NewUser bool `json:"newUser,omitempty"` - LastUpdated string `json:"lastUpdated,omitempty"` + Username string `json:"username,omitempty"` + PublicSSHKey string `json:"publicSshKey,omitempty"` + Role int `json:"role,omitempty"` + RoleName string `json:"rolename,omitempty"` + ID int `json:"id,omitempty"` + UID int `json:"uid,omitempty"` + GID int `json:"gid,omitempty"` + Company string `json:"company,omitempty"` + Email string `json:"email,omitempty"` + FullName string `json:"fullName,omitempty"` + NewUser bool `json:"newUser,omitempty"` + LastUpdated string `json:"lastUpdated,omitempty"` + AddressLine1 string `json:"addressLine1"` + AddressLine2 string `json:"addressLine2"` + City string `json:"city"` + Country string `json:"country"` + PhoneNumber string `json:"phoneNumber"` + PostalCode string `json:"postalCode"` + RegistrationSent time.Time `json:"registrationSent"` + StateOrProvince string `json:"stateOrProvince"` + Tenant string `json:"tenant"` + TenantID int `json:"tenantId"` } // Credentials contains Traffic Ops login credentials diff --git a/traffic_ops/testing/api/v13/user_test.go b/traffic_ops/testing/api/v13/user_test.go index abe8bbf..7485b41 100644 --- a/traffic_ops/testing/api/v13/user_test.go +++ b/traffic_ops/testing/api/v13/user_test.go @@ -15,9 +15,9 @@ package v13 */ import ( - "testing" - + "encoding/json" "github.com/apache/trafficcontrol/lib/go-log" + "testing" ) func TestUsers(t *testing.T) { @@ -29,13 +29,12 @@ func TestUsers(t *testing.T) { CreateTestRegions(t) CreateTestPhysLocations(t) CreateTestCacheGroups(t) - CreateTestServers(t) CreateTestDeliveryServices(t) + GetTestUsers(t) GetTestUserCurrent(t) DeleteTestDeliveryServices(t) - DeleteTestServers(t) DeleteTestCacheGroups(t) DeleteTestPhysLocations(t) DeleteTestRegions(t) @@ -49,6 +48,23 @@ func TestUsers(t *testing.T) { const SessionUserName = "admin" // TODO make dynamic? +func GetTestUsers(t *testing.T) { + + resp, _, err := TOSession.GetUsers() + if err != nil { + t.Fatalf("cannot GET users: %v\n", err) + } + if len(resp) == 0 { + t.Fatalf("no users, must have at least 1 user to test\n") + } + + log.Debugf("Response: %s\n") + for _, user := range resp { + bytes, _ := json.Marshal(user) + log.Debugf("%s\n", bytes) + } +} + func GetTestUserCurrent(t *testing.T) { log.Debugln("GetTestUserCurrent") user, _, err := TOSession.GetUserCurrent() diff --git a/traffic_ops/testing/api/v13/userdeliveryservices_test.go b/traffic_ops/testing/api/v13/userdeliveryservices_test.go index e6acf4f..2b07f87 100644 --- a/traffic_ops/testing/api/v13/userdeliveryservices_test.go +++ b/traffic_ops/testing/api/v13/userdeliveryservices_test.go @@ -29,7 +29,6 @@ func TestUsersDeliveryServices(t *testing.T) { CreateTestRegions(t) CreateTestPhysLocations(t) CreateTestCacheGroups(t) - CreateTestServers(t) CreateTestDeliveryServices(t) CreateTestUsersDeliveryServices(t) @@ -37,7 +36,6 @@ func TestUsersDeliveryServices(t *testing.T) { DeleteTestUsersDeliveryServices(t) DeleteTestDeliveryServices(t) - DeleteTestServers(t) DeleteTestCacheGroups(t) DeleteTestPhysLocations(t) DeleteTestRegions(t)