Skip to content

Commit

Permalink
Disable identity resolution for local definitions
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 24, 2022
1 parent b452654 commit 04aec20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
8 changes: 5 additions & 3 deletions internal/defsender/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ func (bm *definitionSender) CreateDefinition(ctx context.Context, def core.Defin

func (bm *definitionSender) CreateDefinitionWithIdentity(ctx context.Context, def core.Definition, signingIdentity *core.SignerRef, tag string, waitConfirm bool) (msg *core.Message, err error) {

err = bm.identity.ResolveInputSigningIdentity(ctx, signingIdentity)
if err != nil {
return nil, err
if bm.multiparty {
err = bm.identity.ResolveInputSigningIdentity(ctx, signingIdentity)
if err != nil {
return nil, err
}
}

return bm.createDefinitionCommon(ctx, def, signingIdentity, tag, waitConfirm)
Expand Down
18 changes: 2 additions & 16 deletions internal/defsender/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ func TestCreateDefinitionBadIdentity(t *testing.T) {
ds, cancel := newTestDefinitionSender(t)
defer cancel()

ds.multiparty = true

mim := ds.identity.(*identitymanagermocks.Manager)
mim.On("ResolveInputSigningIdentity", mock.Anything, mock.Anything).Return(fmt.Errorf("pop"))
_, err := ds.CreateDefinitionWithIdentity(ds.ctx, &core.Namespace{}, &core.SignerRef{
Expand All @@ -165,38 +167,22 @@ func TestCreateDefinitionLocal(t *testing.T) {
ds, cancel := newTestDefinitionSender(t)
defer cancel()

mim := ds.identity.(*identitymanagermocks.Manager)
mbm := ds.broadcast.(*broadcastmocks.Manager)
mms := &sysmessagingmocks.MessageSender{}
mdh := &mockDefinitionHandler{}
ds.Init(mdh)

mim.On("ResolveInputSigningIdentity", mock.Anything, mock.Anything).Return(nil)

_, err := ds.CreateDefinition(ds.ctx, &core.Datatype{}, core.SystemTagDefineDatatype, true)
assert.NoError(t, err)

mim.AssertExpectations(t)
mbm.AssertExpectations(t)
mms.AssertExpectations(t)
}

func TestCreateDefinitionLocalError(t *testing.T) {
ds, cancel := newTestDefinitionSender(t)
defer cancel()

mim := ds.identity.(*identitymanagermocks.Manager)
mbm := ds.broadcast.(*broadcastmocks.Manager)
mms := &sysmessagingmocks.MessageSender{}
mdh := &mockDefinitionHandler{err: fmt.Errorf("pop")}
ds.Init(mdh)

mim.On("ResolveInputSigningIdentity", mock.Anything, mock.Anything).Return(nil)

_, err := ds.CreateDefinition(ds.ctx, &core.Datatype{}, core.SystemTagDefineDatatype, true)
assert.EqualError(t, err, "pop")

mim.AssertExpectations(t)
mbm.AssertExpectations(t)
mms.AssertExpectations(t)
}
4 changes: 0 additions & 4 deletions internal/identity/identitymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ func (im *identityManager) resolveDefaultSigningIdentity(ctx context.Context, si
if err != nil {
return err
}
if im.multiparty == nil {
signerRef.Key = verifierRef.Value
return nil
}
identity, err := im.GetMultipartyRootOrg(ctx)
if err != nil {
return err
Expand Down

0 comments on commit 04aec20

Please sign in to comment.