Skip to content

Commit

Permalink
Replace "/spi/v1/operations" with "/spi/v1/namespaces/{ns}/operations"
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
  • Loading branch information
awrichar committed Jun 14, 2022
1 parent 6091326 commit f96daef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/apiserver/route_spi_get_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

var spiGetOps = &ffapi.Route{
Name: "spiGetOps",
Path: "operations",
Path: "namespaces/{ns}/operations",
Method: http.MethodGet,
QueryParams: nil,
Description: coremsgs.APIEndpointsAdminGetOps,
Expand All @@ -37,8 +37,8 @@ var spiGetOps = &ffapi.Route{
Extensions: &coreExtensions{
FilterFactory: database.OperationQueryFactory,
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
// TODO: cr.or will be nil (this must be converted to a namespaced query)
return filterResult(cr.or.GetOperations(cr.ctx, cr.filter))
or := cr.mgr.Orchestrator(r.PP["ns"])
return filterResult(or.GetOperations(cr.ctx, cr.filter))
},
},
}
12 changes: 7 additions & 5 deletions internal/apiserver/route_spi_get_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/pkg/core"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)

func TestSPIGetOperations(t *testing.T) {
_, r := newTestSPIServer()
req := httptest.NewRequest("GET", "/spi/v1/operations", nil)
or, r := newTestSPIServer()
req := httptest.NewRequest("GET", "/spi/v1/namespaces/ns1/operations", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

assert.Panics(t, func() {
r.ServeHTTP(res, req)
})
or.On("GetOperations", mock.Anything, mock.Anything).
Return([]*core.Operation{}, nil, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 200, res.Result().StatusCode)
}

0 comments on commit f96daef

Please sign in to comment.