Skip to content

Commit

Permalink
Merge pull request #1405 from arinddas/fix-nonmultiparty-organization
Browse files Browse the repository at this point in the history
check enabled for organization creation in non-multiparty system
  • Loading branch information
nguyer authored Sep 22, 2023
2 parents 6cc1c67 + a17a296 commit a64ee78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/apiserver/route_post_new_organization.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -22,6 +22,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -38,6 +39,9 @@ var postNewOrganization = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.Identity{} },
JSONOutputCodes: []int{http.StatusAccepted, http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.MultiParty() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
Expand Down
4 changes: 3 additions & 1 deletion internal/apiserver/route_post_new_organization_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -22,6 +22,7 @@ import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/mocks/multipartymocks"
"github.com/hyperledger/firefly/mocks/networkmapmocks"
"github.com/hyperledger/firefly/pkg/core"
"github.com/stretchr/testify/assert"
Expand All @@ -33,6 +34,7 @@ func TestNewOrganization(t *testing.T) {
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mnm := &networkmapmocks.Manager{}
o.On("NetworkMap").Return(mnm)
o.On("MultiParty").Return(&multipartymocks.Manager{})
input := core.Identity{}
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(&input)
Expand Down

0 comments on commit a64ee78

Please sign in to comment.