This is an automated email from the ASF dual-hosted git repository.
shamrick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 2cf3335ec7 Fixed phys_locations update API to remove error related to
mismatching region name and ID (#7762)
2cf3335ec7 is described below
commit 2cf3335ec7b6b69d1801db9786841ff030451384
Author: Srijeet Chatterjee <[email protected]>
AuthorDate: Wed Aug 30 12:23:34 2023 -0600
Fixed phys_locations update API to remove error related to mismatching
region name and ID (#7762)
---
CHANGELOG.md | 3 ++-
traffic_ops/testing/api/v5/phys_locations_test.go | 17 +++++++++++++++++
.../traffic_ops_golang/physlocation/phys_locations.go | 16 ----------------
3 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d91df04da0..573550766c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -102,7 +102,8 @@ The format is based on [Keep a
Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7691](https://github.com/apache/trafficcontrol/pull/7691) *Traffic
Ops* Fixed `/topologies` v5 APIs to respond with `RFC3339` timestamps.
- [#7413](https://github.com/apache/trafficcontrol/issues/7413) *Traffic
Ops* Fixed `/service_category` v5 APIs to respond with `RFC3339` timestamps.
- [#7413](https://github.com/apache/trafficcontrol/issues/7706) *Traffic
Ops* Fixed `/statuses` v5 APIs to respond with `RFC3339` timestamps.
- - [#7743](https://github.com/apache/trafficcontrol/issues/7743) *Traffic
Ops* Fixed `/server_server_capabilities` v5 APIs to respond with `RFC3339`
timestamps.
+- [#7762](https://github.com/apache/trafficcontrol/pull/7762) *Traffic Ops*
Fixed `/phys_locations` update API to remove error related to mismatching
region name and ID.
+- [#7743](https://github.com/apache/trafficcontrol/issues/7743) *Traffic Ops*
Fixed `/server_server_capabilities` v5 APIs to respond with `RFC3339`
timestamps.
- [#7730](https://github.com/apache/trafficcontrol/pull/7730) *Traffic
Monitor* Fixed the panic seen in TM when `plugin.system_stats.timestamp_ms`
appears as float and not string.
- [#4393](https://github.com/apache/trafficcontrol/issues/4393) *Traffic Ops*
Fixed the error code and alert structure when TO is queried for a delivery
service with no ssl keys.
- [#7623](https://github.com/apache/trafficcontrol/pull/7623) *Traffic Ops*
Removed TryIfModifiedSinceQuery from servicecategories.go and reused from ims.go
diff --git a/traffic_ops/testing/api/v5/phys_locations_test.go
b/traffic_ops/testing/api/v5/phys_locations_test.go
index ae6f3b03a8..a684d8be5f 100644
--- a/traffic_ops/testing/api/v5/phys_locations_test.go
+++ b/traffic_ops/testing/api/v5/phys_locations_test.go
@@ -148,6 +148,23 @@ func TestPhysLocations(t *testing.T) {
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
validatePhysicalLocationUpdateCreateFields("HotAtlanta",
map[string]interface{}{"City": "NewCity"})),
},
+ "OK when REGION ID doesn't match REGION NAME": {
+ EndpointID: GetPhysicalLocationID(t,
"HotAtlanta"),
+ ClientSession: TOSession,
+ RequestBody: tc.PhysLocationV5{
+ Address: "1234 southern way",
+ City: "NewCity",
+ Name: "HotAtlanta",
+ Phone: "404-222-2222",
+ RegionID: GetRegionID(t,
"region1")(),
+ RegionName: "notRegion1",
+ ShortName: "atlanta",
+ State: "GA",
+ Zip: "30301",
+ },
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
+
validatePhysicalLocationUpdateCreateFields("HotAtlanta",
map[string]interface{}{"City": "NewCity"})),
+ },
"PRECONDITION FAILED when updating with IMS &
IUS Headers": {
EndpointID: GetPhysicalLocationID(t,
"HotAtlanta"),
ClientSession: TOSession,
diff --git a/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
b/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
index d872a50e8b..7de94d9a94 100644
--- a/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
+++ b/traffic_ops/traffic_ops_golang/physlocation/phys_locations.go
@@ -391,22 +391,6 @@ func UpdatePhysLocation(w http.ResponseWriter, r
*http.Request) {
return
}
- // checks to see if the supplied region name and ID in the
phys_location body correspond to each other.
- if physLocation.RegionName != "" {
- regionName, ok, err := dbhelpers.GetRegionNameFromID(tx,
physLocation.RegionID)
- if err != nil {
- api.HandleErr(w, r, tx, http.StatusInternalServerError,
fmt.Errorf("error fetching name from region ID: %w", err), nil)
- return
- } else if !ok {
- api.HandleErr(w, r, tx, http.StatusNotFound,
errors.New("no such region"), nil)
- return
- }
- if regionName != physLocation.RegionName {
- api.HandleErr(w, r, tx, http.StatusBadRequest,
errors.New("region name and ID do not match"), nil)
- return
- }
- }
-
requestedID := inf.Params["id"]
intRequestId, convErr := strconv.Atoi(requestedID)