Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions doc-site/docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ paths:
name: publish
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -1800,6 +1809,15 @@ paths:
name: confirm
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -2411,6 +2429,15 @@ paths:
schema:
example: "true"
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -3828,6 +3855,15 @@ paths:
name: publish
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -4856,6 +4892,15 @@ paths:
name: confirm
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -13721,6 +13766,15 @@ paths:
name: publish
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -15610,6 +15664,15 @@ paths:
name: confirm
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -16501,6 +16564,15 @@ paths:
schema:
example: "true"
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -17981,6 +18053,15 @@ paths:
name: publish
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down Expand Up @@ -19037,6 +19118,15 @@ paths:
name: confirm
schema:
type: string
- description: Custom topics to use for ordering of the definition broadcast
message, instead of the default system topic. Each topic must be a non-empty
string. Only used when the definition is published to the multiparty network
in: query
name: topics
schema:
items:
type: string
type: array
- description: Server-side request timeout (milliseconds, or set a custom suffix
like 10s)
in: header
Expand Down
3 changes: 2 additions & 1 deletion internal/apiserver/route_post_contract_api_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var postContractAPIPublish = &ffapi.Route{
},
QueryParams: []*ffapi.QueryParam{
{Name: "confirm", Description: coremsgs.APIConfirmMsgQueryParam, IsBool: true},
{Name: "topics", Description: coremsgs.APICustomTopicsParam, IsArray: true},
},
Description: coremsgs.APIEndpointsPostContractAPIPublish,
JSONInputValue: func() interface{} { return &core.DefinitionPublish{} },
Expand All @@ -45,7 +46,7 @@ var postContractAPIPublish = &ffapi.Route{
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
input := r.Input.(*core.DefinitionPublish)
return cr.or.DefinitionSender().PublishContractAPI(cr.ctx, cr.apiBaseURL, r.PP["apiName"], input.NetworkName, waitConfirm)
return cr.or.DefinitionSender().PublishContractAPI(cr.ctx, cr.apiBaseURL, r.PP["apiName"], input.NetworkName, waitConfirm, r.QAP["topics"])
},
},
}
21 changes: 20 additions & 1 deletion internal/apiserver/route_post_contract_api_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,26 @@ func TestPostContractAPIPublish(t *testing.T) {
res := httptest.NewRecorder()
api := &core.ContractAPI{}

mds.On("PublishContractAPI", mock.Anything, "http://127.0.0.1:5000/api/v1/namespaces/ns1", "banana", "banana-net", false).Return(api, nil)
mds.On("PublishContractAPI", mock.Anything, "http://127.0.0.1:5000/api/v1/namespaces/ns1", "banana", "banana-net", false, mock.Anything).Return(api, nil)
r.ServeHTTP(res, req)

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

func TestPostContractAPIPublishWithTopics(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("DefinitionSender").Return(mds)
input := core.DefinitionPublish{NetworkName: "banana-net"}
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(&input)
req := httptest.NewRequest("POST", "/api/v1/namespaces/ns1/apis/banana/publish?topics=my-topic", &buf)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()
api := &core.ContractAPI{}

mds.On("PublishContractAPI", mock.Anything, "http://127.0.0.1:5000/api/v1/namespaces/ns1", "banana", "banana-net", false, []string{"my-topic"}).Return(api, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 202, res.Result().StatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var postContractInterfacePublish = &ffapi.Route{
},
QueryParams: []*ffapi.QueryParam{
{Name: "confirm", Description: coremsgs.APIConfirmMsgQueryParam, IsBool: true},
{Name: "topics", Description: coremsgs.APICustomTopicsParam, IsArray: true},
},
Description: coremsgs.APIEndpointsPostContractInterfacePublish,
JSONInputValue: func() interface{} { return &core.DefinitionPublish{} },
Expand All @@ -46,7 +47,7 @@ var postContractInterfacePublish = &ffapi.Route{
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
input := r.Input.(*core.DefinitionPublish)
return cr.or.DefinitionSender().PublishFFI(cr.ctx, r.PP["name"], r.PP["version"], input.NetworkName, waitConfirm)
return cr.or.DefinitionSender().PublishFFI(cr.ctx, r.PP["name"], r.PP["version"], input.NetworkName, waitConfirm, r.QAP["topics"])
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ func TestPostContractInterfacePublish(t *testing.T) {
res := httptest.NewRecorder()
ffi := &fftypes.FFI{}

mds.On("PublishFFI", mock.Anything, "ffi1", "1.0", "", false).Return(ffi, nil)
mds.On("PublishFFI", mock.Anything, "ffi1", "1.0", "", false, mock.Anything).Return(ffi, nil)
r.ServeHTTP(res, req)

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

func TestPostContractInterfacePublishWithTopics(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("DefinitionSender").Return(mds)
input := core.TokenPool{}
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(&input)
req := httptest.NewRequest("POST", "/api/v1/namespaces/ns1/contracts/interfaces/ffi1/1.0/publish?topics=my-topic", &buf)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()
ffi := &fftypes.FFI{}

mds.On("PublishFFI", mock.Anything, "ffi1", "1.0", "", false, []string{"my-topic"}).Return(ffi, nil)
r.ServeHTTP(res, req)

assert.Equal(t, 202, res.Result().StatusCode)
Expand Down
3 changes: 2 additions & 1 deletion internal/apiserver/route_post_new_contract_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var postNewContractAPI = &ffapi.Route{
QueryParams: []*ffapi.QueryParam{
{Name: "confirm", Description: coremsgs.APIConfirmMsgQueryParam, IsBool: true, Example: "true"},
{Name: "publish", Description: coremsgs.APIPublishQueryParam, IsBool: true},
{Name: "topics", Description: coremsgs.APICustomTopicsParam, IsArray: true},
},
Description: coremsgs.APIEndpointsPostNewContractAPI,
JSONInputValue: func() interface{} { return &core.ContractAPI{} },
Expand All @@ -49,7 +50,7 @@ var postNewContractAPI = &ffapi.Route{
api := r.Input.(*core.ContractAPI)
api.ID = nil
api.Published = strings.EqualFold(r.QP["publish"], "true")
err = cr.or.DefinitionSender().DefineContractAPI(cr.ctx, cr.apiBaseURL, api, waitConfirm)
err = cr.or.DefinitionSender().DefineContractAPI(cr.ctx, cr.apiBaseURL, api, waitConfirm, r.QAP["topics"])
return api, err
},
},
Expand Down
23 changes: 21 additions & 2 deletions internal/apiserver/route_post_new_contract_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestPostNewContractAPI(t *testing.T) {
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mds.On("DefineContractAPI", mock.Anything, mock.Anything, mock.AnythingOfType("*core.ContractAPI"), false).Return(nil)
mds.On("DefineContractAPI", mock.Anything, mock.Anything, mock.AnythingOfType("*core.ContractAPI"), false, mock.Anything).Return(nil)
r.ServeHTTP(res, req)

assert.Equal(t, 202, res.Result().StatusCode)
Expand All @@ -61,8 +61,27 @@ func TestPostNewContractAPISync(t *testing.T) {
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mds.On("DefineContractAPI", mock.Anything, mock.Anything, mock.AnythingOfType("*core.ContractAPI"), true).Return(nil)
mds.On("DefineContractAPI", mock.Anything, mock.Anything, mock.AnythingOfType("*core.ContractAPI"), true, mock.Anything).Return(nil)
r.ServeHTTP(res, req)

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

func TestPostNewContractAPIWithTopics(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("Contracts").Return(&contractmocks.Manager{})
o.On("DefinitionSender").Return(mds)
input := core.Datatype{}
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(&input)
req := httptest.NewRequest("POST", "/api/v1/namespaces/ns1/apis?topics=my-topic", &buf)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mds.On("DefineContractAPI", mock.Anything, mock.Anything, mock.AnythingOfType("*core.ContractAPI"), false, []string{"my-topic"}).Return(nil)
r.ServeHTTP(res, req)

assert.Equal(t, 202, res.Result().StatusCode)
}
3 changes: 2 additions & 1 deletion internal/apiserver/route_post_new_contract_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var postNewContractInterface = &ffapi.Route{
QueryParams: []*ffapi.QueryParam{
{Name: "confirm", Description: coremsgs.APIConfirmMsgQueryParam, IsBool: true, Example: "true"},
{Name: "publish", Description: coremsgs.APIPublishQueryParam, IsBool: true},
{Name: "topics", Description: coremsgs.APICustomTopicsParam, IsArray: true},
},
Description: coremsgs.APIEndpointsPostNewContractInterface,
JSONInputValue: func() interface{} { return &fftypes.FFI{} },
Expand All @@ -48,7 +49,7 @@ var postNewContractInterface = &ffapi.Route{
r.SuccessStatus = syncRetcode(waitConfirm)
ffi := r.Input.(*fftypes.FFI)
ffi.Published = strings.EqualFold(r.QP["publish"], "true")
err = cr.or.DefinitionSender().DefineFFI(cr.ctx, ffi, waitConfirm)
err = cr.or.DefinitionSender().DefineFFI(cr.ctx, ffi, waitConfirm, r.QAP["topics"])
return ffi, err
},
},
Expand Down
23 changes: 21 additions & 2 deletions internal/apiserver/route_post_new_contract_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestPostNewContractInterface(t *testing.T) {
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mds.On("DefineFFI", mock.Anything, mock.AnythingOfType("*fftypes.FFI"), false).Return(nil)
mds.On("DefineFFI", mock.Anything, mock.AnythingOfType("*fftypes.FFI"), false, mock.Anything).Return(nil)
r.ServeHTTP(res, req)

assert.Equal(t, 202, res.Result().StatusCode)
Expand All @@ -61,8 +61,27 @@ func TestPostNewContractInterfaceSync(t *testing.T) {
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mds.On("DefineFFI", mock.Anything, mock.AnythingOfType("*fftypes.FFI"), true).Return(nil)
mds.On("DefineFFI", mock.Anything, mock.AnythingOfType("*fftypes.FFI"), true, mock.Anything).Return(nil)
r.ServeHTTP(res, req)

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

func TestPostNewContractInterfaceWithTopics(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("Contracts").Return(&contractmocks.Manager{})
o.On("DefinitionSender").Return(mds)
input := core.Datatype{}
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(&input)
req := httptest.NewRequest("POST", "/api/v1/namespaces/ns1/contracts/interfaces?topics=my-topic", &buf)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

mds.On("DefineFFI", mock.Anything, mock.AnythingOfType("*fftypes.FFI"), false, []string{"my-topic"}).Return(nil)
r.ServeHTTP(res, req)

assert.Equal(t, 202, res.Result().StatusCode)
}
3 changes: 2 additions & 1 deletion internal/apiserver/route_put_contract_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var putContractAPI = &ffapi.Route{
},
QueryParams: []*ffapi.QueryParam{
{Name: "confirm", Description: coremsgs.APIConfirmMsgQueryParam, IsBool: true, Example: "true"},
{Name: "topics", Description: coremsgs.APICustomTopicsParam, IsArray: true},
},
Description: coremsgs.APIParamsContractAPIID,
JSONInputValue: func() interface{} { return &core.ContractAPI{} },
Expand All @@ -51,7 +52,7 @@ var putContractAPI = &ffapi.Route{
api := r.Input.(*core.ContractAPI)
api.ID, err = fftypes.ParseUUID(cr.ctx, r.PP["id"])
if err == nil {
err = cr.or.DefinitionSender().DefineContractAPI(cr.ctx, cr.apiBaseURL, api, waitConfirm)
err = cr.or.DefinitionSender().DefineContractAPI(cr.ctx, cr.apiBaseURL, api, waitConfirm, r.QAP["topics"])
}
return api, err
},
Expand Down
Loading