-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change-set does following: - It modifed the QSCC to use ACLProvider for access control. Tests have been updated to validate the changes. removed sync.Once so we can use RegisterACLProvider for UT . Uses mocks framework for all tests (removes MockACLProvider2). . Put back sync.Once and remove SetACLProvider now we use the mock for everything . refactor query_test.go to use the mock Change-Id: I5f5346c131d6cf715f23a0717fed82c76f58dd43 Signed-off-by: Angelo De Caro <adc@zurich.ibm.com> Signed-off-by: Srinivasan Muralidharan <srinivasan.muralidharan99@gmail.com>
- Loading branch information
1 parent
0e495ee
commit bf4e455
Showing
4 changed files
with
171 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package mocks | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/core/ledger" | ||
"github.com/hyperledger/fabric/protos/common" | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
type MockACLProvider struct { | ||
//create a mock object that can be reset after | ||
//registering a MockACLProvider with aclmgmt | ||
mock *mock.Mock | ||
} | ||
|
||
//clear the mock so we can start afresh | ||
func (m *MockACLProvider) Reset() { | ||
m.mock = &mock.Mock{} | ||
} | ||
|
||
func (m *MockACLProvider) CheckACL(resName string, channelID string, idinfo interface{}) error { | ||
args := m.mock.Called(resName, channelID, idinfo) | ||
return args.Error(0) | ||
} | ||
|
||
func (m *MockACLProvider) GenerateSimulationResults(txEnvelop *common.Envelope, simulator ledger.TxSimulator) error { | ||
return nil | ||
} | ||
|
||
//On overrider the mock method for convenience | ||
func (m *MockACLProvider) On(methodName string, arguments ...interface{}) *mock.Call { | ||
return m.mock.On(methodName, arguments...) | ||
} | ||
|
||
//AssertExpectations overrider the mock method for convenience | ||
func (m *MockACLProvider) AssertExpectations(t *testing.T) { | ||
m.mock.AssertExpectations(t) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.