From 347f66b1f1e851f64fea70f87e2b1fc61edc78d0 Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:28:20 -0300 Subject: [PATCH] fix(edge): fix status inspect error message EE-5190 (#8661) --- .../endpointedge/endpoint_edgestatus_inspect.go | 10 ++++------ .../endpointedge/endpointedge_status_inspect_test.go | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) 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{