diff --git a/routes/v1/runtime_incident_policy/routes.go b/routes/v1/runtime_incident_policy/routes.go index ed56e03..d27cd34 100644 --- a/routes/v1/runtime_incident_policy/routes.go +++ b/routes/v1/runtime_incident_policy/routes.go @@ -30,8 +30,7 @@ func AddRoutes(g *gin.Engine) { WithValidatePostUniqueName(false). WithValidatePutGUID(true). WithValidatePostMandatoryName(true). - WithV2ListSearch(true). - WithValidatePutUniqueName(true) + WithV2ListSearch(true) handlers.AddRoutes(g, routerOptionsBuilder.Get()...) } diff --git a/service_test.go b/service_test.go index c817079..4a1394f 100644 --- a/service_test.go +++ b/service_test.go @@ -36,6 +36,9 @@ var runtimeIncidentPolicyReq1 []byte //go:embed test_data/runtimeIncidentPolicyReq2.json var runtimeIncidentPolicyReq2 []byte +//go:embed test_data/runtimeIncidentPolicyReq3.json +var runtimeIncidentPolicyReq3 []byte + var newClusterCompareFilter = cmp.FilterPath(func(p cmp.Path) bool { switch p.String() { case "PortalBase.GUID", "SubscriptionDate", "LastLoginDate", "PortalBase.UpdatedTime", "ExpirationDate": @@ -2131,6 +2134,13 @@ func (suite *MainTestSuite) TestRuntimeIncidentPolicies() { suite.NotNil(doc.GUID) suite.Equal("Anomaly", doc.Name[:7]) } + // test sort by scope + w = suite.doRequest(http.MethodPost, consts.RuntimeIncidentPolicyPath+"/query", runtimeIncidentPolicyReq3) + suite.Equal(http.StatusOK, w.Code) + _, err = decodeResponse[armotypes.V2ListResponseGeneric[[]*kdr.IncidentPolicy]](w) + if err != nil { + suite.FailNow(err.Error()) + } } func (suite *MainTestSuite) TestIntegrationReference() { diff --git a/test_data/runtimeIncidentPolicyReq3.json b/test_data/runtimeIncidentPolicyReq3.json new file mode 100644 index 0000000..cfdf521 --- /dev/null +++ b/test_data/runtimeIncidentPolicyReq3.json @@ -0,0 +1,33 @@ +{ + "pageSize": 100, + "pageNum": 0, + "orderBy": "scope.designators.cluster:asc,scope.designators.namespace:asc,scope.designators.kind:asc,scope.designators.name:asc", + "innerFilters": [ + { + "enabled": "true", + "managedRuleSetIDs": "c9fe6345-c393-4595-bd7b-22110dbafe61", + "ruleSetType": "Managed", + "scope.designators.cluster": "gke_elated-pottery-310110_us-central1-c_bez-longrun-3,|missing", + "scope.designators.kind": "Deployment,|missing", + "scope.designators.labels": ",|missing", + "scope.designators.name": "redis-sleep,|missing", + "scope.designators.namespace": "systest-ns-o9zz,|missing", + "scope.riskFactors": "risk1,|missing" + }, + { + "enabled": "true", + "incidentTypeIDs": "I013,|missing", + "ruleSetType": "Custom", + "scope.designators.cluster": "gke_elated-pottery-310110_us-central1-c_bez-longrun-3,|missing", + "scope.designators.kind": "Deployment,|missing", + "scope.designators.labels": ",|missing", + "scope.designators.name": "redis-sleep,|missing", + "scope.designators.namespace": "systest-ns-o9zz,|missing", + "scope.riskFactors": "|missing" + } + ], + "includeFields": [ + "guid", + "name" + ] +} \ No newline at end of file