fix(edge): fix status inspect error message EE-5190 (#8661)

pull/8498/head^2
andres-portainer 2023-03-14 13:28:20 -03:00 committed by GitHub
parent 40c387f4f4
commit 347f66b1f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -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)

View File

@ -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{