diff --git a/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go b/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go index c96437604..23d747365 100644 --- a/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go +++ b/api/http/handler/endpointedge/endpoint_edgestatus_inspect.go @@ -81,16 +81,14 @@ func (handler *Handler) endpointEdgeStatusInspect(w http.ResponseWriter, r *http } if _, ok := handler.DataStore.Endpoint().Heartbeat(portainer.EndpointID(endpointID)); !ok { - return httperror.NotFound("Unable to find an environment with the specified identifier inside the database", nil) + // EE-5910 + return httperror.Forbidden("Permission denied to access environment", errors.New("the device has not been trusted yet")) } endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID)) if err != nil { - if handler.DataStore.IsErrObjectNotFound(err) { - return httperror.NotFound("Unable to find an environment with the specified identifier inside the database", err) - } - - return httperror.InternalServerError("Unable to find an environment with the specified identifier inside the database", err) + // EE-5910 + return httperror.Forbidden("Permission denied to access environment", errors.New("the device has not been trusted yet")) } err = handler.requestBouncer.AuthorizedEdgeEndpointOperation(r, endpoint) diff --git a/api/http/handler/endpointedge/endpointedge_status_inspect_test.go b/api/http/handler/endpointedge/endpointedge_status_inspect_test.go index 442f86807..91c32a0f6 100644 --- a/api/http/handler/endpointedge/endpointedge_status_inspect_test.go +++ b/api/http/handler/endpointedge/endpointedge_status_inspect_test.go @@ -30,7 +30,7 @@ var endpointTestCases = []endpointTestCase{ { portainer.Endpoint{}, portainer.EndpointRelation{}, - http.StatusNotFound, + http.StatusForbidden, }, { portainer.Endpoint{ @@ -43,7 +43,7 @@ var endpointTestCases = []endpointTestCase{ portainer.EndpointRelation{ EndpointID: -1, }, - http.StatusNotFound, + http.StatusForbidden, }, { portainer.Endpoint{