From 0af827943190f104d0e548d863c394679f7c1089 Mon Sep 17 00:00:00 2001 From: lpooja <97023286+lpooja@users.noreply.github.com> Date: Wed, 10 Aug 2022 18:51:10 +0530 Subject: [PATCH 1/4] added method not allowed --- svc-api/handle/handlers.go | 6 ++++++ svc-api/router/router.go | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/svc-api/handle/handlers.go b/svc-api/handle/handlers.go index 34a7b2932..b8456e8a9 100755 --- a/svc-api/handle/handlers.go +++ b/svc-api/handle/handlers.go @@ -1241,6 +1241,12 @@ func UpdateServiceMethodNotAllowed(ctx iris.Context) { fillMethodNotAllowedErrorResponse(ctx) return } +func MethodNotAllowed(ctx iris.Context) { + defer ctx.Next() + ctx.ResponseWriter().Header().Set("Allow", "GET") + fillMethodNotAllowedErrorResponse(ctx) + return +} // ChassisMethodNotAllowed holds builds reponse for the unallowed http operation on Chassis URLs and returns 405 error. func ChassisMethodNotAllowed(ctx iris.Context) { diff --git a/svc-api/router/router.go b/svc-api/router/router.go index 0d662dbc5..868239936 100755 --- a/svc-api/router/router.go +++ b/svc-api/router/router.go @@ -195,7 +195,7 @@ func Router() *iris.Application { serviceRoot := handle.InitServiceRoot() router := iris.New() - + router.OnErrorCode(iris.StatusNotFound, handle.SystemsMethodInvalidURI) var reqBody map[string]interface{} // Parses the URL and performs URL decoding for path // Getting the request body copy @@ -680,6 +680,21 @@ func Router() *iris.Application { telemetryService.Get("/MetricReports/{id}", telemetry.GetMetricReport) telemetryService.Get("/Triggers/{id}", telemetry.GetTrigger) telemetryService.Patch("/Triggers/{id}", telemetry.UpdateTrigger) + telemetryService.Any("/MetricDefinitions", handle.MethodNotAllowed) + telemetryService.Any("/MetricReportDefinitions", handle.MethodNotAllowed) + telemetryService.Any("/MetricReports", handle.MethodNotAllowed) + telemetryService.Any("/Triggers", handle.MethodNotAllowed) + telemetryService.Any("/MetricDefinitions/{id}", handle.MethodNotAllowed) + telemetryService.Any("/MetricReportDefinitions/{id}",handle.MethodNotAllowed) + telemetryService.Any("/MetricReports/{id}", handle.MethodNotAllowed) + telemetryService.Any("/Triggers/{id}", handle.MethodNotAllowed) + + + + + + + licenseService := v1.Party("/LicenseService", middleware.SessionDelMiddleware) licenseService.SetRegisterRule(iris.RouteSkip) @@ -716,3 +731,4 @@ func Router() *iris.Application { compositionService.Any("/ActivePool", handle.CompositionServiceMethodNotAllowed) return router } +jerr := \ No newline at end of file From eced61c4cfa2446f7269f615f927e699ef10923f Mon Sep 17 00:00:00 2001 From: lpooja <97023286+lpooja@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:00:16 +0530 Subject: [PATCH 2/4] removed logs --- svc-aggregation/system/common_test.go | 60 +++++++++++++++++++++++++++ svc-api/router/router.go | 10 +---- 2 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 svc-aggregation/system/common_test.go diff --git a/svc-aggregation/system/common_test.go b/svc-aggregation/system/common_test.go new file mode 100644 index 000000000..db912481b --- /dev/null +++ b/svc-aggregation/system/common_test.go @@ -0,0 +1,60 @@ +//(C) Copyright [2020] Hewlett Packard Enterprise Development LP + +// + +//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 system + +import ( + "reflect" + "testing" +) + +func Test_createServerSearchIndex(t *testing.T) { + res map[string]interface{} + type args struct { + computeSystem map[string]interface{} + oidKey string + deviceUUID string + } + tests := []struct { + name string + args args + want map[string]interface{} + }{ + { + name:"test1", + args:args{ + }, + want:map[string]interface{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := createServerSearchIndex(tt.args.computeSystem, tt.args.oidKey, tt.args.deviceUUID); !reflect.DeepEqual(got, tt.want) { + t.Errorf("createServerSearchIndex() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/svc-api/router/router.go b/svc-api/router/router.go index 868239936..f529e7156 100755 --- a/svc-api/router/router.go +++ b/svc-api/router/router.go @@ -685,17 +685,10 @@ func Router() *iris.Application { telemetryService.Any("/MetricReports", handle.MethodNotAllowed) telemetryService.Any("/Triggers", handle.MethodNotAllowed) telemetryService.Any("/MetricDefinitions/{id}", handle.MethodNotAllowed) - telemetryService.Any("/MetricReportDefinitions/{id}",handle.MethodNotAllowed) + telemetryService.Any("/MetricReportDefinitions/{id}", handle.MethodNotAllowed) telemetryService.Any("/MetricReports/{id}", handle.MethodNotAllowed) telemetryService.Any("/Triggers/{id}", handle.MethodNotAllowed) - - - - - - - licenseService := v1.Party("/LicenseService", middleware.SessionDelMiddleware) licenseService.SetRegisterRule(iris.RouteSkip) licenseService.Get("/", licenses.GetLicenseService) @@ -731,4 +724,3 @@ func Router() *iris.Application { compositionService.Any("/ActivePool", handle.CompositionServiceMethodNotAllowed) return router } -jerr := \ No newline at end of file From 48450306be38d204d0de55c88fa23b21320e636f Mon Sep 17 00:00:00 2001 From: lpooja <97023286+lpooja@users.noreply.github.com> Date: Tue, 16 Aug 2022 13:08:06 +0530 Subject: [PATCH 3/4] remove delted file --- svc-aggregation/system/common_test.go | 60 --------------------------- 1 file changed, 60 deletions(-) delete mode 100644 svc-aggregation/system/common_test.go diff --git a/svc-aggregation/system/common_test.go b/svc-aggregation/system/common_test.go deleted file mode 100644 index db912481b..000000000 --- a/svc-aggregation/system/common_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//(C) Copyright [2020] Hewlett Packard Enterprise Development LP - -// - -//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 system - -import ( - "reflect" - "testing" -) - -func Test_createServerSearchIndex(t *testing.T) { - res map[string]interface{} - type args struct { - computeSystem map[string]interface{} - oidKey string - deviceUUID string - } - tests := []struct { - name string - args args - want map[string]interface{} - }{ - { - name:"test1", - args:args{ - }, - want:map[string]interface{}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := createServerSearchIndex(tt.args.computeSystem, tt.args.oidKey, tt.args.deviceUUID); !reflect.DeepEqual(got, tt.want) { - t.Errorf("createServerSearchIndex() = %v, want %v", got, tt.want) - } - }) - } -} From c6ed1e4a4514aa3bfb9c88a6933aabb11383eb23 Mon Sep 17 00:00:00 2001 From: lpooja Date: Thu, 18 Aug 2022 02:53:06 -0600 Subject: [PATCH 4/4] added logs --- svc-api/router/router.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/svc-api/router/router.go b/svc-api/router/router.go index 868239936..107bb1593 100755 --- a/svc-api/router/router.go +++ b/svc-api/router/router.go @@ -730,5 +730,4 @@ func Router() *iris.Application { compositionService.Any("/FreePool", handle.CompositionServiceMethodNotAllowed) compositionService.Any("/ActivePool", handle.CompositionServiceMethodNotAllowed) return router -} -jerr := \ No newline at end of file +} \ No newline at end of file