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/03/12 23:01:05 UTC
[incubator-trafficcontrol] branch master updated: deprecated the
client_tests to use the traffic_ops/testing/api instead
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
The following commit(s) were added to refs/heads/master by this push:
new 52ac31f deprecated the client_tests to use the traffic_ops/testing/api instead
52ac31f is described below
commit 52ac31fb7cbee121a147c579e41c906e667079e8
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Mon Mar 12 10:02:37 2018 -0600
deprecated the client_tests to use the traffic_ops/testing/api instead
---
traffic_ops/client_tests/README.md | 2 +
.../delivery_service_endpoints_test.go | 153 -----
traffic_ops/client_tests/fixtures/cachegroup.go | 35 -
traffic_ops/client_tests/fixtures/cdn.go | 31 -
.../client_tests/fixtures/delivery_service.go | 237 -------
traffic_ops/client_tests/fixtures/hardware.go | 40 --
traffic_ops/client_tests/fixtures/parameter.go | 32 -
traffic_ops/client_tests/fixtures/profile.go | 32 -
traffic_ops/client_tests/fixtures/server.go | 190 ------
traffic_ops/client_tests/fixtures/stats_summary.go | 33 -
traffic_ops/client_tests/fixtures/tenant.go | 33 -
.../fixtures/traffic_monitor_config.go | 126 ----
.../client_tests/fixtures/traffic_router_config.go | 163 -----
traffic_ops/client_tests/fixtures/types.go | 32 -
traffic_ops/client_tests/fixtures/update.go | 31 -
traffic_ops/client_tests/fixtures/user.go | 34 -
traffic_ops/client_tests/http.go | 44 --
traffic_ops/client_tests/tenant_endpoints_test.go | 32 -
traffic_ops/client_tests/test.go | 66 --
traffic_ops/client_tests/tests/cachegroup_test.go | 90 ---
traffic_ops/client_tests/tests/cdn_test.go | 126 ----
.../client_tests/tests/conf/seelog.xml.test | 9 -
.../client_tests/tests/delivery_service_test.go | 660 -------------------
traffic_ops/client_tests/tests/hardware_test.go | 85 ---
.../client_tests/tests/integration/Readme.md | 33 -
.../tests/integration/cachegroup_test.go | 83 ---
.../client_tests/tests/integration/cdn_test.go | 106 ---
.../tests/integration/crconfig_test.go | 40 --
.../tests/integration/deliveryservice_test.go | 722 ---------------------
.../tests/integration/hardware_test.go | 119 ----
.../tests/integration/integration_helper.go | 138 ----
.../tests/integration/parameter_test.go | 68 --
.../client_tests/tests/integration/profile_test.go | 73 ---
.../client_tests/tests/integration/server_test.go | 236 -------
.../tests/integration/stats_summary_test.go | 241 -------
.../integration/traffic_monitor_config_test.go | 190 ------
.../integration/traffic_router_config_test.go | 220 -------
.../client_tests/tests/integration/type_test.go | 73 ---
.../client_tests/tests/integration/user_test.go | 67 --
traffic_ops/client_tests/tests/parameter_test.go | 84 ---
traffic_ops/client_tests/tests/profile_test.go | 84 ---
traffic_ops/client_tests/tests/server_test.go | 311 ---------
.../client_tests/tests/stats_summary_test.go | 90 ---
traffic_ops/client_tests/tests/tenant_test.go | 72 --
.../tests/traffic_monitor_config_test.go | 196 ------
traffic_ops/client_tests/tests/traffic_ops_test.go | 78 ---
.../tests/traffic_router_config_test.go | 207 ------
traffic_ops/client_tests/tests/type_test.go | 84 ---
traffic_ops/client_tests/tests/update_test.go | 63 --
traffic_ops/client_tests/tests/user_test.go | 90 ---
50 files changed, 2 insertions(+), 6082 deletions(-)
diff --git a/traffic_ops/client_tests/README.md b/traffic_ops/client_tests/README.md
new file mode 100644
index 0000000..2f721a4
--- /dev/null
+++ b/traffic_ops/client_tests/README.md
@@ -0,0 +1,2 @@
+
+This client_test dir is now deprecated in favor of the new `traffic_ops/testing/api` directory. Please see [Testing API README.md](https://github.com/apache/incubator-trafficcontrol/tree/master/traffic_ops/testing/api#traffic-ops-api-tests)
diff --git a/traffic_ops/client_tests/delivery_service_endpoints_test.go b/traffic_ops/client_tests/delivery_service_endpoints_test.go
deleted file mode 100644
index 3a46561..0000000
--- a/traffic_ops/client_tests/delivery_service_endpoints_test.go
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package client
-
-import (
- "testing"
-)
-
-func TestDeliveryServicesEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServices uses the correct URL")
-
- ep := deliveryServicesEp()
- expected := "/api/1.2/deliveryservices.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServicesEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery services endpoint")
- }
-}
-
-func TestDeliveryServicesServerEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServicesByServer uses the correct URL")
-
- id := "42"
- ep := deliveryServicesByServerEp(id)
- expected := "/api/1.2/servers/" + id + "/deliveryservices.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServicesEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery services endpoint")
- }
-}
-
-func TestDeliveryServiceEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryService uses the correct URL")
-
- ep := deliveryServiceEp("123")
- expected := "/api/1.2/deliveryservices/123.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service endpoint")
- }
-}
-
-func TestDeliveryServiceStateEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceState uses the correct URL")
-
- ep := deliveryServiceStateEp("123")
- expected := "/api/1.2/deliveryservices/123/state.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceStateEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service state endpoint")
- }
-}
-
-func TestDeliveryServiceHealthEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceHealth uses the correct URL")
-
- ep := deliveryServiceHealthEp("123")
- expected := "/api/1.2/deliveryservices/123/health.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceHealthEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service health endpoint")
- }
-}
-
-func TestDeliveryServiceCapacityEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceCapacity uses the correct URL")
-
- ep := deliveryServiceCapacityEp("123")
- expected := "/api/1.2/deliveryservices/123/capacity.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceCapacityEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service capacity endpoint")
- }
-}
-
-func TestDeliveryServiceRoutingEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceRouting uses the correct URL")
-
- ep := deliveryServiceRoutingEp("123")
- expected := "/api/1.2/deliveryservices/123/routing.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceRoutingEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service routing endpoint")
- }
-}
-
-func TestDeliveryServiceServerEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceServer uses the correct URL")
-
- ep := deliveryServiceServerEp("1", "2")
- expected := "/api/1.2/deliveryserviceserver.json?page=1&limit=2"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceServerEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service server endpoint")
- }
-}
-
-func TestDeliveryServiceRegexesEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceRegexes uses the correct URL")
-
- ep := deliveryServiceRegexesEp()
- expected := "/api/1.2/deliveryservices_regexes.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceRegexesEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service regexes endpoint")
- }
-}
-
-func TestDeliveryServiceSSLKeysByIDEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceSSLKeysByID uses the correct URL")
-
- ep := deliveryServiceSSLKeysByIDEp("123")
- expected := "/api/1.2/deliveryservices/xmlId/123/sslkeys.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceSSLKeysByIDEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service SSL Keys by ID endpoint")
- }
-}
-
-func TestDeliveryServiceSSLKeysByHostnameEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServiceSSLKeysByHostname uses the correct URL")
-
- ep := deliveryServiceSSLKeysByHostnameEp("some-host")
- expected := "/api/1.2/deliveryservices/hostname/some-host/sslkeys.json"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"deliveryServiceSSLKeysByHostnameEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct delivery service SSL Keys by hostname endpoint")
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/cachegroup.go b/traffic_ops/client_tests/fixtures/cachegroup.go
deleted file mode 100644
index ea0fd69..0000000
--- a/traffic_ops/client_tests/fixtures/cachegroup.go
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// Cachegroups returns a default CacheGroupResponse to be used for testing.
-func Cachegroups() *client.CacheGroupResponse {
- return &client.CacheGroupResponse{
- Response: []client.CacheGroup{
- client.CacheGroup{
- Name: "edge-philadelphia",
- ShortName: "phila",
- Type: "EDGE_LOC",
- Longitude: -5.66,
- Latitude: 55.67,
- ParentName: "mid-northeast",
- LastUpdated: "2014-03-28 15:23:50",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/cdn.go b/traffic_ops/client_tests/fixtures/cdn.go
deleted file mode 100644
index 0349cbe..0000000
--- a/traffic_ops/client_tests/fixtures/cdn.go
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// CDNs returns a default CDNResponse to be used for testing.
-func CDNs() *client.CDNResponse {
- return &client.CDNResponse{
- Response: []client.CDN{
- client.CDN{
- ID: 1,
- Name: "CDN-1",
- LastUpdated: "2016-03-22 17:00:30",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/delivery_service.go b/traffic_ops/client_tests/fixtures/delivery_service.go
deleted file mode 100644
index f7c7cc9..0000000
--- a/traffic_ops/client_tests/fixtures/delivery_service.go
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// DeliveryServices returns a default DeliveryServiceResponse to be used for testing.
-func DeliveryServices() *client.GetDeliveryServiceResponse {
- return &client.GetDeliveryServiceResponse{
- Response: []client.DeliveryService{
- client.DeliveryService{
- ID: 001,
- XMLID: "ds-test",
- Active: true,
- DSCP: 40,
- DeepCachingType: "NEVER",
- RoutingName: "edge",
- Signed: false,
- QStringIgnore: 1,
- GeoLimit: 0,
- GeoProvider: 0,
- DNSBypassTTL: 30,
- Type: "HTTP",
- ProfileName: "ds-123",
- CDNName: "test-cdn",
- CCRDNSTTL: 3600,
- GlobalMaxTPS: 0,
- MaxDNSAnswers: 0,
- MissLat: 44.654321,
- MissLong: -99.123456,
- Protocol: 0,
- IPV6RoutingEnabled: true,
- RangeRequestHandling: 0,
- TRResponseHeaders: "Access-Control-Allow-Origin: *",
- MultiSiteOrigin: false,
- DisplayName: "Testing",
- InitialDispersion: 1,
- },
- },
- }
-}
-
-func alerts() []client.DeliveryServiceAlert {
- return []client.DeliveryServiceAlert{
- client.DeliveryServiceAlert{
- Level: "level",
- Text: "text",
- },
- }
-}
-
-// DeliveryService returns a default DeliveryServiceResponse to be used for testing.
-func DeliveryService() *client.DeliveryServiceResponse {
- return &client.DeliveryServiceResponse{
- Response: DeliveryServices().Response[0],
- Alerts: alerts(),
- }
-}
-
-// DeliveryService returns a default DeliveryServiceResponse to be used for testing.
-func DeliveryServicesByServer() *client.GetDeliveryServiceResponse {
- return &client.GetDeliveryServiceResponse{
- Response: DeliveryServices().Response,
- }
-}
-
-// CreateDeliveryService returns a default CreateDeliveryServiceResponse to be used for testing.
-func CreateDeliveryService() *client.CreateDeliveryServiceResponse {
- return &client.CreateDeliveryServiceResponse{
- Response: DeliveryServices().Response,
- Alerts: alerts(),
- }
-}
-
-// UpdateDeliveryService returns a default UpdateDeliveryServiceResponse to be used for testing.
-func UpdateDeliveryService() *client.UpdateDeliveryServiceResponse {
- return &client.UpdateDeliveryServiceResponse{
- Response: DeliveryServices().Response,
- Alerts: alerts(),
- }
-}
-
-// DeleteDeliveryService returns a default DeleteDeliveryServiceResponse to be used for testing.
-func DeleteDeliveryService() *client.DeleteDeliveryServiceResponse {
- return &client.DeleteDeliveryServiceResponse{
- Alerts: alerts(),
- }
-}
-
-// DeliveryServiceState returns a default DeliveryServiceStateResponse to be used for testing.
-func DeliveryServiceState() *client.DeliveryServiceStateResponse {
- dest := client.DeliveryServiceDestination{
- Location: "someLocation",
- Type: "DNS",
- }
-
- failover := client.DeliveryServiceFailover{
- Locations: []string{"one", "two"},
- Destination: dest,
- Configured: true,
- Enabled: true,
- }
-
- ds := client.DeliveryServiceState{
- Enabled: true,
- Failover: failover,
- }
-
- return &client.DeliveryServiceStateResponse{
- Response: ds,
- }
-}
-
-// DeliveryServiceHealth returns a default DeliveryServiceHealthResponse to be used for testing.
-func DeliveryServiceHealth() *client.DeliveryServiceHealthResponse {
- cacheGroup := client.DeliveryServiceCacheGroup{
- Name: "someCacheGroup",
- Online: 2,
- Offline: 3,
- }
-
- dsh := client.DeliveryServiceHealth{
- TotalOnline: 2,
- TotalOffline: 3,
- CacheGroups: []client.DeliveryServiceCacheGroup{cacheGroup},
- }
-
- return &client.DeliveryServiceHealthResponse{
- Response: dsh,
- }
-}
-
-// DeliveryServiceCapacity returns a default DeliveryServiceCapacityResponse to be used for testing.
-func DeliveryServiceCapacity() *client.DeliveryServiceCapacityResponse {
- dsc := client.DeliveryServiceCapacity{
- AvailablePercent: 90.12345,
- UnavailablePercent: 90.12345,
- UtilizedPercent: 90.12345,
- MaintenancePercent: 90.12345,
- }
-
- return &client.DeliveryServiceCapacityResponse{
- Response: dsc,
- }
-}
-
-// DeliveryServiceRouting returns a default DeliveryServiceRoutingResponse to be used for testing.
-func DeliveryServiceRouting() *client.DeliveryServiceRoutingResponse {
- dsr := client.DeliveryServiceRouting{
- StaticRoute: 1,
- Miss: 2,
- Geo: 3.33,
- Err: 4,
- CZ: 5.55,
- DSR: 6.66,
- Fed: 1,
- RegionalAlternate: 1,
- RegionalDenied: 1,
- }
-
- return &client.DeliveryServiceRoutingResponse{
- Response: dsr,
- }
-}
-
-// DeliveryServiceServer returns a default DeliveryServiceServerResponse to be used for testing.
-func DeliveryServiceServer() *client.DeliveryServiceServerResponse {
- dss := client.DeliveryServiceServer{
- LastUpdated: "lastUpdated",
- Server: 1,
- DeliveryService: 1,
- }
-
- return &client.DeliveryServiceServerResponse{
- Response: []client.DeliveryServiceServer{dss},
- Size: 1,
- OrderBy: "foo",
- Limit: 1,
- }
-}
-
-// DeliveryServiceServer returns a default DeliveryServiceServerResponse to be used for testing.
-func DeliveryServiceRegexes() *client.DeliveryServiceRegexResponse {
- dss := client.DeliveryServiceRegexes{
- Regexes: []client.DeliveryServiceRegex{
- client.DeliveryServiceRegex{
- Type: "type",
- SetNumber: 42,
- Pattern: "pattern",
- },
- },
- DSName: "dsname",
- }
-
- return &client.DeliveryServiceRegexResponse{
- Response: []client.DeliveryServiceRegexes{dss},
- }
-}
-
-// DeliveryServiceSSLKeys returns a default DeliveryServiceSSLKeysResponse to be used for testing.
-func DeliveryServiceSSLKeys() *client.DeliveryServiceSSLKeysResponse {
- crt := client.DeliveryServiceSSLKeysCertificate{
- Crt: "crt",
- Key: "key",
- CSR: "someService",
- }
-
- sslKeys := client.DeliveryServiceSSLKeys{
- CDN: "cdn",
- DeliveryService: "deliveryService",
- Certificate: crt,
- BusinessUnit: "businessUnit",
- City: "city",
- Organization: "Kabletown",
- Hostname: "hostname",
- Country: "country",
- State: "state",
- Version: "version",
- }
-
- return &client.DeliveryServiceSSLKeysResponse{
- Response: sslKeys,
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/hardware.go b/traffic_ops/client_tests/fixtures/hardware.go
deleted file mode 100644
index eb5f454..0000000
--- a/traffic_ops/client_tests/fixtures/hardware.go
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// Hardware returns a default HardwareResponse to be used for testing.
-func Hardware() *client.HardwareResponse {
- return &client.HardwareResponse{
- Response: []client.Hardware{
- client.Hardware{
- ID: 18,
- HostName: "edge-den-01",
- LastUpdated: "2015-07-16 09:04:20",
- Value: "DIS1",
- Description: "Phys Disk",
- },
- client.Hardware{
- ID: 19,
- HostName: "edge-den-02",
- LastUpdated: "2015-07-16 09:04:20",
- Value: "DIS2",
- Description: "Physical Disk",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/parameter.go b/traffic_ops/client_tests/fixtures/parameter.go
deleted file mode 100644
index f946790..0000000
--- a/traffic_ops/client_tests/fixtures/parameter.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// Parameters returns a default ParamResponse to be used for testing.
-func Parameters() *client.ParamResponse {
- return &client.ParamResponse{
- Response: []client.Parameter{
- client.Parameter{
- Name: "location",
- Value: "/foo/trafficserver/",
- ConfigFile: "parent.config",
- LastUpdated: "2012-09-17 15:41:22",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/profile.go b/traffic_ops/client_tests/fixtures/profile.go
deleted file mode 100644
index 8bf6be1..0000000
--- a/traffic_ops/client_tests/fixtures/profile.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// Profiles returns a default ProfileResponse to be used for testing.
-func Profiles() *client.ProfileResponse {
- return &client.ProfileResponse{
- Response: []client.Profile{
- client.Profile{
- ID: 1,
- Name: "TR_CDN2",
- Description: "kabletown Content Router",
- LastUpdated: "2012-10-08 13:34:45",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/server.go b/traffic_ops/client_tests/fixtures/server.go
deleted file mode 100644
index 48b75bb..0000000
--- a/traffic_ops/client_tests/fixtures/server.go
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// Servers returns a default ServerResponse to be used for testing.
-func Servers() *client.ServerResponse {
- return &client.ServerResponse{
- Response: []client.Server{
- {
- ID: 001,
- HostName: "edge-alb-01",
- DomainName: "albuquerque.nm.albuq.kabletown.com",
- CDNName: "CDN-1",
- Type: "EDGE",
- Profile: "EDGE1_CDN_520",
- TCPPort: 80,
- Rack: "F-4/35",
- PhysLocation: "Albuquerque",
- Cachegroup: "albuquerque",
- IP6Address: "2001:558:fe18:7::2/64",
- IP6Gateway: "2001:558:fe18:7::1",
- IPAddress: "10.10.10.10",
- IPGateway: "10.10.10.10",
- IPNetmask: "255.255.255.252",
- MgmtIPAddress: "",
- MgmtIPNetmask: "",
- MgmtIPGateway: "",
- Status: "REPORTED",
- XMPPID: "edge-alb-01",
- XMPPPasswd: "**********",
- IloIPAddress: "10.10.10.10",
- IloUsername: "vssilo",
- IloPassword: "password",
- IloIPGateway: "10.10.10.10",
- IloIPNetmask: "255.255.255.192",
- InterfaceName: "bond0",
- InterfaceMtu: 9000,
- RouterPortName: "TenGigE0/3/0/10\t|\tBundle-Ether1000\t|\tPHY|10G|AGG-MEMBER|dtype:IPCDN-EDGE|rhost:edge-alb-01|rport:eth1|lagg:1000",
- RouterHostName: "ar01.albuquerque.nm.albuq.kabletown.com",
- LastUpdated: "2015-03-27 17:00:30",
- },
- {
- ID: 002,
- HostName: "edge-alb-02",
- DomainName: "albuquerque.nm.albuq.kabletown.com",
- CDNName: "CDN-1",
- Type: "EDGE",
- Profile: "EDGE1_XCR_520",
- TCPPort: 80,
- Rack: "F-4/38",
- PhysLocation: "Albuquerque",
- Cachegroup: "us-nm-albuquerque",
- IP6Address: "2001:558:FE18:8::2/64",
- IP6Gateway: "2001:558:fe18:8::1",
- IPAddress: "10.10.10.10",
- IPGateway: "10.10.10.10",
- IPNetmask: "255.255.255.252",
- MgmtIPAddress: "",
- MgmtIPNetmask: "",
- MgmtIPGateway: "",
- Status: "REPORTED",
- XMPPID: "edge-alb-02",
- XMPPPasswd: "**********",
- IloIPAddress: "10.10.10.10",
- IloUsername: "vssilo",
- IloPassword: "password",
- IloIPGateway: "10.10.10.10",
- IloIPNetmask: "255.255.255.192",
- InterfaceName: "bond0",
- InterfaceMtu: 9000,
- RouterPortName: "TenGigE0/3/0/10\t|\tBundle-Ether1000\t|\tPHY|10G|AGG-MEMBER|dtype:IPCDN-EDGE|rhost:edge-alb-02|rport:eth1|lagg:1000",
- RouterHostName: "ar02.albuquerque.nm.albuq.kabletown.com",
- LastUpdated: "2015-03-27 17:00:34",
- },
- {
- ID: 003,
- HostName: "atlanta-mid-01",
- DomainName: "ga.atlanta.kabletown.net",
- CDNName: "CDN-1",
- Type: "MID",
- Profile: "MID1",
- TCPPort: 80,
- Rack: "F-4/38",
- PhysLocation: "Denver",
- Cachegroup: "mid-northeast-group",
- IP6Address: "2001:558:FE18:8::2/64",
- IP6Gateway: "2001:558:fe18:8::1",
- IPAddress: "12.12.12.12",
- IPGateway: "12.12.12.12",
- IPNetmask: "255.255.255.252",
- MgmtIPAddress: "",
- MgmtIPNetmask: "",
- MgmtIPGateway: "",
- Status: "ONLINE",
- XMPPID: "atlanta-mid-01",
- XMPPPasswd: "**********",
- IloIPAddress: "",
- IloUsername: "",
- IloPassword: "",
- IloIPGateway: "1",
- IloIPNetmask: "",
- InterfaceName: "bond0",
- InterfaceMtu: 9000,
- RouterPortName: "",
- RouterHostName: "",
- LastUpdated: "2015-03-27 17:00:34",
- },
- },
- }
-}
-
-// LogstashServers returns a default ServerResponse to be used for testing.
-func LogstashServers() *client.ServerResponse {
- return &client.ServerResponse{
- Response: []client.Server{
- {
- ID: 004,
- HostName: "logstash-01",
- DomainName: "albuquerque.nm.albuq.kabletown.com",
- CDNName: "CDN-2",
- Type: "LOGSTASH",
- Profile: "LOGSTASH_ATS",
- IPAddress: "10.10.10.10",
- },
- {
- ID: 005,
- HostName: "logstash-02",
- DomainName: "albuquerque.nm.albuq.kabletown.com",
- CDNName: "CDN-2",
- Type: "LOGSTASH",
- Profile: "LOGSTASH_ATS",
- IPAddress: "10.10.10.10",
- },
- },
- }
-}
-
-// Server returns a default ServerResponse to be used for testing.
-func Server() *client.ServerDetailResponse {
- return &client.ServerDetailResponse{
- Response: client.Server{
- ID: 001,
- HostName: "edge-alb-01",
- DomainName: "albuquerque.nm.albuq.kabletown.com",
- CDNName: "CDN-1",
- Type: "EDGE",
- Profile: "EDGE1_CDN_520",
- TCPPort: 80,
- Rack: "F-4/35",
- PhysLocation: "Albuquerque",
- Cachegroup: "albuquerque",
- IP6Address: "2001:558:fe18:7::2/64",
- IP6Gateway: "2001:558:fe18:7::1",
- IPAddress: "10.10.10.10",
- IPGateway: "10.10.10.10",
- IPNetmask: "255.255.255.252",
- MgmtIPAddress: "",
- MgmtIPNetmask: "",
- MgmtIPGateway: "",
- Status: "REPORTED",
- XMPPID: "edge-alb-01",
- XMPPPasswd: "**********",
- IloIPAddress: "10.10.10.10",
- IloUsername: "vssilo",
- IloPassword: "password",
- IloIPGateway: "10.10.10.10",
- IloIPNetmask: "255.255.255.192",
- InterfaceName: "bond0",
- InterfaceMtu: 9000,
- RouterPortName: "TenGigE0/3/0/10\t|\tBundle-Ether1000\t|\tPHY|10G|AGG-MEMBER|dtype:IPCDN-EDGE|rhost:edge-alb-01|rport:eth1|lagg:1000",
- RouterHostName: "ar01.albuquerque.nm.albuq.kabletown.com",
- LastUpdated: "2015-03-27 17:00:30",
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/stats_summary.go b/traffic_ops/client_tests/fixtures/stats_summary.go
deleted file mode 100644
index bcc7470..0000000
--- a/traffic_ops/client_tests/fixtures/stats_summary.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// StatsSummary returns a default StatsSummaryResponse to be used for testing.
-func StatsSummary() *client.StatsSummaryResponse {
- return &client.StatsSummaryResponse{
- Response: []client.StatsSummary{
- client.StatsSummary{
- SummaryTime: "2015-05-14 14:39:47",
- DeliveryService: "test-ds1",
- StatName: "test-stat",
- StatValue: "3.1415",
- CDNName: "test-cdn",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/tenant.go b/traffic_ops/client_tests/fixtures/tenant.go
deleted file mode 100644
index 6b1c379..0000000
--- a/traffic_ops/client_tests/fixtures/tenant.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import tc "github.com/apache/incubator-trafficcontrol/lib/go-tc"
-
-// Tenants returns a default DeliveryServiceResponse to be used for testing.
-func Tenants() *tc.GetTenantsResponse {
- return &tc.GetTenantsResponse{
- Response: []tc.Tenant{
- tc.Tenant{
- ID: 1,
- Active: true,
- Name: "test-tenant",
- ParentName: "test-tenant-parent",
- ParentID: 2,
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/traffic_monitor_config.go b/traffic_ops/client_tests/fixtures/traffic_monitor_config.go
deleted file mode 100644
index 1d16182..0000000
--- a/traffic_ops/client_tests/fixtures/traffic_monitor_config.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package fixtures
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// TrafficMonitorConfig returns a default TMConfigResponse to be used for testing.
-func TrafficMonitorConfig() *client.TMConfigResponse {
- return &client.TMConfigResponse{
- Response: client.TrafficMonitorConfig{
- TrafficServers: []client.TrafficServer{
- client.TrafficServer{
- Profile: "TR_CDN",
- IP: "10.10.10.10",
- Status: "OFFLINE",
- CacheGroup: "tr-chicago",
- IP6: "2001:123:abc12:64:22:::17/64",
- Port: 80,
- HostName: "tr-chi-05",
- FQDN: "tr-chi-05.kabletown.com",
- InterfaceName: "eth0",
- Type: "TR",
- HashID: "chi-tr-05",
- },
- client.TrafficServer{
- Profile: "EDGE1_CDN",
- IP: "3.3.3.3",
- Status: "OFFLINE",
- CacheGroup: "philadelphia",
- IP6: "2009:123:456::2/64",
- Port: 80,
- HostName: "edge-test-01",
- FQDN: "edge-test-01.kabletown.com",
- InterfaceName: "bond0",
- Type: "EDGE",
- HashID: "edge-test-01",
- },
- },
- CacheGroups: []client.TMCacheGroup{
- client.TMCacheGroup{
- Name: "philadelphia",
- Coordinates: client.Coordinates{
- Longitude: 5,
- Latitude: 55,
- },
- },
- client.TMCacheGroup{
- Name: "tr-chicago",
- Coordinates: client.Coordinates{
- Longitude: 9,
- Latitude: 99,
- },
- },
- },
- Config: map[string]interface{}{
- "health.event-count": 200,
- "hack.ttl": 30,
- "health.threadPool": 4,
- "peers.polling.interval": 1000,
- },
- TrafficMonitors: []client.TrafficMonitor{
- client.TrafficMonitor{
- Port: 80,
- IP6: "",
- IP: "1.1.1.1",
- HostName: "traffic-monitor-01",
- FQDN: "traffic-monitor-01@example.com",
- Profile: "tm-123",
- Location: "philadelphia",
- Status: "ONLINE",
- },
- },
- DeliveryServices: []client.TMDeliveryService{
- client.TMDeliveryService{
- XMLID: "ds-05",
- TotalTPSThreshold: 0,
- Status: "REPORTED",
- TotalKbpsThreshold: 0,
- },
- },
- Profiles: []client.TMProfile{
- client.TMProfile{
- Name: "tm-123",
- Type: "TR",
- Parameters: client.TMParameters{
- HealthConnectionTimeout: 2000,
- HealthPollingURL: "http://${hostname}/_astats?application=&inf.name=${interface_name}",
- HistoryCount: 30,
- MinFreeKbps: 11500000,
- Thresholds: map[string]client.HealthThreshold{
- "queryTime": client.HealthThreshold{
- Val: 1000,
- Comparator: "<",
- },
- "availableBandwidthInKbps": client.HealthThreshold{
- Val: 1750000,
- Comparator: "<",
- },
- "loadavg": client.HealthThreshold{
- Val: 25.0,
- Comparator: "<",
- },
- },
- },
- },
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/traffic_router_config.go b/traffic_ops/client_tests/fixtures/traffic_router_config.go
deleted file mode 100644
index 82ee5fe..0000000
--- a/traffic_ops/client_tests/fixtures/traffic_router_config.go
+++ /dev/null
@@ -1,163 +0,0 @@
-package fixtures
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// TrafficRouterConfig returns a default TRConfigResponse to be used for testing.
-func TrafficRouterConfig() *client.TRConfigResponse {
- return &client.TRConfigResponse{
- Response: client.TrafficRouterConfig{
- TrafficServers: []client.TrafficServer{
- client.TrafficServer{
- Profile: "TR_CDN",
- IP: "10.10.10.10",
- Status: "OFFLINE",
- CacheGroup: "tr-chicago",
- IP6: "2001:123:abc12:64:22:::17/64",
- Port: 80,
- HostName: "tr-chi-05",
- FQDN: "tr-chi-05.kabletown.com",
- InterfaceName: "eth0",
- Type: "TR",
- HashID: "chi-tr-05",
- },
- client.TrafficServer{
- Profile: "EDGE1_CDN",
- IP: "3.3.3.3",
- Status: "OFFLINE",
- CacheGroup: "philadelphia",
- IP6: "2009:123:456::2/64",
- Port: 80,
- HostName: "edge-test-01",
- FQDN: "edge-test-01.kabletown.com",
- InterfaceName: "bond0",
- Type: "EDGE",
- HashID: "edge-test-01",
- },
- },
- TrafficMonitors: []client.TrafficMonitor{
- client.TrafficMonitor{
- Port: 80,
- IP6: "",
- IP: "1.1.1.1",
- HostName: "traffic-monitor-01",
- FQDN: "traffic-monitor-01@example.com",
- Profile: "tr-123",
- Location: "philadelphia",
- Status: "ONLINE",
- },
- },
- CacheGroups: []client.TMCacheGroup{
- client.TMCacheGroup{
- Name: "philadelphia",
- Coordinates: client.Coordinates{
- Longitude: 88,
- Latitude: 99,
- },
- },
- client.TMCacheGroup{
- Name: "tr-chicago",
- Coordinates: client.Coordinates{
- Longitude: 9,
- Latitude: 99,
- },
- },
- },
- Config: map[string]interface{}{
- "health.event-count": 200,
- "hack.ttl": 30,
- "health.threadPool": 4,
- "peers.polling.interval": 1000,
- },
- Stats: map[string]interface{}{
- "date": 1459371078,
- "cdnName": "test-cdn",
- "trafficOpsHost": "127.0.0.1:3000",
- "trafficOpsPath": "/api/1.2/cdns/title-vi/configs/routing.json",
- "trafficOpsVersion": "__VERSION__",
- "trafficOpsUser": "bob",
- },
- TrafficRouters: []client.TrafficRouter{
- client.TrafficRouter{
- Port: 6789,
- IP6: "2345:1234:12:8::2/64",
- IP: "127.0.0.1",
- FQDN: "tr-01@ga.atlanta.kabletown.net",
- Profile: "tr-123",
- Location: "tr-chicago",
- Status: "ONLINE",
- APIPort: 3333,
- },
- },
- DeliveryServices: []client.TRDeliveryService{
- client.TRDeliveryService{
- XMLID: "ds-06",
- Domains: []string{
- "ga.atlanta.kabletown.net",
- },
- RoutingName: "edge",
- DeepCachingType: "NEVER",
- MissLocation: client.MissLocation{
- Latitude: 75,
- Longitude: 65,
- },
- CoverageZoneOnly: true,
- MatchSets: []client.MatchSet{
- client.MatchSet{
- Protocol: "HTTP",
- MatchList: []client.MatchList{
- client.MatchList{
- Regex: ".*\\.ds-06\\..*",
- MatchType: "HOST",
- },
- },
- },
- },
- TTL: 3600,
- TTLs: client.TTLS{
- Arecord: 3600,
- SoaRecord: 86400,
- NsRecord: 3600,
- AaaaRecord: 3600,
- },
- BypassDestination: client.BypassDestination{
- Type: "HTTP",
- },
- StatcDNSEntries: []client.StaticDNS{
- client.StaticDNS{
- Value: "1.1.1.1",
- TTL: 30,
- Name: "mm",
- Type: "A",
- },
- },
- Soa: client.SOA{
- Admin: "admin",
- Retry: 7200,
- Minimum: 30,
- Refresh: 7200,
- Expire: 604800,
- },
- },
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/types.go b/traffic_ops/client_tests/fixtures/types.go
deleted file mode 100644
index ef77346..0000000
--- a/traffic_ops/client_tests/fixtures/types.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// Types returns a default TypeResponse to be used for testing.
-func Types() *client.TypeResponse {
- return &client.TypeResponse{
- Response: []client.Type{
- client.Type{
- ID: 1,
- Name: "EDGE",
- Description: "edge cache",
- UseInTable: "server",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/update.go b/traffic_ops/client_tests/fixtures/update.go
deleted file mode 100644
index bfb204c..0000000
--- a/traffic_ops/client_tests/fixtures/update.go
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// CDNs returns a default CDNResponse to be used for testing.
-func Update() client.Update {
- return client.Update{
- UpdatePending: true,
- ParentPending: false,
- RevalPending: true,
- ParentRevalPending: false,
- Status: "REPORTED",
- HostID: 42,
- HostName: "edge-cache-0",
- }
-}
diff --git a/traffic_ops/client_tests/fixtures/user.go b/traffic_ops/client_tests/fixtures/user.go
deleted file mode 100644
index b70a3e8..0000000
--- a/traffic_ops/client_tests/fixtures/user.go
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fixtures
-
-import "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-
-// Users returns a default UserResponse to be used for testing.
-func Users() *client.UserResponse {
- return &client.UserResponse{
- Response: []client.User{
- client.User{
- Username: "bsmith",
- PublicSSHKey: "some-ssh-key",
- Role: 3,
- RoleName: "operations",
- Email: "bobsmith@email.com",
- FullName: "Bob Smith",
- },
- },
- }
-}
diff --git a/traffic_ops/client_tests/http.go b/traffic_ops/client_tests/http.go
deleted file mode 100644
index affdcd3..0000000
--- a/traffic_ops/client_tests/http.go
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2015 Comcast Cable Communications Management, LLC
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package client
-
-import (
- "encoding/json"
- "net/http"
- "net/http/httptest"
-)
-
-// ValidHTTPServer starts and returns a new test server. Always
-// responds with a statusCode of 200 and the specified payload.
-func ValidHTTPServer(resp interface{}) *httptest.Server {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- w.WriteHeader(http.StatusOK)
- w.Header().Set("Content-Type", "application/json")
- json.NewEncoder(w).Encode(resp)
- }))
- return server
-}
-
-// InvalidHTTPServer starts and returns a new test server.
-// Responds with the specified statusCode.
-func InvalidHTTPServer(statusCode int) *httptest.Server {
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- w.WriteHeader(statusCode)
- w.Header().Set("Content-Type", "application/json")
- }))
- return server
-}
diff --git a/traffic_ops/client_tests/tenant_endpoints_test.go b/traffic_ops/client_tests/tenant_endpoints_test.go
deleted file mode 100644
index fc8ebdd..0000000
--- a/traffic_ops/client_tests/tenant_endpoints_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package client
-
-import (
- "testing"
-)
-
-func TestDeliveryTenantsEp(t *testing.T) {
- test_helper.Context(t, "Given the need to test that DeliveryServices uses the correct URL")
-
- ep := tenantsEp()
- expected := "/api/1.2/tenants"
- if ep != expected {
- test_helper.Error(t, "Should get back %s for \"tenantsEp\", got: %s", expected, ep)
- } else {
- test_helper.Success(t, "Should be able to get the correct tenants endpoint")
- }
-}
diff --git a/traffic_ops/client_tests/test.go b/traffic_ops/client_tests/test.go
deleted file mode 100644
index f00d159..0000000
--- a/traffic_ops/client_tests/test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Copyright 2015 Comcast Cable Communications Management, LLC
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package client
-
-import (
- "fmt"
- "testing"
-
- "github.com/cihub/seelog"
-)
-
-// Succeed is the Unicode codepoint for a check mark.
-const Succeed = "\u2713"
-
-// Failed is the Unicode codepoint for an X mark.
-const Failed = "\u2717"
-
-func init() {
- // An example seelog.xml is located at conf/seelog.xml
- // If you want to use this config - copy it to your project
- seelogConfig := "conf/seelog.xml.test"
- logger, err := seelog.LoggerFromConfigAsFile(seelogConfig)
- if err != nil {
- err := fmt.Errorf("FOO Error creating Logger from seelog file: %s", seelogConfig)
- seelog.Error(err)
- }
- defer seelog.Flush()
- seelog.ReplaceLogger(logger)
-}
-
-// Context is a summary of the test being run.
-func Context(t *testing.T, msg string, args ...interface{}) {
- t.Log(fmt.Sprintf(msg, args...))
-}
-
-// Fatal contains details of a failed test and stops its execution.
-func Fatal(t *testing.T, msg string, args ...interface{}) {
- m := fmt.Sprintf(msg, args...)
- t.Fatal(fmt.Sprintf("\t %-80s", m), Failed)
-}
-
-// Error contails details of a failed test and continues execution.
-func Error(t *testing.T, msg string, args ...interface{}) {
- m := fmt.Sprintf(msg, args...)
- t.Error(fmt.Sprintf("\t %-80s", m), Failed)
-}
-
-// Success contains details of a successful test.
-func Success(t *testing.T, msg string, args ...interface{}) {
- m := fmt.Sprintf(msg, args...)
- t.Log(fmt.Sprintf("\t %-80s", m), Succeed)
-}
diff --git a/traffic_ops/client_tests/tests/cachegroup_test.go b/traffic_ops/client_tests/tests/cachegroup_test.go
deleted file mode 100644
index 1bb9865..0000000
--- a/traffic_ops/client_tests/tests/cachegroup_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestCacheGroup(t *testing.T) {
- resp := fixtures.Cachegroups()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for CacheGroups")
-
- cacheGroups, err := to.CacheGroups()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(cacheGroups) != 1 {
- testHelper.Error(t, "Should get back \"1\" CacheGroups, got: %d", len(cacheGroups))
- } else {
- testHelper.Success(t, "Should get back \"1\" CacheGroups")
- }
-
- for _, cacheGroup := range cacheGroups {
- if cacheGroup.Name == "" {
- testHelper.Error(t, "Should get back \"edge-philadelphia\" for \"Name\", got: %s", cacheGroup.Name)
- } else {
- testHelper.Success(t, "Should get back \"edge-philadelphia\" for \"Name\"")
- }
-
- if cacheGroup.Longitude != -5.66 {
- testHelper.Error(t, "Should get back \"-5.66\" for \"Longitude\", got: %v", cacheGroup.Longitude)
- } else {
- testHelper.Success(t, "Should get back \"-5.66\" for \"Longitude\"")
- }
-
- if cacheGroup.Latitude != 55.67 {
- testHelper.Error(t, "Should get back \"55.67\" for \"Latitude\", got: %v", cacheGroup.Latitude)
- } else {
- testHelper.Success(t, "Should get back \"55.67\" for \"Latitude\"")
- }
-
- if cacheGroup.ParentName != "mid-northeast" {
- testHelper.Error(t, "Should get back \"mid-northeast\" for \"ParentName\", got: %s", cacheGroup.ParentName)
- } else {
- testHelper.Success(t, "Should get back \"mid-northeast\" for \"ParentName\"")
- }
- }
-}
-
-func TestCacheGroupsUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for CacheGroups")
-
- _, err := to.CacheGroups()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/cdn_test.go b/traffic_ops/client_tests/tests/cdn_test.go
deleted file mode 100644
index cf3a1fb..0000000
--- a/traffic_ops/client_tests/tests/cdn_test.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestCDNs(t *testing.T) {
- resp := fixtures.CDNs()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for CDNs")
-
- cdns, err := to.CDNs()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- for _, cdn := range cdns {
- if cdn.ID != 1 {
- testHelper.Error(t, "Should get back 1 for \"ID\", got %d", cdn.ID)
- } else {
- testHelper.Success(t, "Should get back 1 for \"ID\"")
- }
- if cdn.Name != "CDN-1" {
- testHelper.Error(t, "Should get back \"CDN-1\" for \"name\", got %s", cdn.Name)
- } else {
- testHelper.Success(t, "Should get back \"CDN-1\" for \"name\"")
- }
-
- if cdn.LastUpdated != "2016-03-22 17:00:30" {
- testHelper.Error(t, "Should get back \"2016-03-22 17:00:30\" for \"LastUpdated\", got %s", cdn.LastUpdated)
- } else {
- testHelper.Success(t, "Should get back \"2016-03-22 17:00:30\" for \"LastUpdated\"")
- }
- }
-}
-
-func TestCDNsUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for CDNs")
-
- _, err := to.CDNs()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestCDNName(t *testing.T) {
- resp := fixtures.CDNs()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- cdn := "CDN-1"
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for CDN: \"%s\"", cdn)
-
- cdns, err := to.CDNName(cdn)
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- for _, cdn := range cdns {
- if cdn.Name != "CDN-1" {
- testHelper.Error(t, "Should get back \"CDN-1\" for \"name\", got %s", cdn.Name)
- } else {
- testHelper.Success(t, "Should get back \"CDN-1\" for \"name\"")
- }
-
- if cdn.LastUpdated != "2016-03-22 17:00:30" {
- testHelper.Error(t, "Should get back \"2016-03-22 17:00:30\" for \"LastUpdated\", got %s", cdn.LastUpdated)
- } else {
- testHelper.Success(t, "Should get back \"2016-03-22 17:00:30\" for \"LastUpdated\"")
- }
- }
-}
-
-func TestCDNNameUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- cdn := "CDN-1"
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for CDN: \"%s\"", cdn)
-
- _, err := to.CDNName(cdn)
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/conf/seelog.xml.test b/traffic_ops/client_tests/tests/conf/seelog.xml.test
deleted file mode 100644
index 08facaf..0000000
--- a/traffic_ops/client_tests/tests/conf/seelog.xml.test
+++ /dev/null
@@ -1,9 +0,0 @@
-<seelog>
- <outputs formatid="main">
- <file path="logs/test.log" />
- </outputs>
-
- <formats>
- <format id="main" format="[%Level] %Date(2006/01/02 15:04:05.0000) %File:%Line %FuncShort: %Msg%n"/>
- </formats>
-</seelog>
diff --git a/traffic_ops/client_tests/tests/delivery_service_test.go b/traffic_ops/client_tests/tests/delivery_service_test.go
deleted file mode 100644
index dde3adb..0000000
--- a/traffic_ops/client_tests/tests/delivery_service_test.go
+++ /dev/null
@@ -1,660 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestDeliveryServices(t *testing.T) {
- resp := fixtures.DeliveryServices()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for DeliveryServices")
-
- ds, err := to.DeliveryServices()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(ds) != 1 {
- testHelper.Error(t, "Should get back \"1\" DeliveryService, got: %d", len(ds))
- } else {
- testHelper.Success(t, "Should get back \"1\" DeliveryService")
- }
-
- for _, s := range ds {
- if s.XMLID != "ds-test" {
- testHelper.Error(t, "Should get back \"ds-test\" for \"XMLID\", got: %s", s.XMLID)
- } else {
- testHelper.Success(t, "Should get back \"ds-test\" for \"XMLID\"")
- }
-
- if s.MissLong != -99.123456 {
- testHelper.Error(t, "Should get back \"-99.123456\" for \"MissLong\", got: %s", s.MissLong)
- } else {
- testHelper.Success(t, "Should get back \"-99.123456\" for \"MissLong\"")
- }
- }
-}
-
-func TestDeliveryServicesUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for DeliveryServices")
-
- _, err := to.DeliveryServices()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryService(t *testing.T) {
- resp := fixtures.DeliveryServices()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryService")
-
- ds, err := to.DeliveryService("123")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if ds.XMLID != "ds-test" {
- testHelper.Error(t, "Should get back \"ds-test\" for \"XMLID\", got: %s", ds.XMLID)
- } else {
- testHelper.Success(t, "Should get back \"ds-test\" for \"XMLID\"")
- }
-
- if ds.MissLong != -99.123456 {
- testHelper.Error(t, "Should get back \"-99.123456\" for \"MissLong\", got: %s", ds.MissLong)
- } else {
- testHelper.Success(t, "Should get back \"-99.123456\" for \"MissLong\"")
- }
-}
-
-func TestDeliveryServiceUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryService")
-
- _, err := to.DeliveryService("123")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestCreateDeliveryService(t *testing.T) {
- resp := fixtures.CreateDeliveryService()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request to create a DeliveryService")
-
- ds, err := to.CreateDeliveryService(&client.DeliveryService{})
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- actual := ds.Response[0].ID
- if actual != 001 {
- testHelper.Error(t, "Should get back \"001\" for \"Response.ID\", got: %s", actual)
- } else {
- testHelper.Success(t, "Should get back \"0001\" for \"Response.ID\"")
- }
-}
-
-func TestCreateDeliveryServiceUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request to create a DeliveryService")
-
- _, err := to.CreateDeliveryService(&client.DeliveryService{})
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestUpdateDeliveryService(t *testing.T) {
- resp := fixtures.UpdateDeliveryService()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request to update a DeliveryService")
-
- ds, err := to.UpdateDeliveryService("123", &client.DeliveryService{})
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- actual := ds.Response[0].ID
- if actual != 001 {
- testHelper.Error(t, "Should get back \"001\" for \"Response.ID\", got: %s", actual)
- } else {
- testHelper.Success(t, "Should get back \"0001\" for \"Response.ID\"")
- }
-}
-
-func TestUpdateDeliveryServiceUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request to update a DeliveryService")
-
- _, err := to.UpdateDeliveryService("123", &client.DeliveryService{})
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeleteDeliveryService(t *testing.T) {
- resp := fixtures.DeleteDeliveryService()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request to delete a DeliveryService")
-
- ds, err := to.DeleteDeliveryService("123")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- actual := ds.Alerts[0].Text
- if actual != "text" {
- testHelper.Error(t, "Should get back \"text\" for \"Alerts[0].Text\", got: %s", actual)
- } else {
- testHelper.Success(t, "Should get back \"text\" for \"Alerts[0].Text\"")
- }
-}
-
-func TestDeleteDeliveryServiceUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request to delete a DeliveryService")
-
- _, err := to.DeleteDeliveryService("123")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryServiceState(t *testing.T) {
- resp := fixtures.DeliveryServiceState()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceState")
-
- state, err := to.DeliveryServiceState("123")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if state.Failover.Destination.Location != "someLocation" {
- testHelper.Error(t, "Should get back \"someLocation\" for \"Failover.Destination.Location\", got: %s", state.Failover.Destination.Location)
- } else {
- testHelper.Success(t, "Should get back \"someLocation\" for \"Failover.Destination.Location\"")
- }
-
- if state.Enabled != true {
- testHelper.Error(t, "Should get back \"true\" for \"Enabled\", got: %s", state.Enabled)
- } else {
- testHelper.Success(t, "Should get back \"true\" for \"Enabled\"")
- }
-}
-
-func TestDeliveryServiceStateUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryServiceState")
-
- _, err := to.DeliveryServiceState("123")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryServiceHealth(t *testing.T) {
- resp := fixtures.DeliveryServiceHealth()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceHealth")
-
- health, err := to.DeliveryServiceHealth("123")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if health.TotalOnline != 2 {
- testHelper.Error(t, "Should get back \"2\" for \"TotalOnline\", got: %s", health.TotalOnline)
- } else {
- testHelper.Success(t, "Should get back \"2\" for \"TotalOnline\"")
- }
-
- if health.TotalOffline != 3 {
- testHelper.Error(t, "Should get back \"3\" for \"TotalOffline\", got: %s", health.TotalOffline)
- } else {
- testHelper.Success(t, "Should get back \"2\" for \"TotalOffline\"")
- }
-
- if health.CacheGroups[0].Name != "someCacheGroup" {
- testHelper.Error(t, "Should get back \"someCacheGroup\" for \"CacheGroups[0].Name\", got: %s", health.CacheGroups[0].Name)
- } else {
- testHelper.Success(t, "Should get back \"someCacheGroup\" for \"CacheGroups[0].Name\"")
- }
-}
-
-func TestDeliveryServiceHealthUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryServiceHealth")
-
- _, err := to.DeliveryServiceHealth("123")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryServiceCapacity(t *testing.T) {
- resp := fixtures.DeliveryServiceCapacity()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceCapacity")
-
- capacity, err := to.DeliveryServiceCapacity("123")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if capacity.AvailablePercent != 90.12345 {
- testHelper.Error(t, "Should get back \"90.12345\" for \"AvailablePercent\", got: %s", capacity.AvailablePercent)
- } else {
- testHelper.Success(t, "Should get back \"90.12345\" for \"AvailablePercent\"")
- }
-
- if capacity.UnavailablePercent != 90.12345 {
- testHelper.Error(t, "Should get back \"90.12345\" for \"UnavailablePercent\", got: %s", capacity.UnavailablePercent)
- } else {
- testHelper.Success(t, "Should get back \"90.12345\" for \"UnavailablePercent\"")
- }
-
- if capacity.UtilizedPercent != 90.12345 {
- testHelper.Error(t, "Should get back \"90.12345\" for \"UtilizedPercent\", got: %s", capacity.UtilizedPercent)
- } else {
- testHelper.Success(t, "Should get back \"90.12345\" for \"UtilizedPercent\"")
- }
-}
-
-func TestDeliveryServiceCapacityUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryServiceCapacity")
-
- _, err := to.DeliveryServiceCapacity("123")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryServiceRouting(t *testing.T) {
- resp := fixtures.DeliveryServiceRouting()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceRouting")
-
- routing, err := to.DeliveryServiceRouting("123")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if routing.StaticRoute != 1 {
- testHelper.Error(t, "Should get back \"1\" for \"StaticRoute\", got: %s", routing.StaticRoute)
- } else {
- testHelper.Success(t, "Should get back \"1\" for \"StaticRoute\"")
- }
-}
-
-func TestDeliveryServiceRoutingUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryServiceRouting")
-
- _, err := to.DeliveryServiceRouting("123")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryServicesByServers(t *testing.T) {
- resp := fixtures.DeliveryServicesByServer()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for DeliveryServices")
-
- ds, err := to.DeliveryServicesByServer(42)
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(ds) != 1 {
- testHelper.Error(t, "Should get back \"1\" DeliveryService, got: %d", len(ds))
- } else {
- testHelper.Success(t, "Should get back \"1\" DeliveryService")
- }
-
- for _, s := range ds {
- if s.XMLID != "ds-test" {
- testHelper.Error(t, "Should get back \"ds-test\" for \"XMLID\", got: %s", s.XMLID)
- } else {
- testHelper.Success(t, "Should get back \"ds-test\" for \"XMLID\"")
- }
-
- if s.MissLong != -99.123456 {
- testHelper.Error(t, "Should get back \"-99.123456\" for \"MissLong\", got: %s", s.MissLong)
- } else {
- testHelper.Success(t, "Should get back \"-99.123456\" for \"MissLong\"")
- }
- }
-}
-
-func TestDeliveryServiceRegexes(t *testing.T) {
- resp := fixtures.DeliveryServiceRegexes()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceServer")
-
- s, err := to.DeliveryServiceRegexes()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(s) != 1 {
- testHelper.Error(t, "Should get back \"1\" Regexes, got: %d", len(s))
- } else {
- testHelper.Success(t, "Should get back \"1\" Regexes")
- }
-
- if s[0].DSName != "dsname" {
- testHelper.Error(t, "Should get back \"dsname\" for \"DSName\", got: %s", s[0].DSName)
- } else {
- testHelper.Success(t, "Should get back \"lastUpdated\" for \"LastUpdated\"")
- }
-
- if len(s[0].Regexes) != 1 {
- testHelper.Error(t, "Should get back \"1\" Regex, got: %d", len(s[0].Regexes))
- } else {
- testHelper.Success(t, "Should get back \"1\" Regex")
- }
-
- if s[0].Regexes[0].Type != "type" {
- testHelper.Error(t, "Should get back \"type\" for \"Type\", got: %s", s[0].Regexes[0].Type)
- } else {
- testHelper.Success(t, "Should get back \"type\" for \"Type\"")
- }
-
- if s[0].Regexes[0].SetNumber != 42 {
- testHelper.Error(t, "Should get back 42 for \"SetNumber\", got: %s", s[0].Regexes[0].SetNumber)
- } else {
- testHelper.Success(t, "Should get back 42 for \"SetNumber\"")
- }
-
- if s[0].Regexes[0].Pattern != "pattern" {
- testHelper.Error(t, "Should get back \"pattern\" for \"Pattern\", got: %s", s[0].Regexes[0].Pattern)
- } else {
- testHelper.Success(t, "Should get back \"pattern\" for \"Pattern\"")
- }
-}
-
-func TestDeliveryServiceServer(t *testing.T) {
- resp := fixtures.DeliveryServiceServer()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceServer")
-
- s, err := to.DeliveryServiceServer("1", "1")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if s[0].LastUpdated != "lastUpdated" {
- testHelper.Error(t, "Should get back \"lastUpdated\" for \"LastUpdated\", got: %s", s[0].LastUpdated)
- } else {
- testHelper.Success(t, "Should get back \"lastUpdated\" for \"LastUpdated\"")
- }
-
- if s[0].Server != 1 {
- testHelper.Error(t, "Should get back 1 for \"Server\", got: %s", s[0].Server)
- } else {
- testHelper.Success(t, "Should get back 1 for \"Server\"")
- }
-
- if s[0].DeliveryService != 1 {
- testHelper.Error(t, "Should get back 1 for \"DeliveryService\", got: %s", s[0].DeliveryService)
- } else {
- testHelper.Success(t, "Should get back 1 for \"DeliveryService\"")
- }
-}
-
-func TestDeliveryServiceServerUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryServiceServer")
-
- _, err := to.DeliveryServiceServer("1", "1")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryServiceSSLKeysByID(t *testing.T) {
- resp := fixtures.DeliveryServiceSSLKeys()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceSSLKeysByID")
-
- ssl, err := to.DeliveryServiceSSLKeysByID("123")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if ssl.Certificate.Crt != "crt" {
- testHelper.Error(t, "Should get back \"crt\" for \"Certificte.Crt\", got: %s", ssl.Certificate.Crt)
- } else {
- testHelper.Success(t, "Should get back \"crt\" for \"Certificate.Crt\"")
- }
-
- if ssl.Organization != "Kabletown" {
- testHelper.Error(t, "Should get back \"Kabletown\" for \"Organization\", got: %s", ssl.Organization)
- } else {
- testHelper.Success(t, "Should get back \"Kabletown\" for \"Organization\"")
- }
-}
-
-func TestDeliveryServiceSSLKeysByIDUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryServiceSSLKeysByID")
-
- _, err := to.DeliveryServiceSSLKeysByID("123")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestDeliveryServiceSSLKeysByHostname(t *testing.T) {
- resp := fixtures.DeliveryServiceSSLKeys()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for a DeliveryServiceSSLKeysByHostname")
-
- ssl, err := to.DeliveryServiceSSLKeysByHostname("hostname")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if ssl.Certificate.Crt != "crt" {
- testHelper.Error(t, "Should get back \"crt\" for \"Certificte.Crt\", got: %s", ssl.Certificate.Crt)
- } else {
- testHelper.Success(t, "Should get back \"crt\" for \"Certificate.Crt\"")
- }
-
- if ssl.Organization != "Kabletown" {
- testHelper.Error(t, "Should get back \"Kabletown\" for \"Organization\", got: %s", ssl.Organization)
- } else {
- testHelper.Success(t, "Should get back \"Kabletown\" for \"Organization\"")
- }
-}
-
-func TestDeliveryServiceSSLKeysByHostnameUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for a DeliveryServiceSSLKeysByHostname")
-
- _, err := to.DeliveryServiceSSLKeysByHostname("hostname")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/hardware_test.go b/traffic_ops/client_tests/tests/hardware_test.go
deleted file mode 100644
index 091d431..0000000
--- a/traffic_ops/client_tests/tests/hardware_test.go
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "strings"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestHardware(t *testing.T) {
- resp := fixtures.Hardware()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Hardware")
-
- hardware, err := to.Hardware(0)
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(hardware) != 2 {
- testHelper.Error(t, "Should get back \"2\" Hardware, got: %d", len(hardware))
- } else {
- testHelper.Success(t, "Should get back \"2\" Hardware")
- }
-
- for _, h := range hardware {
- if !strings.Contains(h.HostName, "edge-den") {
- testHelper.Error(t, "Should get back \"edge-den\" in \"Hostname\", got: %s", h.HostName)
- } else {
- testHelper.Success(t, "Should get back \"edge-den\" in \"Hostname\"")
- }
-
- if !strings.Contains(h.Value, "DIS") {
- testHelper.Error(t, "Should get back \"DIS1\" or \"DIS2\" for \"Value\", got: %s", h.Value)
- } else {
- testHelper.Success(t, "Should get back \"DIS1\" or \"DIS2\" for \"Value\"")
- }
-
- if !strings.Contains(h.Description, "Phys") {
- testHelper.Error(t, "Should get back \"Phys Disk\" or \"Physical Disk\" for \"Description\", got: %s", h.Description)
- } else {
- testHelper.Success(t, "Should get back \"BACKPLANE FIRMWARE\" for \"Description\"")
- }
- }
-}
-
-func TestHardwareUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Hardware")
-
- _, err := to.Hardware(0)
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/Readme.md b/traffic_ops/client_tests/tests/integration/Readme.md
deleted file mode 100644
index 615ac12..0000000
--- a/traffic_ops/client_tests/tests/integration/Readme.md
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-# Traffic Ops Client Integration Tests
-
-The Traffic Ops Client Integration tests are used to validate the clients responses against those from the Traffic Ops API. In order to run the tests you will need a Traffic Ops instance with at least one of each of the following: CDN, Delivery Service, Type, Cachegroup, User and Server.
-
-## Running the Integration Tests
-The integration tests are run using `go test`, however, there are some flags that need to be provided in order for the tests to work. The flags are:
-
-* toURL - The URL to Traffic Ops. Default is "http://localhost:3000".
-* toUser - The Traffic Ops user to use. Default is "admin".
-* toPass - The password of the user provided. Deafault is "password".
-
-Example command to run the tests: `go test -v -toUrl=https://to.kabletown.net -toUser=myUser -toPass=myPass`
-
-*It can take serveral minutes for the integration tests to complete, so using the `-v` flag is recommended to see progress.*
diff --git a/traffic_ops/client_tests/tests/integration/cachegroup_test.go b/traffic_ops/client_tests/tests/integration/cachegroup_test.go
deleted file mode 100644
index 403a514..0000000
--- a/traffic_ops/client_tests/tests/integration/cachegroup_test.go
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-//TestCachegroupResults compares the results of the Cachegroup api and Cachegroup client
-func TestCachegroups(t *testing.T) {
- //Get Cachegroups Data from API
- resp, err := Request(*to, "GET", "/api/1.2/cachegroups.json", nil)
- if err != nil {
- t.Errorf("Could not get cachegroups.json reponse was: %v\n", err)
- }
-
- defer resp.Body.Close()
- var apiCgRes traffic_ops.CacheGroupResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiCgRes); err != nil {
- t.Errorf("Could not decode Cachegroup json. Error is: %v\n", err)
- }
- apiCgs := apiCgRes.Response
-
- clientCgs, err := to.CacheGroups()
- if err != nil {
- t.Errorf("Could not get Cachegroups from client. Error is: %v\n", err)
- }
-
- if len(apiCgs) != len(clientCgs) {
- t.Errorf("Array lengths from client and API are different...API = %d, Client = %d\n", len(apiCgs), len(clientCgs))
- }
-
- for _, apiCg := range apiCgs {
- matchFound := false
- for _, clientCg := range clientCgs {
- if clientCg.Name != apiCg.Name {
- continue
- }
- matchFound = true
- //compare API results and client results
- if apiCg.Name != clientCg.Name {
- t.Errorf("Cachegroup Name from client and API are different...API = %s, Client = %s\n", apiCg.Name, clientCg.Name)
- }
- if apiCg.ShortName != clientCg.ShortName {
- t.Errorf("Cachegroup ShortName from client and API are different...API = %s, Client = %s\n", apiCg.ShortName, clientCg.ShortName)
- }
- if apiCg.LastUpdated != clientCg.LastUpdated {
- t.Errorf("Cachegroup Last Updated from client and API are different...API = %s, Client = %s\n", apiCg.Name, clientCg.Name)
- }
- if apiCg.Latitude != clientCg.Latitude {
- t.Errorf("Cachegroup Latitude from client and API are different...API = %f, Client = %f\n", apiCg.Latitude, clientCg.Latitude)
- }
- if apiCg.Longitude != clientCg.Longitude {
- t.Errorf("Cachegroup Longitude from client and API are different...API = %f, Client = %f\n", apiCg.Longitude, clientCg.Longitude)
- }
- if apiCg.ParentName != clientCg.ParentName {
- t.Errorf("Cachegroup ParentName from client and API are different...API = %s, Client = %s\n", apiCg.ParentName, clientCg.ParentName)
- }
- if apiCg.Type != clientCg.Type {
- t.Errorf("Cachegroup Type from client and API are different...API = %s, Client = %s\n", apiCg.Type, clientCg.Type)
- }
- }
- if !matchFound {
- t.Errorf("A match for %s from the API was not found in the client results\n", apiCg.Name)
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/cdn_test.go b/traffic_ops/client_tests/tests/integration/cdn_test.go
deleted file mode 100644
index 0dca906..0000000
--- a/traffic_ops/client_tests/tests/integration/cdn_test.go
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-//TestCDNs compares the results of the CDN api and CDN client
-func TestCDNs(t *testing.T) {
- //Get CDNs Data from API
- resp, err := Request(*to, "GET", "/api/1.2/cdns.json", nil)
- if err != nil {
- t.Errorf("Could not get cdns.json reponse was: %v\n", err)
- }
-
- defer resp.Body.Close()
- var apiCDNRes traffic_ops.CDNResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiCDNRes); err != nil {
- t.Errorf("Could not decode CDN json. Error is: %v\n", err)
- }
- apiCDNs := apiCDNRes.Response
-
- //get CDNs data from client
- clientCDNs, err := to.CDNs()
- if err != nil {
- t.Errorf("Could not get CDNs from client. Error is: %v\n", err)
- }
-
- if len(apiCDNs) != len(clientCDNs) {
- t.Errorf("Array lengths from client and API are different...API = %s, Client = %s\n", apiCDNs, clientCDNs)
- }
-
- for _, apiCDN := range apiCDNs {
- matchFound := false
- for _, clientCDN := range clientCDNs {
- if clientCDN.Name != apiCDN.Name {
- continue
- }
- matchFound = true
- //compare API results and client results
- if apiCDN.Name != clientCDN.Name {
- t.Errorf("CDN Name from client and API are different...API = %s, Client = %s\n", apiCDN.Name, clientCDN.Name)
- }
- if apiCDN.LastUpdated != clientCDN.LastUpdated {
- t.Errorf("CDN Last Updated from client and API are different...API = %s, Client = %s\n", apiCDN.Name, clientCDN.Name)
- }
- }
- if !matchFound {
- t.Errorf("A match for %s from the API was not found in the client results\n", apiCDN.Name)
- }
- }
-}
-
-//TestCDNName ensures the client returns a CDN by name
-func TestCDNName(t *testing.T) {
- //Get CDNs Data from API
- resp, err := Request(*to, "GET", "/api/1.2/cdns.json", nil)
- if err != nil {
- t.Errorf("Could not get cdns.json reponse was: %v\n", err)
- }
-
- defer resp.Body.Close()
- var apiCDNRes traffic_ops.CDNResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiCDNRes); err != nil {
- t.Errorf("Could not decode CDN json. Error is: %v\n", err)
- }
-
- apiCDNs := apiCDNRes.Response
- apiName := apiCDNs[0].Name
- apiLastUpdated := apiCDNs[0].LastUpdated
-
- //get CDNs data from client
- clientCDN, err := to.CDNName(apiName)
-
- if len(clientCDN) != 1 {
- t.Errorf("The length of the client CDN response %v is greater than 1!\n", len(apiCDNs))
- }
-
- clientName := clientCDN[0].Name
- clientLastUpdated := clientCDN[0].LastUpdated
-
- //compare API results and client results
- if apiName != clientName {
- t.Errorf("CDN Name from client and API are different...API = %s, Client = %s\n", apiName, clientName)
- }
- if apiLastUpdated != clientLastUpdated {
- t.Errorf("CDN Last Updated from client and API are different...API = %s, Client = %s\n", apiName, clientName)
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/crconfig_test.go b/traffic_ops/client_tests/tests/integration/crconfig_test.go
deleted file mode 100644
index ceb1fa6..0000000
--- a/traffic_ops/client_tests/tests/integration/crconfig_test.go
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import "testing"
-
-//TestCachegroupResults compares the results of the Cachegroup api and Cachegroup client
-func TestGetCrConfig(t *testing.T) {
- //Get a CDN from the to client
- cdn, err := GetCdn()
- if err != nil {
- t.Errorf("TestGetCrConfig -- Could not get CDNs from TO...%v\n", err)
- }
-
- crConfig, cacheHitStatus, err := to.GetCRConfig(cdn.Name)
- if err != nil {
- t.Errorf("Could not get CrConfig for %s. Error is...%v\n", cdn.Name, err)
- }
-
- if cacheHitStatus == "" {
- t.Error("cacheHitStatus is empty...")
- }
-
- if len(crConfig) == 0 {
- t.Error("Raw CrConfig reponse was 0...")
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/deliveryservice_test.go b/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
deleted file mode 100644
index b2fb797..0000000
--- a/traffic_ops/client_tests/tests/integration/deliveryservice_test.go
+++ /dev/null
@@ -1,722 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "net/url"
- "os"
- "strconv"
- "strings"
- "testing"
- "time"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-var (
- testDs traffic_ops.DeliveryService
- testDsID string
- existingTestDS traffic_ops.DeliveryService
- existingTestDSID string
- sslDs traffic_ops.DeliveryService
-)
-
-func init() {
- cdn, err := GetCdn()
- if err != nil {
- fmt.Printf("Deliverservice_test init -- Could not get CDNs from TO...%v\n", err)
- os.Exit(1)
- }
-
- profile, err := GetProfile()
- if err != nil {
- fmt.Printf("Deliverservice_test init -- Could not get Profiles from TO...%v\n", err)
- os.Exit(1)
- }
-
- dsType, err := GetType("deliveryservice")
- if err != nil {
- fmt.Printf("Deliverservice_test init -- Could not get Types from TO...%v\n", err)
- os.Exit(1)
- }
-
- //create DeliveryService object for testing
- testDs.Active = false
- testDs.CCRDNSTTL = 30
- testDs.CDNName = cdn.Name
- testDs.CDNID = cdn.ID
- testDs.CacheURL = "cacheURL"
- testDs.CheckPath = "CheckPath"
- testDs.DeepCachingType = "NEVER"
- testDs.DNSBypassCname = "DNSBypassCNAME"
- testDs.DNSBypassIP = "10.10.10.10"
- testDs.DNSBypassIP6 = "FF01:0:0:0:0:0:0:FB"
- testDs.DNSBypassTTL = 30
- testDs.DSCP = 0
- testDs.DisplayName = "DisplayName"
- testDs.EdgeHeaderRewrite = "EdgeHeaderRewrite"
- testDs.GeoLimit = 5
- testDs.GeoProvider = 1
- testDs.GlobalMaxMBPS = 15000
- testDs.GlobalMaxTPS = 15000
- testDs.HTTPBypassFQDN = "HTTPBypassFQDN"
- testDs.IPV6RoutingEnabled = true
- testDs.InfoURL = "InfoUrl"
- testDs.InitialDispersion = 5
- testDs.LongDesc = "LongDesc"
- testDs.LongDesc1 = "LongDesc1"
- testDs.LongDesc2 = "LongDesc2"
- testDs.MaxDNSAnswers = 5
- testDs.MidHeaderRewrite = "MidHeaderRewrite"
- testDs.MissLat = 5.555
- testDs.MissLong = -50.5050
- testDs.MultiSiteOrigin = true
- testDs.OrgServerFQDN = "http://OrgServerFQDN"
- testDs.ProfileDesc = profile.Description
- testDs.ProfileName = profile.Name
- testDs.ProfileID = profile.ID
- testDs.Protocol = 1
- testDs.QStringIgnore = 1
- testDs.RangeRequestHandling = 0
- testDs.RegexRemap = "regexRemap"
- testDs.RemapText = "remapText"
- testDs.RoutingName = "edge"
- testDs.Signed = false
- testDs.TRResponseHeaders = "TRResponseHeaders"
- testDs.Type = dsType.Name
- testDs.TypeID = dsType.ID
- testDs.XMLID = "Test-DS-" + strconv.FormatInt(time.Now().Unix(), 10)
- testDs.RegionalGeoBlocking = false
- testDs.LogsEnabled = false
-
- //Create method currently does not support MatchList...
- // testDsMatch1 := new(traffic_ops.DeliveryServiceMatch)
- // testDsMatch1.Pattern = "Pattern1"
- // testDsMatch1.SetNumber = "0"
- // testDsMatch1.Type = "HOST"
-
- // testDsMatch2 := new(traffic_ops.DeliveryServiceMatch)
- // testDsMatch2.Pattern = "Pattern2"
- // testDsMatch2.SetNumber = "1"
- // testDsMatch2.Type = "HOST"
-
- // testDs.MatchList = append(testDs.MatchList, *testDsMatch1)
- // testDs.MatchList = append(testDs.MatchList, *testDsMatch2)
-
-}
-
-func TestDeliveryServices(t *testing.T) {
- resp, err := Request(*to, "GET", "/api/1.2/deliveryservices.json", nil)
- if err != nil {
- t.Errorf("Could not get deliveryservices.json reponse was: %v\n", err)
- }
-
- defer resp.Body.Close()
- var apiDsRes traffic_ops.GetDeliveryServiceResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiDsRes); err != nil {
- t.Errorf("Could not decode Deliveryservice json. Error is: %v\n", err)
- }
- apiDss := apiDsRes.Response
-
- clientDss, err := to.DeliveryServices()
- if err != nil {
- t.Errorf("Could not get Deliveryservices from client. Error is: %v\n", err)
- }
-
- if len(apiDss) != len(clientDss) {
- t.Errorf("Array lengths from client and API are different...API = %v, Client = %v\n", apiDss, clientDss)
- }
-
- matchFound := false
- for _, apiDs := range apiDss {
- //set these to use later...this saves time over doing it in the init() method
- if apiDs.Protocol == 0 && existingTestDS.ID == 0 {
- existingTestDS = apiDs
- existingTestDSID = strconv.Itoa(existingTestDS.ID)
- }
- if apiDs.Protocol > 0 && strings.Contains(apiDs.Type, "DNS") && sslDs.ID == 0 {
- sslDs = apiDs
- }
-
- for _, clientDs := range clientDss {
- if clientDs.XMLID != apiDs.XMLID {
- continue
- }
- matchFound = true
- compareDs(apiDs, clientDs, t)
- }
- if !matchFound {
- t.Errorf("A match for %s from the API was not found in the client results\n", apiDs.XMLID)
- }
- }
-}
-
-func TestCreateDs(t *testing.T) {
- //create a DS and validate response
- res, err := to.CreateDeliveryService(&testDs)
- if err != nil {
- t.Error("Failed to create deliveryservice! Error is: ", err)
- t.FailNow()
- }
- if res.Response[0].ID < 1 {
- t.Error("A DS ID was not returned after DS creation!")
- t.FailNow()
- }
- testDs.ID = res.Response[0].ID
- testDsID = strconv.Itoa(testDs.ID)
- compareDs(testDs, res.Response[0], t)
-}
-
-func TestUpdateDs(t *testing.T) {
- if testDsID == "" {
- t.Error("testDsID is not defined")
- t.FailNow()
- }
- testDs.DisplayName = "New Display Name"
- testDs.LongDesc += "-- Update"
- testDs.LongDesc1 += "-- Update"
- testDs.LongDesc2 += "-- Update"
- testDs.EdgeHeaderRewrite += "-- Update"
- res, err := to.UpdateDeliveryService(testDsID, &testDs)
- if err != nil {
- t.Error("Failed to update deliveryservice! Error is: ", err)
- } else {
- compareDs(testDs, res.Response[0], t)
- }
-}
-
-func TestDeliveryService(t *testing.T) {
- if testDsID == "" {
- t.Error("testDsID is not defined")
- t.FailNow()
- }
- uri := fmt.Sprintf("/api/1.2/deliveryservices/%s.json", testDsID)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- }
-
- defer resp.Body.Close()
- var apiDsRes traffic_ops.GetDeliveryServiceResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiDsRes); err != nil {
- t.Errorf("Could not decode Deliveryservice json. Error is: %v\n", err)
- }
-
- clientDss, err := to.DeliveryService(testDsID)
- if err != nil {
- t.Errorf("Could not get Deliveryservice from client. Error is: %v\n", err)
- }
-
- compareDs(apiDsRes.Response[0], *clientDss, t)
-}
-
-//Put this Test after anything using the testDS or testDsID variables
-func TestDeleteDeliveryService(t *testing.T) {
- if testDsID == "" {
- t.Error("testDsID is not defined")
- t.FailNow()
- }
- res, err := to.DeleteDeliveryService(testDsID)
- if err != nil {
- t.Errorf("Could not delete Deliveryserivce %s reponse was: %v\n", testDsID, err)
- }
- if res.Alerts[0].Level != "success" {
- t.Errorf("Alert.Level -- Expected \"success\" got %s", res.Alerts[0].Level)
- }
- if res.Alerts[0].Text != "Delivery service was deleted." {
- t.Errorf("Alert.Level -- Expected \"Delivery service was deleted.\" got %s", res.Alerts[0].Text)
- }
-}
-
-func TestDeliveryServiceState(t *testing.T) {
- uri := fmt.Sprintf("/api/1.2/deliveryservices/%s/state.json", existingTestDSID)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- }
-
- defer resp.Body.Close()
- var apiDsStateRes traffic_ops.DeliveryServiceStateResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiDsStateRes); err != nil {
- t.Errorf("Could not decode DeliveryserviceState reponse. Error is: %v\n", err)
- }
-
- apiDsState := apiDsStateRes.Response
-
- clientDsState, err := to.DeliveryServiceState(existingTestDSID)
- if err != nil {
- t.Errorf("Could not get DS State from client for %s reponse was: %v\n", existingTestDSID, err)
- }
-
- if apiDsState.Enabled != clientDsState.Enabled {
- t.Errorf("Enabled -- Expected %v got %v for ID %s", apiDsState.Enabled, clientDsState.Enabled, existingTestDSID)
- }
- if apiDsState.Failover.Configured != clientDsState.Failover.Configured {
- t.Errorf("Failover.Configured -- Expected %v got %v", apiDsState.Failover.Configured, clientDsState.Failover.Configured)
- }
- if apiDsState.Failover.Destination.Location != clientDsState.Failover.Destination.Location {
- t.Errorf("Failover.Destination.Location -- Expected %v got %v", apiDsState.Failover.Destination.Location, clientDsState.Failover.Destination.Location)
- }
- if apiDsState.Failover.Destination.Type != clientDsState.Failover.Destination.Type {
- t.Errorf("Failover.Destination.Type -- Expected %v got %v", apiDsState.Failover.Destination.Type, clientDsState.Failover.Destination.Type)
- }
- if apiDsState.Failover.Enabled != clientDsState.Failover.Enabled {
- t.Errorf("res.Failover.Enabled -- Expected %v got %v", apiDsState.Failover.Enabled, clientDsState.Failover.Enabled)
- }
- if len(apiDsState.Failover.Locations) != len(clientDsState.Failover.Locations) {
- t.Errorf("res.Failover.Locations len -- Expected %v got %v", len(apiDsState.Failover.Locations), len(clientDsState.Failover.Locations))
- }
-}
-
-func TestDeliveryServiceHealth(t *testing.T) {
- uri := fmt.Sprintf("/api/1.2/deliveryservices/%s/health.json", existingTestDSID)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- }
-
- defer resp.Body.Close()
- var apiDsHealthRes traffic_ops.DeliveryServiceHealthResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiDsHealthRes); err != nil {
- t.Errorf("Could not decode DeliveryserviceHealth reponse. Error is: %v\n", err)
- }
-
- apiDsHealth := apiDsHealthRes.Response
-
- clientDsHealth, err := to.DeliveryServiceHealth(existingTestDSID)
- if err != nil {
- t.Errorf("Could not ge Deliveryserivce Health for %s reponse was: %v\n", existingTestDSID, err)
- }
-
- if apiDsHealth.TotalOnline != clientDsHealth.TotalOnline {
- t.Errorf("TotalOnline -- Expected %v got %v", apiDsHealth.TotalOnline, apiDsHealth.TotalOnline)
- }
-
- if apiDsHealth.TotalOffline != clientDsHealth.TotalOffline {
- t.Errorf("TotalOffline -- Expected %v got %v", apiDsHealth.TotalOffline, clientDsHealth.TotalOffline)
- }
-
- if len(apiDsHealth.CacheGroups) != len(clientDsHealth.CacheGroups) {
- t.Errorf("len Cachegroups -- Expected %v got %v", len(apiDsHealth.CacheGroups), len(clientDsHealth.CacheGroups))
- }
-
- for _, apiCg := range apiDsHealth.CacheGroups {
- match := false
- for _, clientCg := range clientDsHealth.CacheGroups {
- if apiCg.Name != clientCg.Name {
- continue
- }
- match = true
- if apiCg.Offline != clientCg.Offline {
- t.Errorf("Cachegroup.Offline -- Expected %v got %v", apiCg.Offline, clientCg.Offline)
- }
- if apiCg.Online != clientCg.Online {
- t.Errorf("Cachegroup.Online -- Expected %v got %v", apiCg.Online, clientCg.Online)
- }
- }
- if !match {
- t.Errorf("Cachegroup -- No match from client for api cachgroup %v", apiCg.Name)
- }
- }
-}
-
-func TestDeliveryServiceCapacity(t *testing.T) {
- uri := fmt.Sprintf("/api/1.2/deliveryservices/%s/capacity.json", existingTestDSID)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- }
-
- defer resp.Body.Close()
- var apiDsCapacityRes traffic_ops.DeliveryServiceCapacityResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiDsCapacityRes); err != nil {
- t.Errorf("Could not decode DeliveryserviceCapacity reponse. Error is: %v\n", err)
- }
-
- apiDsCapacity := apiDsCapacityRes.Response
-
- clientDsCapacity, err := to.DeliveryServiceCapacity(existingTestDSID)
- if err != nil {
- t.Errorf("Could not ge Deliveryserivce Capacity for %s reponse was: %v\n", existingTestDSID, err)
- }
-
- if !compareCapacity(apiDsCapacity.AvailablePercent, clientDsCapacity.AvailablePercent) {
- t.Errorf("AvailablePercent -- Expected %v got %v", apiDsCapacity.AvailablePercent, clientDsCapacity.AvailablePercent)
- }
-
- if !compareCapacity(apiDsCapacity.MaintenancePercent, clientDsCapacity.MaintenancePercent) {
- t.Errorf("MaintenenancePercent -- Expected %v got %v", apiDsCapacity.MaintenancePercent, clientDsCapacity.MaintenancePercent)
- }
-
- if !compareCapacity(apiDsCapacity.UnavailablePercent, clientDsCapacity.UnavailablePercent) {
- t.Errorf("UnavailablePercent -- Expected %v got %v", apiDsCapacity.UnavailablePercent, clientDsCapacity.UnavailablePercent)
- }
-
- if !compareCapacity(apiDsCapacity.UtilizedPercent, clientDsCapacity.UtilizedPercent) {
- t.Errorf("UtilizedPercent -- Expected %v got %v", apiDsCapacity.UtilizedPercent, clientDsCapacity.UtilizedPercent)
- }
-
-}
-
-func compareCapacity(val1 float64, val2 float64) bool {
- // make sure val 2 is within 1% of val1
- if val2 > val1*1.01 || val2 < val1*.99 {
- return false
- }
- return true
-}
-
-func TestDeliveryServiceRouting(t *testing.T) {
- uri := fmt.Sprintf("/api/1.2/deliveryservices/%s/routing.json", existingTestDSID)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- }
-
- defer resp.Body.Close()
- var apiDsRoutingRes traffic_ops.DeliveryServiceRoutingResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiDsRoutingRes); err != nil {
- t.Errorf("Could not decode DeliveryserviceRouting reponse. Error is: %v\n", err)
- }
-
- apiDsRouting := apiDsRoutingRes.Response
-
- clientDsRouting, err := to.DeliveryServiceRouting(existingTestDSID)
- if err != nil {
- t.Errorf("Could not ge Deliveryserivce Routing for %s reponse was: %v\n", existingTestDSID, err)
- }
-
- if apiDsRouting.CZ != clientDsRouting.CZ {
- t.Errorf("CZ -- Expected %v got %v", apiDsRouting.CZ, clientDsRouting.CZ)
- }
-
- if apiDsRouting.DSR != clientDsRouting.DSR {
- t.Errorf("DSR -- Expected %v got %v", apiDsRouting.DSR, clientDsRouting.DSR)
- }
-
- if apiDsRouting.Err != clientDsRouting.Err {
- t.Errorf("Err-- Expected %v got %v", apiDsRouting.Err, clientDsRouting.Err)
- }
-
- if apiDsRouting.Fed != clientDsRouting.Fed {
- t.Errorf("Fed -- Expected %v got %v", apiDsRouting.Fed, clientDsRouting.Fed)
- }
-
- if apiDsRouting.Geo != clientDsRouting.Geo {
- t.Errorf("Geo -- Expected %v got %v", apiDsRouting.Geo, clientDsRouting.Geo)
- }
-
- if apiDsRouting.Miss != clientDsRouting.Miss {
- t.Errorf("Miss -- Expected %v got %v", apiDsRouting.Miss, clientDsRouting.Miss)
- }
-
- if apiDsRouting.RegionalAlternate != clientDsRouting.RegionalAlternate {
- t.Errorf("RegionalAlternate -- Expected %v got %v", apiDsRouting.RegionalAlternate, clientDsRouting.RegionalAlternate)
- }
-
- if apiDsRouting.RegionalDenied != clientDsRouting.RegionalDenied {
- t.Errorf("RegionalDenied -- Expected %v got %v", apiDsRouting.RegionalDenied, clientDsRouting.RegionalDenied)
- }
-}
-
-func TestDeliveryServiceServer(t *testing.T) {
- resp, err := Request(*to, "GET", "/api/1.2/deliveryserviceserver.json?page=1&limit=1", nil)
- if err != nil {
- t.Errorf("Could not get deliveryserviceserver.json reponse was: %v\n", err)
- }
-
- defer resp.Body.Close()
- var apiDsServerRes traffic_ops.DeliveryServiceServerResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiDsServerRes); err != nil {
- t.Errorf("Could not decode DeliveryserviceServer reponse. Error is: %v\n", err)
- }
-
- clientDsServerRes, err := to.DeliveryServiceServer("1", "1")
-
- if err != nil {
- t.Errorf("Could not get DeliveryserviceServer, reponse was: %v\n", err)
- }
-
- for _, apiDss := range apiDsServerRes.Response {
- match := false
- for _, clientDss := range clientDsServerRes {
- if clientDss.DeliveryService != apiDss.DeliveryService {
- continue
- }
- match = true
- if apiDss.LastUpdated != clientDss.LastUpdated {
- t.Errorf("LastUpdated -- Expected %v got %v", apiDss.LastUpdated, clientDss.LastUpdated)
- }
- if apiDss.Server != clientDss.Server {
- t.Errorf("Server -- Expected %v got %v", apiDss.Server, clientDss.Server)
- }
- }
- if match != true {
- t.Errorf("No match found for the Deliveryservice %v in DeliveryserviceServer response: %v\n", apiDss.DeliveryService, err)
- }
- }
-
-}
-
-func TestDeliveryServiceSSLKeysByID(t *testing.T) {
- if sslDs.ID > 0 {
- uri := fmt.Sprintf("/api/1.2/deliveryservices/xmlId/%s/sslkeys.json", sslDs.XMLID)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- }
-
- defer resp.Body.Close()
- var apiSslRes traffic_ops.DeliveryServiceSSLKeysResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiSslRes); err != nil {
- t.Errorf("Could not decode DeliveryServiceSSLKeysResponse reponse. Error is: %v\n", err)
- }
-
- clientSslRes, err := to.DeliveryServiceSSLKeysByID(sslDs.XMLID)
-
- if err != nil {
- t.Errorf("Could not get DeliveryserviceSSLKeys, reponse was: %v\n", err)
- }
- compareSSLResponse(apiSslRes.Response, *clientSslRes, t)
- } else {
- t.Skip("Skipping TestDeliveryServiceSSLKeysByID because no Deliveryservice was found with SSL enabled")
- }
-}
-
-func TestDeliveryServiceSSLKeysByHostname(t *testing.T) {
- if sslDs.ID > 0 {
- var hostname string
- for _, exampleURL := range sslDs.ExampleURLs {
- if strings.Contains(exampleURL, "edge.") {
- u, err := url.Parse(exampleURL)
- if err != nil {
- t.Errorf("could not parse exampleURL %s\n", exampleURL)
- t.FailNow()
- }
- hostname = u.Host
- }
- }
- if hostname == "" {
- t.Skipf("could not find an example URL from Deliveryservice %s to use for testing\n", sslDs.XMLID)
- t.SkipNow()
- }
-
- uri := fmt.Sprintf("/api/1.2/deliveryservices/hostname/%s/sslkeys.json", hostname)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- }
-
- defer resp.Body.Close()
- var apiSslRes traffic_ops.DeliveryServiceSSLKeysResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiSslRes); err != nil {
- t.Errorf("Could not decode DeliveryServiceSSLKeysResponse reponse. Error is: %v\n", err)
- }
-
- clientSslRes, err := to.DeliveryServiceSSLKeysByHostname(hostname)
-
- if err != nil {
- t.Errorf("Could not get DeliveryserviceSSLKeys, reponse was: %v\n", err)
- }
- compareSSLResponse(apiSslRes.Response, *clientSslRes, t)
- } else {
- t.Skip("Skipping TestDeliveryServiceSSLKeysByID because no Deliveryservice was found with SSL enabled")
- }
-}
-
-func compareDs(ds1 traffic_ops.DeliveryService, ds2 traffic_ops.DeliveryService, t *testing.T) {
- if ds1.Active != ds1.Active {
- t.Errorf("Active -- Expected %v, Got %v\n", ds1.Active, ds2.Active)
- }
- if ds1.CCRDNSTTL != ds2.CCRDNSTTL {
- t.Errorf("CCRDNSTTL -- Expected %v, Got %v\n", ds1.CCRDNSTTL, ds2.CCRDNSTTL)
- }
- if ds1.CDNName != ds2.CDNName {
- t.Errorf("CDNName -- Expected %v, Got %v\n", ds1.CDNName, ds2.CDNName)
- }
- if ds1.CDNID != ds2.CDNID {
- t.Errorf("CDNID -- Expected %v, Got %v\n", ds1.CDNID, ds2.CDNID)
- }
- if ds1.CacheURL != ds2.CacheURL {
- t.Errorf("CacheURL -- Expected %v, Got %v\n", ds1.CacheURL, ds2.CacheURL)
- }
- if ds1.CheckPath != ds2.CheckPath {
- t.Errorf("CheckPath -- Expected %v, Got %v\n", ds1.CheckPath, ds2.CheckPath)
- }
- if ds1.DNSBypassCname != ds2.DNSBypassCname {
- t.Errorf("DNSBypassCname -- Expected %v, Got %v\n", ds1.DNSBypassCname, ds2.DNSBypassCname)
- }
- if ds1.DNSBypassIP != ds2.DNSBypassIP {
- t.Errorf("DNSBypassIP -- Expected %v, Got %v\n", ds1.DNSBypassIP, ds2.DNSBypassIP)
- }
- if ds1.DNSBypassIP6 != ds2.DNSBypassIP6 {
- t.Errorf("DNSBypassIP6 -- Expected %v, Got %v\n", ds1.DNSBypassIP6, ds2.DNSBypassIP6)
- }
- if ds1.DNSBypassTTL != ds2.DNSBypassTTL {
- t.Errorf("DNSBypassTTL -- Expected %v, Got %v\n", ds1.DNSBypassTTL, ds2.DNSBypassTTL)
- }
- if ds1.DSCP != ds2.DSCP {
- t.Errorf("DSCP -- Expected %v, Got %v\n", ds1.DSCP, ds2.DSCP)
- }
- if ds1.DisplayName != ds2.DisplayName {
- t.Errorf("DisplayName -- Expected %v, Got %v\n", ds1.DisplayName, ds2.DisplayName)
- }
- if ds1.EdgeHeaderRewrite != ds2.EdgeHeaderRewrite {
- t.Errorf("EdgeHeaderRewrite -- Expected %v, Got %v\n", ds1.EdgeHeaderRewrite, ds2.EdgeHeaderRewrite)
- }
- if ds1.GeoLimit != ds2.GeoLimit {
- t.Errorf("GeoLimit -- Expected %v, Got %v\n", ds1.GeoLimit, ds2.GeoLimit)
- }
- if ds1.GeoProvider != ds2.GeoProvider {
- t.Errorf("GeoProvider -- Expected %v, Got %v\n", ds1.GeoProvider, ds2.GeoProvider)
- }
- if ds1.GlobalMaxMBPS != ds2.GlobalMaxMBPS {
- t.Errorf("GlobalMaxMBPS -- Expected %v, Got %v\n", ds1.GlobalMaxMBPS, ds2.GlobalMaxMBPS)
- }
- if ds1.GlobalMaxTPS != ds2.GlobalMaxTPS {
- t.Errorf("GlobalMaxTPS -- Expected %v, Got %v\n", ds1.GlobalMaxTPS, ds2.GlobalMaxTPS)
- }
- if ds1.HTTPBypassFQDN != ds2.HTTPBypassFQDN {
- t.Errorf("HTTPBypassFQDN -- Expected %v, Got %v\n", ds1.HTTPBypassFQDN, ds2.HTTPBypassFQDN)
- }
- if ds1.ID > 0 && ds1.ID != ds2.ID {
- t.Errorf("ID -- Expected %v, Got %v\n", ds1.ID, ds2.ID)
- }
- if ds1.IPV6RoutingEnabled != ds2.IPV6RoutingEnabled {
- t.Errorf("IPv6RoutingEnabled -- Expected %v, Got %v\n", ds1.IPV6RoutingEnabled, ds2.IPV6RoutingEnabled)
- }
- if ds1.InfoURL != ds2.InfoURL {
- t.Errorf("InfoURL -- Expected %v, Got %v\n", ds1.InfoURL, ds2.InfoURL)
- }
- if ds1.InitialDispersion != ds2.InitialDispersion {
- t.Errorf("InitialDispersion -- Expected %v, Got %v\n", ds1.InitialDispersion, ds2.InitialDispersion)
- }
- if ds1.LastUpdated != "" && ds1.LastUpdated != ds2.LastUpdated {
- t.Errorf("LastUpdated -- Expected %v, Got %v\n", ds1.LastUpdated, ds2.LastUpdated)
- }
- if ds1.LongDesc != ds2.LongDesc {
- t.Errorf("LongDesc -- Expected %v, Got %v\n", ds1.LongDesc, ds2.LongDesc)
- }
- if ds1.LongDesc1 != ds2.LongDesc1 {
- t.Errorf("LongDesc1 -- Expected %v, Got %v\n", ds1.LongDesc1, ds2.LongDesc1)
- }
- if ds1.LongDesc2 != ds2.LongDesc2 {
- t.Errorf("LongDesc2 -- Expected %v, Got %v\n", ds1.LongDesc2, ds2.LongDesc2)
- }
- if ds1.MaxDNSAnswers != ds2.MaxDNSAnswers {
- t.Errorf("MaxDNSAnswers-- Expected %v, Got %v\n", ds1.MaxDNSAnswers, ds2.MaxDNSAnswers)
- }
- if ds1.MidHeaderRewrite != ds2.MidHeaderRewrite {
- t.Errorf("MidHeaderRewrite -- Expected %v, Got %v\n", ds1.MidHeaderRewrite, ds2.MidHeaderRewrite)
- }
- if ds1.MissLat != ds2.MissLat {
- t.Errorf("MissLat -- Expected %v, Got %v\n", ds1.MissLat, ds2.MissLat)
- }
- if ds1.MissLong != ds2.MissLong {
- t.Errorf("MissLong -- Expected %v, Got %v\n", ds1.MissLong, ds2.MissLong)
- }
- if ds1.MultiSiteOrigin != ds2.MultiSiteOrigin {
- t.Errorf("MutiSiteOrigin -- Expected %v, Got %v\n", ds1.MultiSiteOrigin, ds2.MultiSiteOrigin)
- }
- if ds1.OrgServerFQDN != ds2.OrgServerFQDN {
- t.Errorf("OrgServerFQDN -- Expected %v, Got %v\n", ds1.OrgServerFQDN, ds2.OrgServerFQDN)
- }
- if ds1.ProfileDesc != ds2.ProfileDesc {
- t.Errorf("ProfileDesc -- Expected %v, Got %v\n", ds1.ProfileDesc, ds2.ProfileDesc)
- }
- if ds1.ProfileName != ds2.ProfileName {
- t.Errorf("ProfileName -- Expected %v, Got %v\n", ds1.ProfileName, ds2.ProfileName)
- }
- if ds1.Protocol != ds2.Protocol {
- t.Errorf("Protocol -- Expected %v, Got %v\n", ds1.Protocol, ds2.Protocol)
- }
- if ds1.QStringIgnore != ds2.QStringIgnore {
- t.Errorf("QStringIgnore -- Expected %v, Got %v\n", ds1.QStringIgnore, ds2.QStringIgnore)
- }
- if ds1.RangeRequestHandling != ds2.RangeRequestHandling {
- t.Errorf("RangeRequestHandling -- Expected %v, Got %v\n", ds1.RangeRequestHandling, ds2.RangeRequestHandling)
- }
- if ds1.RegexRemap != ds2.RegexRemap {
- t.Errorf("RegexRemap -- Expected %v, Got %v\n", ds1.RegexRemap, ds2.RegexRemap)
- }
- if ds1.RemapText != ds2.RemapText {
- t.Errorf("RemapText -- Expected %v, Got %v\n", ds1.RemapText, ds2.RemapText)
- }
- if ds1.Signed != ds2.Signed {
- t.Errorf("Signed -- Expected %v, Got %v\n", ds1.Signed, ds2.Signed)
- }
- if ds1.TRResponseHeaders != ds2.TRResponseHeaders {
- t.Errorf("TRResponseHeaders -- Expected %v, Got %v\n", ds1.TRResponseHeaders, ds2.TRResponseHeaders)
- }
- if ds1.Type != ds2.Type {
- t.Errorf("Type -- Expected %v, Got %v\n", ds1.Type, ds2.Type)
- }
- if ds1.RegionalGeoBlocking != ds2.RegionalGeoBlocking {
- t.Errorf("RegionalGeoBlocking -- Expected %v, Got %v\n", ds1.RegionalGeoBlocking, ds2.RegionalGeoBlocking)
- }
- if ds1.LogsEnabled != ds2.LogsEnabled {
- t.Errorf("LogsEnabled -- Expected %v, Got %v\n", ds1.LogsEnabled, ds2.LogsEnabled)
- }
- if len(ds1.MatchList) > 0 {
- for i, match := range ds1.MatchList {
- if match != ds2.MatchList[i] {
- t.Errorf("Matchlist -- Expected %v, Got %v\n", match, ds2.MatchList[i])
- }
- }
- }
- if len(ds1.ExampleURLs) > 0 {
- for i, url := range ds1.ExampleURLs {
- if url != ds2.ExampleURLs[i] {
- t.Errorf("ExampleURL -- Expected %v, Got %v\n", url, ds2.ExampleURLs[i])
- }
- }
- }
-}
-
-func compareSSLResponse(apiSslRes traffic_ops.DeliveryServiceSSLKeys, clientSslRes traffic_ops.DeliveryServiceSSLKeys, t *testing.T) {
- if apiSslRes.BusinessUnit != clientSslRes.BusinessUnit {
- t.Errorf("BusinessUnit -- Expected %v got %v", apiSslRes.BusinessUnit, clientSslRes.BusinessUnit)
- }
- if apiSslRes.CDN != clientSslRes.CDN {
- t.Errorf("CDN -- Expected %v got %v", apiSslRes.CDN, clientSslRes.CDN)
- }
- if apiSslRes.Certificate.CSR != clientSslRes.Certificate.CSR {
- t.Errorf("CSR -- Expected %v got %v", apiSslRes.Certificate.CSR, clientSslRes.Certificate.CSR)
- }
- if apiSslRes.Certificate.Crt != clientSslRes.Certificate.Crt {
- t.Errorf("CRT -- Expected %v got %v", apiSslRes.Certificate.Crt, clientSslRes.Certificate.Crt)
- }
- if apiSslRes.Certificate.Key != clientSslRes.Certificate.Key {
- t.Errorf("Key -- Expected %v got %v", apiSslRes.Certificate.Key, clientSslRes.Certificate.Key)
- }
- if apiSslRes.City != clientSslRes.City {
- t.Errorf("City -- Expected %v got %v", apiSslRes.City, clientSslRes.City)
- }
- if apiSslRes.Country != clientSslRes.Country {
- t.Errorf("Country -- Expected %v got %v", apiSslRes.Country, clientSslRes.Country)
- }
- if apiSslRes.DeliveryService != clientSslRes.DeliveryService {
- t.Errorf("DeliveryService -- Expected %v got %v", apiSslRes.DeliveryService, clientSslRes.DeliveryService)
- }
- if apiSslRes.Hostname != clientSslRes.Hostname {
- t.Errorf("Hostname -- Expected %v got %v", apiSslRes.Hostname, clientSslRes.Hostname)
- }
- if apiSslRes.Organization != clientSslRes.Organization {
- t.Errorf("Organization -- Expected %v got %v", apiSslRes.Organization, clientSslRes.Organization)
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/hardware_test.go b/traffic_ops/client_tests/tests/integration/hardware_test.go
deleted file mode 100644
index 0c12ca5..0000000
--- a/traffic_ops/client_tests/tests/integration/hardware_test.go
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestHardware(t *testing.T) {
- resp, err := Request(*to, "GET", "/api/1.2/hwinfo.json", nil)
- if err != nil {
- t.Errorf("Could not get hardware.json reponse was: %v\n", err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiHwRes traffic_ops.HardwareResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiHwRes); err != nil {
- t.Errorf("Could not decode hwinfo json. Error is: %v\n", err)
- t.FailNow()
- }
- apiHardware := apiHwRes.Response
-
- clientHardware, err := to.Hardware(0)
- if err != nil {
- t.Errorf("Could not get Hardware from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiHardware) != len(clientHardware) {
- t.Errorf("Hardware Response Length -- expected %v, got %v\n", len(apiHardware), len(clientHardware))
- }
-
- for _, apiHw := range apiHardware {
- match := false
- for _, clientHw := range clientHardware {
- if apiHw.HostName == clientHw.HostName && apiHw.Description == clientHw.Description {
- match = true
- compareHw(apiHw, clientHw, t)
- }
- }
- if !match {
- t.Errorf("No hardware information returned from client for %s\n", apiHw.HostName)
- }
- }
-}
-
-func TestHardwareWithLimit(t *testing.T) {
- resp, err := Request(*to, "GET", "/api/1.2/hwinfo.json?limit=10", nil)
- if err != nil {
- t.Errorf("Could not get hwinfo.json reponse was: %v\n", err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiHwRes traffic_ops.HardwareResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiHwRes); err != nil {
- t.Errorf("Could not decode hwinfo json. Error is: %v\n", err)
- t.FailNow()
- }
- apiHardware := apiHwRes.Response
-
- clientHardware, err := to.Hardware(10)
- if err != nil {
- t.Errorf("Could not get Hardware from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiHardware) != len(clientHardware) {
- t.Errorf("Hardware Response Length -- expected %v, got %v\n", len(apiHardware), len(clientHardware))
- }
-
- for _, apiHw := range apiHardware {
- match := false
- for _, clientHw := range clientHardware {
- if apiHw.HostName == clientHw.HostName && apiHw.Description == clientHw.Description {
- match = true
- compareHw(apiHw, clientHw, t)
- }
- }
- if !match {
- t.Errorf("No hardware information returned from client for %s\n", apiHw.HostName)
- }
- }
-}
-
-func compareHw(hw1 traffic_ops.Hardware, hw2 traffic_ops.Hardware, t *testing.T) {
- if hw1.Description != hw2.Description {
- t.Errorf("Description -- Expected %v, got %v", hw1.Description, hw2.Description)
- }
- if hw1.HostName != hw2.HostName {
- t.Errorf("HostName -- Expected %v, got %v", hw1.HostName, hw2.HostName)
- }
- if hw1.ID != hw2.ID {
- t.Errorf("ID -- Expected %v, got %v", hw1.ID, hw2.ID)
- }
- if hw1.LastUpdated != hw2.LastUpdated {
- t.Errorf("LastUpdated -- Expected %v, got %v", hw1.LastUpdated, hw2.LastUpdated)
- }
- if hw1.Value != hw2.Value {
- t.Errorf("Value -- Expected %v, got %v", hw1.Value, hw2.Value)
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/integration_helper.go b/traffic_ops/client_tests/tests/integration/integration_helper.go
deleted file mode 100644
index bc44b89..0000000
--- a/traffic_ops/client_tests/tests/integration/integration_helper.go
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "bytes"
- "errors"
- "flag"
- "fmt"
- "net/http"
- "os"
- "time"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-var (
- to *traffic_ops.Session
-)
-
-func init() {
- toURL := flag.String("toURL", "http://localhost:3000", "Traffic Ops URL")
- toUser := flag.String("toUser", "admin", "Traffic Ops user")
- toPass := flag.String("toPass", "password", "Traffic Ops password")
- flag.Parse()
- var loginErr error
- toReqTimeout := time.Second * time.Duration(30)
- to, loginErr = traffic_ops.LoginWithAgent(*toURL, *toUser, *toPass, true, "traffic-ops-client-integration-tests", true, toReqTimeout)
- if loginErr != nil {
- fmt.Printf("\nError logging in to %v: %v\nMake sure toURL, toUser, and toPass flags are included and correct.\nExample: go test -toUser=admin -toPass=pass -toURL=http://localhost:3000\n\n", *toURL, loginErr)
- os.Exit(1)
- }
-}
-
-//GetCdn returns a Cdn struct
-func GetCdn() (traffic_ops.CDN, error) {
- cdns, err := to.CDNs()
- if err != nil {
- return *new(traffic_ops.CDN), err
- }
- cdn := cdns[0]
- if cdn.Name == "ALL" {
- cdn = cdns[1]
- }
- return cdn, nil
-}
-
-//GetProfile returns a Profile Struct
-func GetProfile() (traffic_ops.Profile, error) {
- profiles, err := to.Profiles()
- if err != nil {
- return *new(traffic_ops.Profile), err
- }
- return profiles[0], nil
-}
-
-//GetType returns a Type Struct
-func GetType(useInTable string) (traffic_ops.Type, error) {
- types, err := to.Types()
- if err != nil {
- return *new(traffic_ops.Type), err
- }
- for _, myType := range types {
- if myType.UseInTable == useInTable {
- return myType, nil
- }
- }
- nfErr := fmt.Sprintf("No Types found for useInTable %s\n", useInTable)
- return *new(traffic_ops.Type), errors.New(nfErr)
-}
-
-//GetDeliveryService returns a DeliveryService Struct
-func GetDeliveryService(cdn string) (traffic_ops.DeliveryService, error) {
- dss, err := to.DeliveryServices()
- if err != nil {
- return *new(traffic_ops.DeliveryService), err
- }
- if cdn != "" {
- for _, ds := range dss {
- if ds.CDNName == cdn {
- return ds, nil
- }
- }
- }
- return dss[0], nil
-}
-
-//Request sends a request to TO and returns a response.
-//This is basically a copy of the private "request" method in the traffic_ops.go \
-//but I didn't want to make that one public.
-func Request(to traffic_ops.Session, method, path string, body []byte) (*http.Response, error) {
- url := fmt.Sprintf("%s%s", to.URL, path)
-
- var req *http.Request
- var err error
-
- if body != nil && method != "GET" {
- req, err = http.NewRequest(method, url, bytes.NewBuffer(body))
- if err != nil {
- return nil, err
- }
- req.Header.Set("Content-Type", "application/json")
- } else {
- req, err = http.NewRequest("GET", url, nil)
- if err != nil {
- return nil, err
- }
- }
-
- resp, err := to.Client.Do(req)
- if err != nil {
- return nil, err
- }
-
- if resp.StatusCode != http.StatusOK {
- e := traffic_ops.HTTPError{
- HTTPStatus: resp.Status,
- HTTPStatusCode: resp.StatusCode,
- URL: url,
- }
- return nil, &e
- }
-
- return resp, nil
-}
diff --git a/traffic_ops/client_tests/tests/integration/parameter_test.go b/traffic_ops/client_tests/tests/integration/parameter_test.go
deleted file mode 100644
index e7d2220..0000000
--- a/traffic_ops/client_tests/tests/integration/parameter_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestParameters(t *testing.T) {
- profile, err := GetProfile()
- if err != nil {
- t.Errorf("Could not get a profile, error was: %v\n", err)
- }
-
- uri := fmt.Sprintf("/api/1.2/parameters/profile/%s.json", profile.Name)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiParamRes traffic_ops.ParamResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiParamRes); err != nil {
- t.Errorf("Could not decode parameter json. Error is: %v\n", err)
- t.FailNow()
- }
- apiParams := apiParamRes.Response
-
- clientParams, err := to.Parameters(profile.Name)
- if err != nil {
- t.Errorf("Could not get parameters from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiParams) != len(clientParams) {
- t.Errorf("Params Response Length -- expected %v, got %v\n", len(apiParams), len(clientParams))
- }
-
- for _, apiParam := range apiParams {
- match := false
- for _, clientParam := range clientParams {
- if apiParam.Name == clientParam.Name && apiParam.Value == clientParam.Value && apiParam.ConfigFile == clientParam.ConfigFile {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a param matching %+v from the client\n", apiParam)
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/profile_test.go b/traffic_ops/client_tests/tests/integration/profile_test.go
deleted file mode 100644
index f678a37..0000000
--- a/traffic_ops/client_tests/tests/integration/profile_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestProfiles(t *testing.T) {
-
- uri := fmt.Sprintf("/api/1.2/profiles.json")
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiProfileRes traffic_ops.ProfileResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiProfileRes); err != nil {
- t.Errorf("Could not decode profile json. Error is: %v\n", err)
- t.FailNow()
- }
- apiProfiles := apiProfileRes.Response
-
- clientProfiles, err := to.Profiles()
- if err != nil {
- t.Errorf("Could not get profiles from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiProfiles) != len(clientProfiles) {
- t.Errorf("Profile Response Length -- expected %v, got %v\n", len(apiProfiles), len(clientProfiles))
- }
-
- for _, apiProfile := range apiProfiles {
- match := false
- for _, clientProfile := range clientProfiles {
- if apiProfile.ID == clientProfile.ID {
- match = true
- if apiProfile.Description != clientProfile.Description {
- t.Errorf("Description -- Expected %v, got %v\n", apiProfile.Description, clientProfile.Description)
- }
- if apiProfile.LastUpdated != clientProfile.LastUpdated {
- t.Errorf("Last Updated -- Expected %v, got %v\n", apiProfile.LastUpdated, clientProfile.LastUpdated)
- }
- if apiProfile.Name != clientProfile.Name {
- t.Errorf("Name -- Expected %v, got %v\n", apiProfile.Name, clientProfile.Name)
- }
- }
- }
- if !match {
- t.Errorf("Did not get a profile matching %v\n", apiProfile.Name)
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/server_test.go b/traffic_ops/client_tests/tests/integration/server_test.go
deleted file mode 100644
index 937e519..0000000
--- a/traffic_ops/client_tests/tests/integration/server_test.go
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "net/url"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestServers(t *testing.T) {
-
- uri := fmt.Sprintf("/api/1.2/servers.json")
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiServerRes traffic_ops.ServerResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiServerRes); err != nil {
- t.Errorf("Could not decode server json. Error is: %v\n", err)
- t.FailNow()
- }
- apiServers := apiServerRes.Response
-
- clientServers, err := to.Servers()
- if err != nil {
- t.Errorf("Could not get servers from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiServers) != len(clientServers) {
- t.Errorf("Server Response Length -- expected %v, got %v\n", len(apiServers), len(clientServers))
- }
-
- for _, apiServer := range apiServers {
- match := false
- for _, clientServer := range clientServers {
- if apiServer.ID == clientServer.ID {
- match = true
- compareServer(apiServer, clientServer, t)
- }
- }
- if !match {
- t.Errorf("Did not get a server matching %v\n", apiServer.ID)
- }
- }
-}
-
-func TestServersByType(t *testing.T) {
- serverType, err := GetType("server")
- if err != nil {
- t.Error("Could not get Type from client for TestServersByType")
- t.FailNow()
- }
- uri := fmt.Sprintf("/api/1.2/servers.json?type=%s", serverType.Name)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiServerRes traffic_ops.ServerResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiServerRes); err != nil {
- t.Errorf("Could not decode server json. Error is: %v\n", err)
- t.FailNow()
- }
- apiServers := apiServerRes.Response
-
- params := make(url.Values)
- params.Add("type", serverType.Name)
- clientServers, err := to.ServersByType(params)
- if err != nil {
- t.Errorf("Could not get servers from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiServers) != len(clientServers) {
- t.Errorf("Server Response Length -- expected %v, got %v\n", len(apiServers), len(clientServers))
- }
-
- for _, apiServer := range apiServers {
- match := false
- for _, clientServer := range clientServers {
- if apiServer.ID == clientServer.ID {
- match = true
- compareServer(apiServer, clientServer, t)
- }
- }
- if !match {
- t.Errorf("Did not get a server matching %v\n", apiServer.ID)
- }
- }
-
-}
-
-func TestServersFQDN(t *testing.T) {
- serverType, err := GetType("server")
- if err != nil {
- t.Error("Could not get Type from client")
- t.FailNow()
- }
-
- params := make(url.Values)
- params.Add("type", serverType.Name)
- servers, err := to.ServersByType(params)
- if err != nil {
- t.Errorf("Could not get servers from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- serverFQDN := fmt.Sprintf("%s.%s", servers[0].HostName, servers[0].DomainName)
-
- clientFQDN, err := to.ServersFqdn(servers[0].HostName)
- if err != nil {
- t.Errorf("Servers FQDN failed...err: %v\n", err)
- }
- if clientFQDN != serverFQDN {
- t.Errorf("Client FQDN -- expected %v, got %v", serverFQDN, clientFQDN)
- }
-}
-
-func compareServer(server1 traffic_ops.Server, server2 traffic_ops.Server, t *testing.T) {
- if server1.CDNName != server2.CDNName {
- t.Errorf("CDNName -- Expected %v, got %v", server1.CDNName, server2.CDNName)
- }
- if server1.Cachegroup != server2.Cachegroup {
- t.Errorf("Cachegroup -- Expected %v, got %v", server1.Cachegroup, server2.Cachegroup)
- }
- if server1.DomainName != server2.DomainName {
- t.Errorf("DomainName -- Expected %v, got %v", server1.DomainName, server2.DomainName)
- }
- if server1.HostName != server2.HostName {
- t.Errorf("HostName -- Expected %v, got %v", server1.HostName, server2.HostName)
- }
- if server1.IP6Address != server2.IP6Address {
- t.Errorf("IP6Address -- Expected %v, got %v", server1.IPAddress, server2.IP6Address)
- }
- if server1.IP6Gateway != server2.IP6Gateway {
- t.Errorf("IP6Gateway -- Expected %v, got %v", server1.IP6Gateway, server2.IP6Gateway)
- }
- if server1.IPAddress != server2.IPAddress {
- t.Errorf("IPAddress -- Expected %v, got %v", server1.IPAddress, server2.IPAddress)
- }
- if server1.IPGateway != server2.IPGateway {
- t.Errorf("IPGateway -- Expected %v, got %v", server1.IPGateway, server2.IPGateway)
- }
- if server1.IPNetmask != server2.IPNetmask {
- t.Errorf("IPNetmask -- Expected %v, got %v", server1.IPNetmask, server2.IPNetmask)
- }
- if server1.IloIPAddress != server2.IloIPAddress {
- t.Errorf("IloIPAddress -- Expected %v, got %v", server1.IloIPAddress, server2.IloIPAddress)
- }
- if server1.IloIPGateway != server2.IloIPGateway {
- t.Errorf("IloIPGateway -- Expected %v, got %v", server1.IloIPGateway, server2.IloIPGateway)
- }
- if server1.IloIPNetmask != server2.IloIPNetmask {
- t.Errorf("IloIPNetmast -- Expected %v, got %v", server1.IloIPNetmask, server2.IloIPNetmask)
- }
- if server1.IloPassword != server2.IloPassword {
- t.Errorf("IloPassword -- Expected %v, got %v", server1.IloPassword, server2.IloPassword)
- }
- if server1.IloUsername != server2.IloUsername {
- t.Errorf("IloUsername -- Expected %v, got %v", server1.IloUsername, server2.IloUsername)
- }
- if server1.InterfaceMtu != server2.InterfaceMtu {
- t.Errorf("InterfaceMty -- Expected %v, got %v", server1.InterfaceMtu, server2.InterfaceMtu)
- }
- if server1.InterfaceName != server2.InterfaceName {
- t.Errorf("InterfaceName -- Expected %v, got %v", server1.InterfaceName, server2.InterfaceName)
- }
- if server1.LastUpdated != server2.LastUpdated {
- t.Errorf("LastUpdated -- Expected %v, got %v", server1.LastUpdated, server2.LastUpdated)
- }
- if server1.MgmtIPAddress != server2.MgmtIPAddress {
- t.Errorf("MgmtIPAddress -- Expected %v, got %v", server1.MgmtIPAddress, server2.MgmtIPAddress)
- }
- if server1.MgmtIPGateway != server2.MgmtIPGateway {
- t.Errorf("MgmtIPGateway -- Expected %v, got %v", server1.MgmtIPGateway, server2.MgmtIPGateway)
- }
- if server1.MgmtIPNetmask != server2.MgmtIPNetmask {
- t.Errorf("MgmtIPNetmask -- Expected %v, got %v", server1.MgmtIPNetmask, server2.MgmtIPNetmask)
- }
- if server1.PhysLocation != server2.PhysLocation {
- t.Errorf("PhysLocation -- Expected %v, got %v", server1.PhysLocation, server2.PhysLocation)
- }
- if server1.Profile != server2.Profile {
- t.Errorf("Profile -- Expected %v, got %v", server1.Profile, server2.Profile)
- }
- if server1.ProfileDesc != server2.ProfileDesc {
- t.Errorf("ProfileDesc -- Expected %v, got %v", server1.ProfileDesc, server2.ProfileDesc)
- }
- if server1.Rack != server2.Rack {
- t.Errorf("Rack -- Expected %v, got %v", server1.Rack, server2.Rack)
- }
- if server1.RouterHostName != server2.RouterHostName {
- t.Errorf("RouterHostName -- Expected %v, got %v", server1.RouterHostName, server2.RouterHostName)
- }
- if server1.RouterPortName != server2.RouterPortName {
- t.Errorf("RouterPortName -- Expected %v, got %v", server1.RouterPortName, server2.RouterPortName)
- }
- if server1.Status != server2.Status {
- t.Errorf("Status -- Expected %v, got %v", server1.Status, server2.Status)
- }
- if server1.TCPPort != server2.TCPPort {
- t.Errorf("TCPPort -- Expected %v, got %v", server1.TCPPort, server2.TCPPort)
- }
- if server1.Type != server2.Type {
- t.Errorf("Type -- Expected %v, got %v", server1.Type, server2.Type)
- }
- if server1.XMPPID != server2.XMPPID {
- t.Errorf("XMPPID -- Expected %v, got %v", server1.XMPPID, server2.XMPPID)
- }
- if server1.XMPPPasswd != server2.XMPPPasswd {
- t.Errorf("XMPPasswd -- Expected %v, got %v", server1.XMPPPasswd, server2.XMPPPasswd)
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/stats_summary_test.go b/traffic_ops/client_tests/tests/integration/stats_summary_test.go
deleted file mode 100644
index 401a740..0000000
--- a/traffic_ops/client_tests/tests/integration/stats_summary_test.go
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "testing"
- "time"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestStatsSummaryAll(t *testing.T) {
-
- uri := fmt.Sprintf("/api/1.2/stats_summary.json")
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiStatsSummaryRes traffic_ops.StatsSummaryResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiStatsSummaryRes); err != nil {
- t.Errorf("Could not decode stats summary json. Error is: %v\n", err)
- t.FailNow()
- }
- apiStatsSummary := apiStatsSummaryRes.Response
-
- clientStatsSummary, err := to.SummaryStats("", "", "")
- if err != nil {
- t.Errorf("Could not get stats summary from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiStatsSummary) != len(clientStatsSummary) {
- t.Errorf("Stats Summary Response Length -- expected %v, got %v\n", len(apiStatsSummary), len(clientStatsSummary))
- }
-
- for _, apiSs := range apiStatsSummary {
- match := false
- for _, clientSs := range clientStatsSummary {
- if apiSs == clientSs {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a stats summary matching %+v\n", apiSs)
- }
- }
-}
-
-func TestStatsSummarybyCDN(t *testing.T) {
- cdn, err := GetCdn()
- if err != nil {
- t.Error("Could not get a CDN, response was %v\n", err)
- t.FailNow()
- }
- uri := fmt.Sprintf("/api/1.2/stats_summary.json?cdnName=%s", cdn.Name)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiStatsSummaryRes traffic_ops.StatsSummaryResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiStatsSummaryRes); err != nil {
- t.Errorf("Could not decode stats summary json. Error is: %v\n", err)
- t.FailNow()
- }
- apiStatsSummary := apiStatsSummaryRes.Response
-
- clientStatsSummary, err := to.SummaryStats(cdn.Name, "", "")
- if err != nil {
- t.Errorf("Could not get stats summary from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiStatsSummary) != len(clientStatsSummary) {
- t.Errorf("Stats Summary Response Length -- expected %v, got %v\n", len(apiStatsSummary), len(clientStatsSummary))
- }
-
- for _, apiSs := range apiStatsSummary {
- match := false
- for _, clientSs := range clientStatsSummary {
- if apiSs == clientSs {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a stats summary matching %+v\n", apiSs)
- }
- }
-}
-
-func TestStatsSummaryByDs(t *testing.T) {
- ds, err := GetDeliveryService("")
- if err != nil {
- t.Error("Could not get a DS, response was %v\n", err)
- t.FailNow()
- }
- uri := fmt.Sprintf("/api/1.2/stats_summary.json?deliveryServiceName=%s", ds.XMLID)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiStatsSummaryRes traffic_ops.StatsSummaryResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiStatsSummaryRes); err != nil {
- t.Errorf("Could not decode stats summary json. Error is: %v\n", err)
- t.FailNow()
- }
- apiStatsSummary := apiStatsSummaryRes.Response
-
- clientStatsSummary, err := to.SummaryStats("", ds.XMLID, "")
- if err != nil {
- t.Errorf("Could not get stats summary from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiStatsSummary) != len(clientStatsSummary) {
- t.Errorf("Stats Summary Response Length -- expected %v, got %v\n", len(apiStatsSummary), len(clientStatsSummary))
- }
-
- for _, apiSs := range apiStatsSummary {
- match := false
- for _, clientSs := range clientStatsSummary {
- if apiSs == clientSs {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a stats summary matching %+v\n", apiSs)
- }
- }
-}
-
-func TestStatsSummaryByStatName(t *testing.T) {
- uri := fmt.Sprintf("/api/1.2/stats_summary.json?statName=daily_bytesserved")
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiStatsSummaryRes traffic_ops.StatsSummaryResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiStatsSummaryRes); err != nil {
- t.Errorf("Could not decode stats summary json. Error is: %v\n", err)
- t.FailNow()
- }
- apiStatsSummary := apiStatsSummaryRes.Response
-
- clientStatsSummary, err := to.SummaryStats("", "", "daily_bytesserved")
- if err != nil {
- t.Errorf("Could not get stats summary from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiStatsSummary) != len(clientStatsSummary) {
- t.Errorf("Stats Summary Response Length -- expected %v, got %v\n", len(apiStatsSummary), len(clientStatsSummary))
- }
-
- for _, apiSs := range apiStatsSummary {
- match := false
- for _, clientSs := range clientStatsSummary {
- if apiSs == clientSs {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a stats summary matching %+v\n", apiSs)
- }
- }
-}
-
-func TestAddSummaryStats(t *testing.T) {
- cdn, err := GetCdn()
- if err != nil {
- t.Errorf("Could not get a CDN, response was %v\n", err)
- t.FailNow()
- }
- ds, err := GetDeliveryService(cdn.Name)
- if err != nil {
- t.Errorf("Could not get a DS, response was %v\n", err)
- t.FailNow()
- }
- now := time.Now()
- summaryTime := now.Format(time.RFC3339)
- statDate := now.Format("2006-01-02")
-
- testStatsSummay := new(traffic_ops.StatsSummary)
- testStatsSummay.CDNName = cdn.Name
- testStatsSummay.DeliveryService = ds.XMLID
- testStatsSummay.StatDate = statDate
- testStatsSummay.StatName = "testStatName"
- testStatsSummay.StatValue = "1234"
- testStatsSummay.SummaryTime = summaryTime
-
- err = to.AddSummaryStats(*testStatsSummay)
- if err != nil {
- t.Errorf("Could not add Summary Stats, response was %v\n", err)
- t.FailNow()
- }
-
- ssRes, err := to.SummaryStats(testStatsSummay.CDNName, testStatsSummay.DeliveryService, testStatsSummay.StatName)
- if err != nil {
- t.Errorf("Could not get a SummaryStats, error was: %v\n", err)
- t.FailNow()
- }
- match := false
- for _, ss := range ssRes {
- if ss.CDNName == testStatsSummay.CDNName &&
- ss.DeliveryService == testStatsSummay.DeliveryService &&
- ss.StatDate == testStatsSummay.StatDate &&
- ss.StatName == testStatsSummay.StatName &&
- ss.StatValue == testStatsSummay.StatValue {
- match = true
- }
- }
- if !match {
- t.Errorf("Stats Summary not found in Traffic Ops after Adding. Summary Stats Response was: %+v, expecting: %+v\n", ssRes, *testStatsSummay)
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/traffic_monitor_config_test.go b/traffic_ops/client_tests/tests/integration/traffic_monitor_config_test.go
deleted file mode 100644
index e7a8433..0000000
--- a/traffic_ops/client_tests/tests/integration/traffic_monitor_config_test.go
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestTrafficMonitorConfig(t *testing.T) {
- cdn, err := GetCdn()
- if err != nil {
- t.Errorf("Could not get CDN, error was: %v\n", err)
- }
- uri := fmt.Sprintf("/api/1.2/cdns/%s/configs/monitoring.json", cdn.Name)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiTMConfigRes traffic_ops.TMConfigResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiTMConfigRes); err != nil {
- t.Errorf("Could not decode Traffic Monitor Config response. Error is: %v\n", err)
- t.FailNow()
- }
- apiTMConfig := apiTMConfigRes.Response
-
- clientTMConfig, err := to.TrafficMonitorConfig(cdn.Name)
- if err != nil {
- t.Errorf("Could not get Traffic Monitor Config from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiTMConfig.CacheGroups) != len(clientTMConfig.CacheGroups) {
- t.Errorf("Length of Traffic Monitor config cachegroups do not match! Expected %v, got %v\n", len(apiTMConfig.CacheGroups), len(clientTMConfig.CacheGroups))
- }
-
- for _, apiCg := range apiTMConfig.CacheGroups {
- match := false
- for _, clientCg := range clientTMConfig.CacheGroups {
- if apiCg == clientCg {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a cachegroup matching %+v\n", apiCg)
- }
- }
-
- if len(apiTMConfig.DeliveryServices) != len(clientTMConfig.DeliveryServices) {
- t.Errorf("Length of Traffic Monitor config deliveryserivces do not match! Expected %v, got %v\n", len(apiTMConfig.DeliveryServices), len(clientTMConfig.DeliveryServices))
- }
-
- for _, apiDs := range apiTMConfig.DeliveryServices {
- match := false
- for _, clientDs := range clientTMConfig.DeliveryServices {
- if apiDs == clientDs {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a Deliveryservice matching %+v\n", apiDs)
- }
- }
-
- if len(apiTMConfig.Profiles) != len(clientTMConfig.Profiles) {
- t.Errorf("Length of Traffic Monitor config profiles do not match! Expected %v, got %v\n", len(apiTMConfig.Profiles), len(clientTMConfig.Profiles))
- }
-
- for _, apiProfile := range apiTMConfig.Profiles {
- match := false
- for _, clientProfile := range clientTMConfig.Profiles {
- if apiProfile.Name == clientProfile.Name {
- match = true
- if apiProfile.Parameters.HealthConnectionTimeout != clientProfile.Parameters.HealthConnectionTimeout {
- t.Errorf("Prof.Param.HealthConnTimeout -- Expected %v got %v", apiProfile.Parameters.HealthConnectionTimeout, clientProfile.Parameters.HealthConnectionTimeout)
- }
- if apiProfile.Parameters.HealthPollingURL != clientProfile.Parameters.HealthPollingURL {
- t.Errorf("Prof.Param.HealthPollURL -- Expected %v got %v", apiProfile.Parameters.HealthPollingURL, clientProfile.Parameters.HealthPollingURL)
- }
- if apiProfile.Parameters.HistoryCount != clientProfile.Parameters.HistoryCount {
- t.Errorf("Prof.Param.HistCount -- Expected %v got %v", apiProfile.Parameters.HistoryCount, clientProfile.Parameters.HistoryCount)
- }
- if apiProfile.Parameters.MinFreeKbps != clientProfile.Parameters.MinFreeKbps {
- t.Errorf("Prof.Param.MinFreeKbps -- Expected %v got %v", apiProfile.Parameters.MinFreeKbps, clientProfile.Parameters.MinFreeKbps)
- }
- if len(apiProfile.Parameters.Thresholds) != len(clientProfile.Parameters.Thresholds) {
- t.Errorf("Len Prof.Param.Thresholds -- Expected %v got %v", len(apiProfile.Parameters.Thresholds), len(clientProfile.Parameters.Thresholds))
- }
- }
- }
- if !match {
- t.Errorf("Did not get a Profile matching %+v\n", apiProfile)
- }
- }
-
- if len(apiTMConfig.TrafficMonitors) != len(clientTMConfig.TrafficMonitors) {
- t.Errorf("Length of Traffic Monitor config traffic monitors does not match! Expected %v, got %v\n", len(apiTMConfig.TrafficMonitors), len(clientTMConfig.TrafficMonitors))
- }
-
- for _, apiTM := range apiTMConfig.TrafficMonitors {
- match := false
- for _, clientTM := range clientTMConfig.TrafficMonitors {
- if apiTM == clientTM {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a Traffic Monitor matching %+v\n", apiTM)
- }
- }
-
- if len(apiTMConfig.TrafficServers) != len(clientTMConfig.TrafficServers) {
- t.Errorf("Length of Traffic Monitor config traffic servers does not match! Expected %v, got %v\n", len(apiTMConfig.TrafficServers), len(clientTMConfig.TrafficServers))
- }
-
- for _, apiTS := range apiTMConfig.TrafficServers {
- match := false
- for _, clientTS := range clientTMConfig.TrafficServers {
- if apiTS.HostName == clientTS.HostName {
- match = true
- if apiTS.CacheGroup != clientTS.CacheGroup {
- t.Errorf("Cachegroup -- Expected %v, got %v\n", apiTS.CacheGroup, clientTS.CacheGroup)
- }
- if len(apiTS.DeliveryServices) != len(clientTS.DeliveryServices) {
- t.Errorf("len DeliveryServices -- Expected %v, got %v\n", len(apiTS.DeliveryServices), len(clientTS.DeliveryServices))
- }
- for _, apiDS := range apiTS.DeliveryServices {
- dsMatch := false
- for _, clientDS := range clientTS.DeliveryServices {
- if apiDS.Xmlid == clientDS.Xmlid && len(apiDS.Remaps) == len(clientDS.Remaps) {
- dsMatch = true
- }
- }
- if !dsMatch {
- t.Errorf("Could not finding a matching DS for %v\n", apiDS.Xmlid)
- }
- }
- if apiTS.FQDN != clientTS.FQDN {
- t.Errorf("FQDN -- Expected %v, got %v\n", apiTS.FQDN, clientTS.FQDN)
- }
- if apiTS.HashID != clientTS.HashID {
- t.Errorf("HashID -- Expected %v, got %v\n", apiTS.HashID, clientTS.HashID)
- }
- if apiTS.IP != clientTS.IP {
- t.Errorf("IP -- Expected %v, got %v\n", apiTS.IP, clientTS.IP)
- }
- if apiTS.IP6 != clientTS.IP6 {
- t.Errorf("IP6 -- Expected %v, got %v\n", apiTS.IP6, clientTS.IP6)
- }
- if apiTS.InterfaceName != clientTS.InterfaceName {
- t.Errorf("Interface Name -- Expected %v, got %v\n", apiTS.InterfaceName, clientTS.InterfaceName)
- }
- if apiTS.Port != clientTS.Port {
- t.Errorf("Port -- Expected %v, got %v\n", apiTS.Port, clientTS.Port)
- }
- if apiTS.Profile != clientTS.Profile {
- t.Errorf("Profile -- Expected %v, got %v\n", apiTS.Profile, clientTS.Profile)
- }
- if apiTS.Status != clientTS.Status {
- t.Errorf("Status -- Expected %v, got %v\n", apiTS.Status, clientTS.Status)
- }
- if apiTS.Type != clientTS.Type {
- t.Errorf("Type -- Expected %v, got %v\n", apiTS.Type, clientTS.Type)
- }
- }
- }
- if !match {
- t.Errorf("Did not get a Traffic Server matching %+v\n", apiTS)
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/traffic_router_config_test.go b/traffic_ops/client_tests/tests/integration/traffic_router_config_test.go
deleted file mode 100644
index 40a0bd7..0000000
--- a/traffic_ops/client_tests/tests/integration/traffic_router_config_test.go
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestTrafficRouterConfig(t *testing.T) {
- cdn, err := GetCdn()
- if err != nil {
- t.Errorf("Could not get CDN, error was: %v\n", err)
- }
- uri := fmt.Sprintf("/api/1.2/cdns/%s/configs/routing.json", cdn.Name)
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiTRConfigRes traffic_ops.TRConfigResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiTRConfigRes); err != nil {
- t.Errorf("Could not decode Traffic Router Config response. Error is: %v\n", err)
- t.FailNow()
- }
- apiTRConfig := apiTRConfigRes.Response
-
- clientTRConfig, err := to.TrafficRouterConfig(cdn.Name)
- if err != nil {
- t.Errorf("Could not get Traffic Router Config from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiTRConfig.CacheGroups) != len(clientTRConfig.CacheGroups) {
- t.Errorf("Length of Traffic Router config cachegroups do not match! Expected %v, got %v\n", len(apiTRConfig.CacheGroups), len(clientTRConfig.CacheGroups))
- }
-
- for _, apiCg := range apiTRConfig.CacheGroups {
- match := false
- for _, clientCg := range clientTRConfig.CacheGroups {
- if apiCg == clientCg {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a cachegroup matching %+v\n", apiCg)
- }
- }
-
- if len(apiTRConfig.DeliveryServicesRouter) != len(clientTRConfig.DeliveryServicesRouter) {
- t.Errorf("Length of Traffic Router config deliveryserivces do not match! Expected %v, got %v\n", len(apiTRConfig.DeliveryServicesRouter), len(clientTRConfig.DeliveryServicesRouter))
- }
-
- for _, apiDs := range apiTRConfig.DeliveryServicesRouter {
- match := false
- for _, clientDs := range clientTRConfig.DeliveryServicesRouter {
- if apiDs.XMLID == clientDs.XMLID {
- match = true
- if apiDs.BypassDestination != clientDs.BypassDestination {
- t.Errorf("BypassDestination -- Expected %v, got %v\n", apiDs.BypassDestination, clientDs.BypassDestination)
- }
- if apiDs.CoverageZoneOnly != clientDs.CoverageZoneOnly {
- t.Errorf("CZ Only -- Expected %v, got %v\n", apiDs.CoverageZoneOnly, clientDs.CoverageZoneOnly)
- }
- if len(apiDs.Domains) != len(clientDs.Domains) {
- t.Errorf("len Domains -- Expected %v, got %v\n", len(apiDs.Domains), len(clientDs.Domains))
- }
- for _, apiDomain := range apiDs.Domains {
- domainMatch := false
- for _, clientDomain := range clientDs.Domains {
- if apiDomain == clientDomain {
- domainMatch = true
- }
- }
- if !domainMatch {
- t.Errorf("Domains -- Did not find a match for %v\n", apiDomain)
- }
- }
- if len(apiDs.MatchSets) != len(clientDs.MatchSets) {
- t.Errorf("len Matchsets -- Expected %v, got %v\n", len(apiDs.MatchSets), len(clientDs.MatchSets))
- }
- for _, apiMatch := range apiDs.MatchSets {
- foundMatch := false
- for _, clientMatch := range clientDs.MatchSets {
- if apiMatch.Protocol == clientMatch.Protocol && len(apiMatch.MatchList) == len(clientMatch.MatchList) {
- foundMatch = true
- }
- }
- if !foundMatch {
- t.Errorf("Matchsets -- Did not find a match for %+v\n", apiMatch)
- }
- }
- if apiDs.MissLocation != clientDs.MissLocation {
- t.Errorf("MissLocation -- Expected %v, got %v\n", apiDs.MissLocation, clientDs.MissLocation)
- }
- if apiDs.Soa != clientDs.Soa {
- t.Errorf("Soa-- Expected %v, got %v\n", apiDs.Soa, clientDs.Soa)
- }
- if apiDs.TTL != clientDs.TTL {
- t.Errorf("TTL -- Expected %v, got %v\n", apiDs.TTL, clientDs.TTL)
- }
- if apiDs.TTLs != clientDs.TTLs {
- t.Errorf("TTLs -- Expected %v, got %v\n", apiDs.TTLs, clientDs.TTLs)
- }
- if len(apiDs.StatcDNSEntries) != len(clientDs.StatcDNSEntries) {
- t.Errorf("len StaticDNSEntries -- Expected %v, got %v\n", len(apiDs.StatcDNSEntries), len(clientDs.StatcDNSEntries))
- }
- for _, apiEntry := range apiDs.StatcDNSEntries {
- found := false
- for _, clientEntry := range clientDs.StatcDNSEntries {
- if apiEntry == clientEntry {
- found = true
- }
- }
- if !found {
- t.Errorf("Static DNS -- Did not find a match for %+v\n", apiEntry)
- }
- }
-
- }
- }
- if !match {
- t.Errorf("Did not get a Deliveryservice matching %+v\n", apiDs)
- }
- }
-
- if len(apiTRConfig.TrafficMonitors) != len(clientTRConfig.TrafficMonitors) {
- t.Errorf("Length of Traffic Router config Traffic Routers does not match! Expected %v, got %v\n", len(apiTRConfig.TrafficMonitors), len(clientTRConfig.TrafficMonitors))
- }
-
- for _, apiTM := range apiTRConfig.TrafficMonitors {
- match := false
- for _, clientTM := range clientTRConfig.TrafficMonitors {
- if apiTM == clientTM {
- match = true
- }
- }
- if !match {
- t.Errorf("Did not get a Traffic Router matching %+v\n", apiTM)
- }
- }
-
- if len(apiTRConfig.TrafficServers) != len(clientTRConfig.TrafficServers) {
- t.Errorf("Length of Traffic Router config traffic servers does not match! Expected %v, got %v\n", len(apiTRConfig.TrafficServers), len(clientTRConfig.TrafficServers))
- }
-
- for _, apiTS := range apiTRConfig.TrafficServers {
- match := false
- for _, clientTS := range clientTRConfig.TrafficServers {
- if apiTS.HostName == clientTS.HostName {
- match = true
- if apiTS.CacheGroup != clientTS.CacheGroup {
- t.Errorf("Cachegroup -- Expected %v, got %v\n", apiTS.CacheGroup, clientTS.CacheGroup)
- }
- if len(apiTS.DeliveryServicesRouter) != len(clientTS.DeliveryServicesRouter) {
- t.Errorf("len DeliveryServicesRouter -- Expected %v, got %v\n", len(apiTS.DeliveryServicesRouter), len(clientTS.DeliveryServicesRouter))
- }
- for _, apiDS := range apiTS.DeliveryServicesRouter {
- dsMatch := false
- for _, clientDS := range clientTS.DeliveryServicesRouter {
- if apiDS.Xmlid == clientDS.Xmlid && len(apiDS.Remaps) == len(clientDS.Remaps) {
- dsMatch = true
- }
- }
- if !dsMatch {
- t.Errorf("Could not finding a matching DS for %v\n", apiDS.Xmlid)
- }
- }
- if apiTS.FQDN != clientTS.FQDN {
- t.Errorf("FQDN -- Expected %v, got %v\n", apiTS.FQDN, clientTS.FQDN)
- }
- if apiTS.HashID != clientTS.HashID {
- t.Errorf("HashID -- Expected %v, got %v\n", apiTS.HashID, clientTS.HashID)
- }
- if apiTS.IP != clientTS.IP {
- t.Errorf("IP -- Expected %v, got %v\n", apiTS.IP, clientTS.IP)
- }
- if apiTS.IP6 != clientTS.IP6 {
- t.Errorf("IP6 -- Expected %v, got %v\n", apiTS.IP6, clientTS.IP6)
- }
- if apiTS.InterfaceName != clientTS.InterfaceName {
- t.Errorf("Interface Name -- Expected %v, got %v\n", apiTS.InterfaceName, clientTS.InterfaceName)
- }
- if apiTS.Port != clientTS.Port {
- t.Errorf("Port -- Expected %v, got %v\n", apiTS.Port, clientTS.Port)
- }
- if apiTS.Profile != clientTS.Profile {
- t.Errorf("Profile -- Expected %v, got %v\n", apiTS.Profile, clientTS.Profile)
- }
- if apiTS.Status != clientTS.Status {
- t.Errorf("Status -- Expected %v, got %v\n", apiTS.Status, clientTS.Status)
- }
- if apiTS.Type != clientTS.Type {
- t.Errorf("Type -- Expected %v, got %v\n", apiTS.Type, clientTS.Type)
- }
- }
- }
- if !match {
- t.Errorf("Did not get a Traffic Server matching %+v\n", apiTS)
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/type_test.go b/traffic_ops/client_tests/tests/integration/type_test.go
deleted file mode 100644
index 38284c6..0000000
--- a/traffic_ops/client_tests/tests/integration/type_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestTypes(t *testing.T) {
-
- uri := fmt.Sprintf("/api/1.2/types.json")
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiTypeRes traffic_ops.TypeResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiTypeRes); err != nil {
- t.Errorf("Could not decode type json. Error is: %v\n", err)
- t.FailNow()
- }
- apiTypes := apiTypeRes.Response
-
- clientTypes, err := to.Types()
- if err != nil {
- t.Errorf("Could not get types from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiTypes) != len(clientTypes) {
- t.Errorf("Types Response Length -- expected %v, got %v\n", len(apiTypes), len(clientTypes))
- }
-
- for _, apiType := range apiTypes {
- match := false
- for _, clientType := range clientTypes {
- if apiType.ID == clientType.ID {
- match = true
- if apiType.Description != clientType.Description {
- t.Errorf("Description -- Expected %v, got %v\n", apiType.Description, clientType.Description)
- }
- if apiType.Name != clientType.Name {
- t.Errorf("Name -- Expected %v, got %v\n", apiType.Name, clientType.Name)
- }
- if apiType.UseInTable != clientType.UseInTable {
- t.Errorf("UseInTable -- Expected %v, got %v\n", apiType.UseInTable, clientType.UseInTable)
- }
- }
- }
- if !match {
- t.Errorf("Did not get a type matching %v\n", apiType.Name)
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/integration/user_test.go b/traffic_ops/client_tests/tests/integration/user_test.go
deleted file mode 100644
index 7307b59..0000000
--- a/traffic_ops/client_tests/tests/integration/user_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package integration
-
-import (
- "encoding/json"
- "fmt"
- "testing"
-
- traffic_ops "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
-)
-
-func TestUsers(t *testing.T) {
-
- uri := fmt.Sprintf("/api/1.2/users.json")
- resp, err := Request(*to, "GET", uri, nil)
- if err != nil {
- t.Errorf("Could not get %s reponse was: %v\n", uri, err)
- t.FailNow()
- }
-
- defer resp.Body.Close()
- var apiUserRes traffic_ops.UserResponse
- if err := json.NewDecoder(resp.Body).Decode(&apiUserRes); err != nil {
- t.Errorf("Could not decode user json. Error is: %v\n", err)
- t.FailNow()
- }
- apiUsers := apiUserRes.Response
-
- clientUsers, err := to.Users()
- if err != nil {
- t.Errorf("Could not get users from client. Error is: %v\n", err)
- t.FailNow()
- }
-
- if len(apiUsers) != len(clientUsers) {
- t.Errorf("Users Response Length -- expected %v, got %v\n", len(apiUsers), len(clientUsers))
- }
-
- for _, apiUser := range apiUsers {
- match := false
- for _, clientUser := range clientUsers {
- if apiUser.ID == clientUser.ID {
- match = true
- if apiUser != clientUser {
- t.Errorf("apiUser and clientUser do not match! Expected %+v, got %+v\n", apiUser, clientUser)
- }
- }
- }
- if !match {
- t.Errorf("Did not get a user matching %v\n", apiUser.Email)
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/parameter_test.go b/traffic_ops/client_tests/tests/parameter_test.go
deleted file mode 100644
index 36eb317..0000000
--- a/traffic_ops/client_tests/tests/parameter_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestParameters(t *testing.T) {
- resp := fixtures.Parameters()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Parameters")
-
- parameters, err := to.Parameters("test")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(parameters) != 1 {
- testHelper.Error(t, "Should get back \"1\" Parameter, got: %d", len(parameters))
- } else {
- testHelper.Success(t, "Should get back \"1\" Parameter")
- }
-
- for _, param := range parameters {
- if param.Name != "location" {
- testHelper.Error(t, "Should get back \"location\" for \"Name\", got: %s", param.Name)
- } else {
- testHelper.Success(t, "Should get back \"location\" for \"Name\"")
- }
-
- if param.Value != "/foo/trafficserver/" {
- testHelper.Error(t, "Should get back \"/foo/trafficserver/\" for \"Value\", got: %s", param.Value)
- } else {
- testHelper.Success(t, "Should get back \"/foo/trafficserver/\" for \"Value\"")
- }
-
- if param.ConfigFile != "parent.config" {
- testHelper.Error(t, "Should get back \"parent.config\" for \"ConfigFile\", got: %s", param.ConfigFile)
- } else {
- testHelper.Success(t, "Should get back \"parent.config\" for \"ConfigFile\"")
- }
- }
-}
-
-func TestParametersUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Parameters")
-
- _, err := to.Parameters("test")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/profile_test.go b/traffic_ops/client_tests/tests/profile_test.go
deleted file mode 100644
index f01c071..0000000
--- a/traffic_ops/client_tests/tests/profile_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestProfile(t *testing.T) {
- resp := fixtures.Profiles()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Profiles")
-
- profiles, err := to.Profiles()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(profiles) != 1 {
- testHelper.Error(t, "Should get back \"1\" Profile, got: %d", len(profiles))
- } else {
- testHelper.Success(t, "Should get back \"1\" Profile")
- }
-
- for _, p := range profiles {
- if p.ID != 1 {
- testHelper.Error(t, "Should get back 1 for \"ID\", got: %d", p.ID)
- } else {
- testHelper.Success(t, "Should get back 1 for \"ID\"")
- }
-
- if p.Name != "TR_CDN2" {
- testHelper.Error(t, "Should get back \"TR_CDN2\" for \"Name\", got: %s", p.Name)
- } else {
- testHelper.Success(t, "Should get back \"TR_CDN2\" for \"Name\"")
- }
-
- if p.Description != "kabletown Content Router" {
- testHelper.Error(t, "Should get back \"kabletown Content Router\" for \"Description\", got: %s", p.Description)
- } else {
- testHelper.Success(t, "Should get back \"kabletown Content Router\" for \"Description\"")
- }
- }
-}
-
-func TestProfilesUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Profiles")
-
- _, err := to.Profiles()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/server_test.go b/traffic_ops/client_tests/tests/server_test.go
deleted file mode 100644
index 7bd762d..0000000
--- a/traffic_ops/client_tests/tests/server_test.go
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "net/url"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestServers(t *testing.T) {
- resp := fixtures.Servers()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Servers")
-
- servers, err := to.Servers()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(servers) != 3 {
- testHelper.Error(t, "Should get back \"3\" Server, got: %d", len(servers))
- } else {
- testHelper.Success(t, "Should get back \"3\" Server")
- }
-
- if servers[0].HostName != "edge-alb-01" {
- testHelper.Error(t, "Should get \"edge-alb-01\" for \"HostName\", got: %s", servers[0].HostName)
- } else {
- testHelper.Success(t, "Should get \"edge-alb-01\" for \"HostName\"")
- }
-
- if servers[0].DomainName != "albuquerque.nm.albuq.kabletown.com" {
- testHelper.Error(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\", got: %s", servers[0].DomainName)
- } else {
- testHelper.Success(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\"")
- }
-
- if servers[0].Type != "EDGE" {
- testHelper.Error(t, "Should get \"EDGE\" for \"Type\", got: %s", servers[0].Type)
- } else {
- testHelper.Success(t, "Should get \"EDGE\" for \"Type\"")
- }
-}
-
-func TestServersUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Servers")
-
- _, err := to.Servers()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestServerFQDN(t *testing.T) {
- resp := fixtures.Servers()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- shortName := "edge-alb-01"
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for the FQDN of Server: \"%s\"", shortName)
-
- s, err := to.ServersFqdn("edge-alb-01")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if s != "edge-alb-01.albuquerque.nm.albuq.kabletown.com" {
- testHelper.Error(t, "Should get back \"edge-alb-01.albuquerque.nm.albuq.kabletown.com\", got: %s", s)
- } else {
- testHelper.Success(t, "Should get back \"edge-alb-01.albuquerque.nm.albuq.kabletown.com\"")
- }
-}
-
-func TestServerFQDNError(t *testing.T) {
- var resp client.ServerResponse
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- shortName := "edge-alb-01"
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for the FQDN of Server: \"%s\"", shortName)
-
- _, err := to.ServersFqdn(shortName)
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestServerFQDNUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- shortName := "edge-alb-01"
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for the FQDN of Server: \"%s\"", shortName)
-
- _, err := to.ServersFqdn(shortName)
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestServerShortName(t *testing.T) {
- resp := fixtures.Servers()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- pattern := "edge"
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for servers that match Short Name: \"%s\"", pattern)
-
- servers, err := to.ServersShortNameSearch(pattern)
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if servers[0] != "edge-alb-01" {
- testHelper.Error(t, "Should get back \"edge-alb-01\", got: %s", servers[0])
- } else {
- testHelper.Success(t, "Should get back \"edge-alb-01\"")
- }
-
- if servers[1] != "edge-alb-02" {
- testHelper.Error(t, "Should get back \"edge-alb-02\", got: %s", servers[1])
- } else {
- testHelper.Success(t, "Should get back \"edge-alb-02\"")
- }
-}
-
-func TestServerShortNameError(t *testing.T) {
- var resp client.ServerResponse
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- pattern := "edge"
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for servers that match Short Name: \"%s\"", pattern)
-
- _, err := to.ServersShortNameSearch(pattern)
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestServerShortNameUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- pattern := "edge"
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for servers that match Short Name: \"%s\"", pattern)
-
- _, err := to.ServersShortNameSearch(pattern)
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestServerByType(t *testing.T) {
- resp := fixtures.LogstashServers()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for \"Logstash\" Servers")
-
- params := make(url.Values)
- params.Add("type", "Logstash")
-
- servers, err := to.ServersByType(params)
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(servers) != 2 {
- testHelper.Error(t, "Should get back \"2\" Server, got: %d", len(servers))
- } else {
- testHelper.Success(t, "Should get back \"2\" Server")
- }
-
- if servers[0].HostName != "logstash-01" {
- testHelper.Error(t, "Should get \"logstash-01\" for \"HostName\", got: %s", servers[0].HostName)
- } else {
- testHelper.Success(t, "Should get \"logstash-01\" for \"HostName\"")
- }
-
- if servers[0].DomainName != "albuquerque.nm.albuq.kabletown.com" {
- testHelper.Error(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\", got: %s", servers[0].DomainName)
- } else {
- testHelper.Success(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\"")
- }
-
- if servers[0].Type != "LOGSTASH" {
- testHelper.Error(t, "Should get \"LOGSTASH\" for \"Type\", got: %s", servers[0].Type)
- } else {
- testHelper.Success(t, "Should get \"LOGSTASH\" for \"Type\"")
- }
-}
-
-func TestServerByTypeUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for \"Logstash\" servers")
-
- params := make(url.Values)
- params.Add("type", "Logstash")
-
- _, err := to.ServersByType(params)
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
-
-func TestServer(t *testing.T) {
- resp := fixtures.Server()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Servers")
-
- toserver, err := to.Server(resp.Response.HostName)
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if toserver.HostName != "edge-alb-01" {
- testHelper.Error(t, "Should get \"edge-alb-01\" for \"HostName\", got: %s", toserver.HostName)
- } else {
- testHelper.Success(t, "Should get \"edge-alb-01\" for \"HostName\"")
- }
-
- if toserver.DomainName != "albuquerque.nm.albuq.kabletown.com" {
- testHelper.Error(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\", got: %s", toserver.DomainName)
- } else {
- testHelper.Success(t, "Should get \"albuquerque.nm.albuq.kabletown.com\" for \"DomainName\"")
- }
-
- if toserver.Type != "EDGE" {
- testHelper.Error(t, "Should get \"EDGE\" for \"Type\", got: %s", toserver.Type)
- } else {
- testHelper.Success(t, "Should get \"EDGE\" for \"Type\"")
- }
-
- if toserver.CDNName != "CDN-1" {
- testHelper.Error(t, "Should get \"CDN-1\" for \"CDNName\", got: %s", toserver.CDNName)
- } else {
- testHelper.Success(t, "Should get \"CDN-1\" for \"CDNName\"")
- }
-}
diff --git a/traffic_ops/client_tests/tests/stats_summary_test.go b/traffic_ops/client_tests/tests/stats_summary_test.go
deleted file mode 100644
index de91fce..0000000
--- a/traffic_ops/client_tests/tests/stats_summary_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestStatsSummary(t *testing.T) {
- resp := fixtures.StatsSummary()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Stats Summary")
-
- stats, err := to.SummaryStats("test-cdn", "test-ds1", "test-stat")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(stats) != 1 {
- testHelper.Error(t, "Should get back \"1\" Parameter, got: %d", len(stats))
- } else {
- testHelper.Success(t, "Should get back \"1\" Parameter")
- }
-
- for _, s := range stats {
- if s.StatName != "test-stat" {
- testHelper.Error(t, "Should get back \"test-stat\" for \"StatName\", got: %s", s.StatName)
- } else {
- testHelper.Success(t, "Should get back \"test-stat\" for \"StatName\"")
- }
-
- if s.DeliveryService != "test-ds1" {
- testHelper.Error(t, "Should get back \"test-ds1\" for \"DeliveryService\", got: %s", s.DeliveryService)
- } else {
- testHelper.Success(t, "Should get back \"test-ds1\" for \"DeliveryService\"")
- }
-
- if s.StatValue != "3.1415" {
- testHelper.Error(t, "Should get back \"3.1415\" for \"StatValue\", got: %s", s.StatValue)
- } else {
- testHelper.Success(t, "Should get back \"3.1415\" for \"StatValue\"")
- }
-
- if s.CDNName != "test-cdn" {
- testHelper.Error(t, "Should get back \"test-cdn\" for \"CDNName\", got: %s", s.CDNName)
- } else {
- testHelper.Success(t, "Should get back \"test-cdn\" for \"CDNName\"")
- }
- }
-}
-
-func TestStatsSummaryUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Stats Summary")
-
- _, err := to.SummaryStats("test-cdn", "test-ds1", "test-stat")
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/tenant_test.go b/traffic_ops/client_tests/tests/tenant_test.go
deleted file mode 100644
index fe33d05..0000000
--- a/traffic_ops/client_tests/tests/tenant_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client_tests/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestTenants(t *testing.T) {
- resp := fixtures.Tenants()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Tenants")
-
- t, err := to.Tenants()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if len(t) != 1 {
- testHelper.Error(t, "Should get back \"1\" Tenant, got: %d", len(t))
- } else {
- testHelper.Success(t, "Should get back \"1\" Tenant")
- }
-
- for _, s := range t {
- if s.ID != 001 {
- testHelper.Error(t, "Should get back \"1\" for \"ID\", got: %s", s.ID)
- } else {
- testHelper.Success(t, "Should get back \"1\" for \"ID\"")
- }
- }
-}
-
-func TestTenantUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Tenants")
-
- _, err := to.Tenants()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/traffic_monitor_config_test.go b/traffic_ops/client_tests/tests/traffic_monitor_config_test.go
deleted file mode 100644
index c70e72f..0000000
--- a/traffic_ops/client_tests/tests/traffic_monitor_config_test.go
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestTMConfig(t *testing.T) {
- resp := fixtures.TrafficMonitorConfig()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config")
-
- tm, err := to.TrafficMonitorConfigMap("test-cdn")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config - Traffic Server")
-
- ts := tm.TrafficServer
- if len(ts) != 2 {
- testHelper.Error(t, "Should get back \"2\" Traffic Servers, got: %d", len(ts))
- } else {
- testHelper.Success(t, "Should get back \"2\" Traffic Servers")
- }
-
- hashID := "tr-chi-05"
- if val, ok := ts[hashID]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", hashID)
-
- if val.IP != "10.10.10.10" {
- testHelper.Error(t, "Should get back \"10.10.10.10\" for \"IP\", got: %s", val.IP)
- } else {
- testHelper.Success(t, "Should get back \"10.10.10.10\" for \"IP\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", hashID)
- }
-
- hashID = "edge-test-01"
- if val, ok := ts[hashID]; ok {
- testHelper.Success(t, "Should get back map entry for for \"%s\"", hashID)
-
- if val.Type != "EDGE" {
- testHelper.Error(t, "Should get back \"EDGE\" for \"%s\" \"Type\", got: %s", hashID, ts[hashID].Type)
- } else {
- testHelper.Success(t, "Should get back \"EDGE\" for \"%s\" \"Type\"", hashID)
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", hashID)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Traffic Monitor")
-
- m := tm.TrafficMonitor
- if len(m) != 1 {
- testHelper.Error(t, "Should get back \"1\" Traffic Servers, got: %d", len(m))
- } else {
- testHelper.Success(t, "Should get back \"1\" Traffic Servers")
- }
-
- hostName := "traffic-monitor-01"
- if val, ok := m[hostName]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", hostName)
-
- if val.Status != "ONLINE" {
- testHelper.Error(t, "Should get back \"ONLINE\" for \"Status\", got: %s", val.Status)
- } else {
- testHelper.Success(t, "Should get back \"ONLINE\" for \"Status\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", hostName)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config - CacheGroups")
-
- c := tm.CacheGroup
- if len(c) != 2 {
- testHelper.Error(t, "Should get back \"2\" Traffic Servers, got: %d", len(c))
- } else {
- testHelper.Success(t, "Should get back \"2\" Traffic Servers")
- }
-
- name := "philadelphia"
- if val, ok := c[name]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", name)
-
- if val.Coordinates.Latitude != 55 {
- testHelper.Error(t, "Should get back \"55\" for \"Coordinates.Latitude\", got: %s", val.Coordinates.Latitude)
- } else {
- testHelper.Success(t, "Should get back \"55\" for \"Coordinates.Latitude\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", name)
- }
-
- name = "tr-chicago"
- if val, ok := c[name]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", name)
-
- if val.Coordinates.Longitude != 9 {
- testHelper.Error(t, "Should get back \"9\" for \"Coordinates.Longitude\", got: %s", val.Coordinates.Longitude)
- } else {
- testHelper.Success(t, "Should get back \"9\" for \"Coordinates.Longitude\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", name)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config - Delivery Services")
-
- ds := tm.DeliveryService
- if len(ds) != 1 {
- testHelper.Error(t, "Should get back \"1\" TM Delivery Service, got: %d", len(ds))
- } else {
- testHelper.Success(t, "Should get back \"1\" TM Delivery Service")
- }
-
- xmlID := "ds-05"
- if val, ok := ds[xmlID]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", xmlID)
-
- if val.Status != "REPORTED" {
- testHelper.Error(t, "Should get back \"REPORTED\" for \"Status\", got: %s", val.Status)
- } else {
- testHelper.Success(t, "Should get back \"REPORTED\" for \"Status\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", xmlID)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config - TM Profiles")
-
- p := tm.Profile
- if len(p) != 1 {
- testHelper.Error(t, "Should get back \"1\" TM Profie, got: %d", len(p))
- } else {
- testHelper.Success(t, "Should get back \"1\" TM Profile")
- }
-
- name = "tm-123"
- if val, ok := p[name]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", name)
-
- if val.Parameters.HealthConnectionTimeout != 2000 {
- testHelper.Error(t, "Should get back \"2000\" for \"Parameters.HealthConnectionTimeout\", got: %v", val.Parameters.HealthConnectionTimeout)
- } else {
- testHelper.Success(t, "Should get back \"2000\" for \"Parameters.HealthConnectionTimeout\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", name)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TM Config - Config")
-
- conf := tm.Config
- if _, ok := conf["peers.polling.interval"]; ok {
- if conf["peers.polling.interval"] != float64(1000) {
- testHelper.Error(t, "Should get back \"1000\" for map entry for \"peers.polling.interval\", got: \"%v\"", conf["peers.polling.interval"])
- } else {
- testHelper.Success(t, "Should get back \"1000\" for map entry for \"peers.polling.interval\"")
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/traffic_ops_test.go b/traffic_ops/client_tests/tests/traffic_ops_test.go
deleted file mode 100644
index a9dae06..0000000
--- a/traffic_ops/client_tests/tests/traffic_ops_test.go
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/jheitz200/test_helper"
-)
-
-func TestLogin(t *testing.T) {
- resp := client.Result{
- Alerts: []client.Alert{
- client.Alert{
- Level: "success",
- Text: "Successfully logged in.",
- },
- },
- }
-
- server := testHelper.ValidHTTPServer(resp)
-
- testHelper.Context(t, "Given the need to test a successful login to Traffic Ops")
-
- session, err := client.Login(server.URL, "test", "password", true)
- if err != nil {
- testHelper.Error(t, "Should be able to login")
- } else {
- testHelper.Success(t, "Should be able to login")
- }
-
- if session.UserName != "test" {
- testHelper.Error(t, "Should get back \"test\" for \"UserName\", got %s", session.UserName)
- } else {
- testHelper.Success(t, "Should get back \"test\" for \"UserName\"")
- }
-
- if session.Password != "password" {
- testHelper.Error(t, "Should get back \"password\" for \"Password\", got %s", session.Password)
- } else {
- testHelper.Success(t, "Should get back \"password\" for \"Password\"")
- }
-
- if session.URL != server.URL {
- testHelper.Error(t, "Should get back \"%s\" for \"URL\", got %s", server.URL, session.URL)
- } else {
- testHelper.Success(t, "Should get back \"%s\" for \"URL\"", server.URL)
- }
-}
-
-func TestLoginUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- testHelper.Context(t, "Given the need to test an unsuccessful login to Traffic Ops")
-
- _, err := client.Login(server.URL, "test", "password", true)
- if err == nil {
- testHelper.Error(t, "Should not be able to login")
- } else {
- testHelper.Success(t, "Should not be able to login")
- }
-}
diff --git a/traffic_ops/client_tests/tests/traffic_router_config_test.go b/traffic_ops/client_tests/tests/traffic_router_config_test.go
deleted file mode 100644
index 1b5f562..0000000
--- a/traffic_ops/client_tests/tests/traffic_router_config_test.go
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestTRConfig(t *testing.T) {
- resp := fixtures.TrafficRouterConfig()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config")
-
- tr, err := to.TrafficRouterConfigMap("title-vi")
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Traffic Server")
-
- ts := tr.TrafficServer
- if len(ts) != 2 {
- testHelper.Error(t, "Should get back \"2\" Traffic Servers, got: %d", len(ts))
- } else {
- testHelper.Success(t, "Should get back \"2\" Traffic Servers")
- }
-
- hashID := "tr-chi-05"
- if val, ok := ts[hashID]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", hashID)
-
- if val.IP != "10.10.10.10" {
- testHelper.Error(t, "Should get back \"10.10.10.10\" for \"IP\", got: %s", val.IP)
- } else {
- testHelper.Success(t, "Should get back \"10.10.10.10\" for \"IP\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", hashID)
- }
-
- hashID = "edge-test-01"
- if val, ok := ts[hashID]; ok {
- testHelper.Success(t, "Should get back map entry for for \"%s\"", hashID)
-
- if val.Type != "EDGE" {
- testHelper.Error(t, "Should get back \"EDGE\" for \"%s\" \"Type\", got: %s", hashID, ts[hashID].Type)
- } else {
- testHelper.Success(t, "Should get back \"EDGE\" for \"%s\" \"Type\"", hashID)
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", hashID)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Traffic Monitor")
-
- tm := tr.TrafficMonitor
- if len(tm) != 1 {
- testHelper.Error(t, "Should get back \"1\" Traffic Servers, got: %d", len(tm))
- } else {
- testHelper.Success(t, "Should get back \"1\" Traffic Servers")
- }
-
- hostname := "traffic-monitor-01"
- if val, ok := tm[hostname]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", hostname)
-
- if val.Profile != "tr-123" {
- testHelper.Error(t, "Should get back \"tr-123\" for \"Profile\", got: %s", val.Profile)
- } else {
- testHelper.Success(t, "Should get back \"tr-123\" for \"Profile\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", hostname)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Traffic Router")
-
- r := tr.TrafficRouter
- if len(r) != 1 {
- testHelper.Error(t, "Should get back \"1\" Traffic Servers, got: %d", len(r))
- } else {
- testHelper.Success(t, "Should get back \"1\" Traffic Servers")
- }
-
- fqdn := "tr-01@ga.atlanta.kabletown.net"
- if val, ok := r[fqdn]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", fqdn)
-
- if val.Location != "tr-chicago" {
- testHelper.Error(t, "Should get back \"tr-chicago\" for \"Location\", got: %s", val.Location)
- } else {
- testHelper.Success(t, "Should get back \"tr-chicago\" for \"Location\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", fqdn)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - CacheGroups")
-
- c := tr.CacheGroup
- if len(c) != 2 {
- testHelper.Error(t, "Should get back \"2\" Traffic Servers, got: %d", len(c))
- } else {
- testHelper.Success(t, "Should get back \"2\" Traffic Servers")
- }
-
- name := "philadelphia"
- if val, ok := c[name]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", name)
-
- if val.Coordinates.Latitude != 99 {
- testHelper.Error(t, "Should get back \"99\" for \"Coordinates.Latitude\", got: %v", val.Coordinates.Latitude)
- } else {
- testHelper.Success(t, "Should get back \"99\" for \"Coordinates.Latitude\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", name)
- }
-
- name = "tr-chicago"
- if val, ok := c[name]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", name)
-
- if val.Coordinates.Longitude != 9 {
- testHelper.Error(t, "Should get back \"9\" for \"Coordinates.Longitude\", got: %v", val.Coordinates.Longitude)
- } else {
- testHelper.Success(t, "Should get back \"9\" for \"Coordinates.Longitude\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", name)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Delivery Services")
-
- ds := tr.DeliveryService
- if len(ds) != 1 {
- testHelper.Error(t, "Should get back \"1\" TR Delivery Service, got: %d", len(ds))
- } else {
- testHelper.Success(t, "Should get back \"1\" TR Delivery Service")
- }
-
- xmlID := "ds-06"
- if val, ok := ds[xmlID]; ok {
- testHelper.Success(t, "Should get back map entry for \"%s\"", xmlID)
-
- if val.TTL != 3600 {
- testHelper.Error(t, "Should get back \"3600\" for \"TTL\", got: %d", val.TTL)
- } else {
- testHelper.Success(t, "Should get back \"3600\" for \"TTL\"")
- }
-
- } else {
- testHelper.Error(t, "Should get back map entry for \"%s\"", xmlID)
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Config")
-
- conf := tr.Config
- if _, ok := conf["peers.polling.interval"]; ok {
- if conf["peers.polling.interval"] != float64(1000) {
- testHelper.Error(t, "Should get back \"1000\" for map entry for \"peers.polling.interval\", got: \"%v\"", conf["peers.polling.interval"])
- } else {
- testHelper.Success(t, "Should get back \"1000\" for map entry for \"peers.polling.interval\"")
- }
- }
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for TR Config - Stats")
-
- stats := tr.Stat
- if _, ok := stats["cdnName"]; ok {
- if stats["cdnName"] != "test-cdn" {
- testHelper.Error(t, "Should get back \"test-cdn\" for map entry for \"cdnName\", got: \"%s\"", stats["cdnName"])
- } else {
- testHelper.Success(t, "Should get back \"test-cdn\" for map entry for \"cdnName\"")
- }
- }
-}
diff --git a/traffic_ops/client_tests/tests/type_test.go b/traffic_ops/client_tests/tests/type_test.go
deleted file mode 100644
index 3550cbd..0000000
--- a/traffic_ops/client_tests/tests/type_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestTypes(t *testing.T) {
- resp := fixtures.Types()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Types")
-
- types, err := to.Types()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- for _, n := range types {
- if n.ID != 1 {
- testHelper.Error(t, "Should get back 1 for \"ID\", got %d", n.ID)
- } else {
- testHelper.Success(t, "Should get back 1 for \"ID\"")
- }
-
- if n.Name != "EDGE" {
- testHelper.Error(t, "Should get back \"EDGE\" for \"Name\", got %s", n.Name)
- } else {
- testHelper.Success(t, "Should get back \"EDGE\" for \"Name\"")
- }
-
- if n.Description != "edge cache" {
- testHelper.Error(t, "Should get back \"edge cache\" for \"Description\", got %s", n.Description)
- } else {
- testHelper.Success(t, "Should get back \"edge cache\" for \"Description\"")
- }
-
- if n.UseInTable != "server" {
- testHelper.Error(t, "Should get back \"server\" for \"UseInTable\", got %s", n.UseInTable)
- } else {
- testHelper.Success(t, "Should get back \"server\" for \"UseInTable\"")
- }
- }
-}
-
-func TestTypesUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Types")
-
- _, err := to.Types()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/update_test.go b/traffic_ops/client_tests/tests/update_test.go
deleted file mode 100644
index 577fabf..0000000
--- a/traffic_ops/client_tests/tests/update_test.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestGetUpdate(t *testing.T) {
- resp := fixtures.Update()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Update")
-
- update, err := to.GetUpdate()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- if update != resp {
- testHelper.Error(t, "Should get back %v, got %v", resp, update)
- }
-}
-
-func TestSetUpdate(t *testing.T) {
- resp := fixtures.CreateDeliveryService()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request to set the update status")
-
- err := to.SetUpdate("edge-cache-0", false, true)
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-}
diff --git a/traffic_ops/client_tests/tests/user_test.go b/traffic_ops/client_tests/tests/user_test.go
deleted file mode 100644
index 00a536e..0000000
--- a/traffic_ops/client_tests/tests/user_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package test
-
-import (
- "net/http"
- "testing"
-
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client"
- "github.com/apache/incubator-trafficcontrol/traffic_ops/client/fixtures"
- "github.com/jheitz200/test_helper"
-)
-
-func TestUsers(t *testing.T) {
- resp := fixtures.Users()
- server := testHelper.ValidHTTPServer(resp)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Users")
-
- users, err := to.Users()
- if err != nil {
- testHelper.Error(t, "Should be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should be able to make a request to Traffic Ops")
- }
-
- for _, u := range users {
- if u.FullName != "Bob Smith" {
- testHelper.Error(t, "Should get back \"Bob Smith\" for \"FullName\", got %s", u.FullName)
- } else {
- testHelper.Success(t, "Should get back \"Bob Smith\" for \"FullName\"")
- }
-
- if u.PublicSSHKey != "some-ssh-key" {
- testHelper.Error(t, "Should get back \"some-ssh-key\" for \"PublicSSHKey\", got %s", u.PublicSSHKey)
- } else {
- testHelper.Success(t, "Should get back \"some-ssh-key\" for \"PublicSSHKey\"")
- }
-
- if u.Role != 3 {
- testHelper.Error(t, "Should get back \"3\" for \"Role\", got %s", u.Role)
- } else {
- testHelper.Success(t, "Should get back \"3\" for \"Role\"")
- }
-
- if u.Email != "bobsmith@email.com" {
- testHelper.Error(t, "Should get back \"bobsmith@email.com\" for \"Email\", got %s", u.Email)
- } else {
- testHelper.Success(t, "Should get back \"bobsmith@email.com\" for \"Email\"")
- }
-
- if u.Username != "bsmith" {
- testHelper.Error(t, "Should get back \"bsmith\" for \"Username\", got %s", u.Username)
- } else {
- testHelper.Success(t, "Should get back \"bsmith\" for \"Username\"")
- }
- }
-}
-
-func TestUsersUnauthorized(t *testing.T) {
- server := testHelper.InvalidHTTPServer(http.StatusUnauthorized)
- defer server.Close()
-
- to := client.NewSession("", "", server.URL, "", &http.Client{}, false)
-
- testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Users")
-
- _, err := to.Users()
- if err == nil {
- testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
- } else {
- testHelper.Success(t, "Should not be able to make a request to Traffic Ops")
- }
-}
--
To stop receiving notification emails like this one, please contact
dangogh@apache.org.