diff --git a/internal/core/command/controller/http/command.go b/internal/core/command/controller/http/command.go index 2a5ba4a470..68ba95cbe4 100644 --- a/internal/core/command/controller/http/command.go +++ b/internal/core/command/controller/http/command.go @@ -79,13 +79,13 @@ func (cc *CommandController) CommandsByDeviceName(w http.ResponseWriter, r *http } func validateGetCommandParameters(r *http.Request) (err errors.EdgeX) { - dsReturnEvent := utils.ParseQueryStringToString(r, common.ReturnEvent, common.ValueYes) - dsPushEvent := utils.ParseQueryStringToString(r, common.PushEvent, common.ValueNo) - if dsReturnEvent != common.ValueYes && dsReturnEvent != common.ValueNo { - return errors.NewCommonEdgeX(errors.KindContractInvalid, fmt.Sprintf("invalid query parameter, %s has to be %s or %s", dsReturnEvent, common.ValueYes, common.ValueNo), nil) + dsReturnEvent := utils.ParseQueryStringToString(r, common.ReturnEvent, common.ValueTrue) + dsPushEvent := utils.ParseQueryStringToString(r, common.PushEvent, common.ValueFalse) + if dsReturnEvent != common.ValueTrue && dsReturnEvent != common.ValueFalse { + return errors.NewCommonEdgeX(errors.KindContractInvalid, fmt.Sprintf("invalid query parameter, %s has to be %s or %s", dsReturnEvent, common.ValueTrue, common.ValueFalse), nil) } - if dsPushEvent != common.ValueYes && dsPushEvent != common.ValueNo { - return errors.NewCommonEdgeX(errors.KindContractInvalid, fmt.Sprintf("invalid query parameter, %s has to be %s or %s", dsPushEvent, common.ValueYes, common.ValueNo), nil) + if dsPushEvent != common.ValueTrue && dsPushEvent != common.ValueFalse { + return errors.NewCommonEdgeX(errors.KindContractInvalid, fmt.Sprintf("invalid query parameter, %s has to be %s or %s", dsPushEvent, common.ValueTrue, common.ValueFalse), nil) } return nil } diff --git a/internal/core/command/controller/http/command_test.go b/internal/core/command/controller/http/command_test.go index 4ae93ff64c..b2411d4048 100644 --- a/internal/core/command/controller/http/command_test.go +++ b/internal/core/command/controller/http/command_test.go @@ -46,7 +46,7 @@ const ( testDeviceServiceName = "testDeviceService" testCommandName = "testCommand" testBaseAddress = "http://localhost:49990" - testQueryStrings = "a=1&b=2&ds-pushevent=no" + testQueryStrings = "a=1&b=2&ds-pushevent=false" ) // NewMockDIC function returns a mock bootstrap di Container diff --git a/internal/core/command/controller/messaging/external_test.go b/internal/core/command/controller/messaging/external_test.go index db2cac55da..e1cc48eb57 100644 --- a/internal/core/command/controller/messaging/external_test.go +++ b/internal/core/command/controller/messaging/external_test.go @@ -392,8 +392,8 @@ func testCommandQueryPayload() types.MessageEnvelope { func testCommandRequestPayload() types.MessageEnvelope { payload := types.NewMessageEnvelopeForRequest(nil, map[string]string{ - "ds-pushevent": "yes", - "ds-returnevent": "yes", + "ds-pushevent": common.ValueTrue, + "ds-returnevent": common.ValueTrue, }) return payload diff --git a/internal/core/command/controller/messaging/utils.go b/internal/core/command/controller/messaging/utils.go index 42717ad888..03fa82da96 100644 --- a/internal/core/command/controller/messaging/utils.go +++ b/internal/core/command/controller/messaging/utils.go @@ -54,13 +54,13 @@ func validateRequestTopic(prefix string, deviceName string, commandName string, // validateGetCommandQueryParameters validates the value is valid for device service's reserved query parameters func validateGetCommandQueryParameters(queryParams map[string]string) error { if dsReturnEvent, ok := queryParams[common.ReturnEvent]; ok { - if dsReturnEvent != common.ValueYes && dsReturnEvent != common.ValueNo { - return fmt.Errorf("invalid query parameter, %s has to be '%s' or '%s'", common.ReturnEvent, common.ValueYes, common.ValueNo) + if dsReturnEvent != common.ValueTrue && dsReturnEvent != common.ValueFalse { + return fmt.Errorf("invalid query parameter, %s has to be '%s' or '%s'", common.ReturnEvent, common.ValueTrue, common.ValueFalse) } } if dsPushEvent, ok := queryParams[common.PushEvent]; ok { - if dsPushEvent != common.ValueYes && dsPushEvent != common.ValueNo { - return fmt.Errorf("invalid query parameter, %s has to be '%s' or '%s'", common.PushEvent, common.ValueYes, common.ValueNo) + if dsPushEvent != common.ValueTrue && dsPushEvent != common.ValueFalse { + return fmt.Errorf("invalid query parameter, %s has to be '%s' or '%s'", common.PushEvent, common.ValueTrue, common.ValueFalse) } }