Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 96fd401

Browse files
committed
[FAB-8866] Rename UserName to Username
Change-Id: Id68a7fc03210060449cb39e876195636c33229d8 Signed-off-by: Troy Ronda <troy@troyronda.com>
1 parent f662850 commit 96fd401

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+137
-137
lines changed

pkg/client/channel/api_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ func TestWithTargetURLsValid(t *testing.T) {
6969
assert.Equal(t, npConfig1.MSPID, opts.Targets[0].MSPID(), "", "Wrong MSP")
7070
}
7171

72-
func setupMockTestContext(userName string, mspID string) *fcmocks.MockContext {
73-
user := fcmocks.NewMockUserWithMSPID(userName, mspID)
72+
func setupMockTestContext(username string, mspID string) *fcmocks.MockContext {
73+
user := fcmocks.NewMockUserWithMSPID(username, mspID)
7474
ctx := fcmocks.NewMockContext(user)
7575
return ctx
7676
}

pkg/client/common/selection/dynamicselection/ccpolicyprovider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ type CCPolicyProvider interface {
4444
}
4545

4646
// NewCCPolicyProvider creates new chaincode policy data provider
47-
func newCCPolicyProvider(providers api.Providers, channelID string, userName string, orgName string) (CCPolicyProvider, error) {
48-
if providers == nil || channelID == "" || userName == "" || orgName == "" {
47+
func newCCPolicyProvider(providers api.Providers, channelID string, username string, orgName string) (CCPolicyProvider, error) {
48+
if providers == nil || channelID == "" || username == "" || orgName == "" {
4949
return nil, errors.New("Must provide providers, channel ID, user name and organisation for cc policy provider")
5050
}
5151

@@ -61,7 +61,7 @@ func newCCPolicyProvider(providers api.Providers, channelID string, userName str
6161
return nil, errors.New("invalid options to create identity, invalid org name")
6262
}
6363

64-
identity, err := mgr.GetUser(userName)
64+
identity, err := mgr.GetUser(username)
6565
if err != nil {
6666
return nil, errors.WithMessage(err, "unable to create identity for ccl policy provider")
6767
}

pkg/client/common/selection/dynamicselection/dynamicselection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
// ChannelUser contains user(identity) info to be used for specific channel
2323
type ChannelUser struct {
2424
ChannelID string
25-
UserName string
25+
Username string
2626
OrgName string
2727
}
2828

@@ -76,7 +76,7 @@ func (p *SelectionProvider) CreateSelectionService(channelID string) (fab.Select
7676
return nil, errors.New("Must provide user for channel")
7777
}
7878

79-
ccPolicyProvider, err := newCCPolicyProvider(p.providers, channelID, channelUser.UserName, channelUser.OrgName)
79+
ccPolicyProvider, err := newCCPolicyProvider(p.providers, channelID, channelUser.Username, channelUser.OrgName)
8080
if err != nil {
8181
return nil, errors.WithMessage(err, "Failed to create cc policy provider")
8282
}

pkg/client/common/selection/dynamicselection/dynamicselection_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func TestDynamicSelection(t *testing.T) {
338338
t.Fatalf("Failed to to get client context: %s", err)
339339
}
340340

341-
mychannelUser := ChannelUser{ChannelID: "mychannel", UserName: "User1", OrgName: "Org1"}
341+
mychannelUser := ChannelUser{ChannelID: "mychannel", Username: "User1", OrgName: "Org1"}
342342

343343
selectionProvider, err := New(ctx.Config(), []ChannelUser{mychannelUser}, nil)
344344
if err != nil {
@@ -472,8 +472,8 @@ func (lbp *customLBP) Choose(peerGroups []pgresolver.PeerGroup) pgresolver.PeerG
472472
return peerGroups[0]
473473
}
474474

475-
func setupMockContext(userName, orgName string) context.Providers {
476-
user := mocks.NewMockUserWithMSPID(userName, orgName)
475+
func setupMockContext(username, orgName string) context.Providers {
476+
user := mocks.NewMockUserWithMSPID(username, orgName)
477477
ctx := mocks.NewMockContext(user)
478478
return ctx
479479
}

pkg/client/ledger/opts_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ func TestWithTargetURLsValid(t *testing.T) {
6969
assert.Equal(t, npConfig1.MSPID, opts.Targets[0].MSPID(), "", "Wrong MSP")
7070
}
7171

72-
func setupTestContext(userName string, mspID string) *fcmocks.MockContext {
73-
user := fcmocks.NewMockUserWithMSPID(userName, mspID)
72+
func setupTestContext(username string, mspID string) *fcmocks.MockContext {
73+
user := fcmocks.NewMockUserWithMSPID(username, mspID)
7474
ctx := fcmocks.NewMockContext(user)
7575
return ctx
7676
}

pkg/client/msp/msp.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ func (c *Client) Revoke(request *RevocationRequest) (*RevocationResponse, error)
181181
}
182182

183183
// GetSigningIdentity returns a signing identity for the given user name
184-
func (c *Client) GetSigningIdentity(userName string) (*SigningIdentity, error) {
185-
user, err := c.GetUser(userName)
184+
func (c *Client) GetSigningIdentity(username string) (*SigningIdentity, error) {
185+
user, err := c.GetUser(username)
186186
if err != nil {
187187
if err == mspctx.ErrUserNotFound {
188188
return nil, ErrUserNotFound
@@ -194,9 +194,9 @@ func (c *Client) GetSigningIdentity(userName string) (*SigningIdentity, error) {
194194
}
195195

196196
// GetUser returns a user for the given user name
197-
func (c *Client) GetUser(userName string) (User, error) {
197+
func (c *Client) GetUser(username string) (User, error) {
198198
im, _ := c.ctx.IdentityManager(c.orgName)
199-
user, err := im.GetUser(userName)
199+
user, err := im.GetUser(username)
200200
if err != nil {
201201
if err == mspctx.ErrUserNotFound {
202202
return nil, ErrUserNotFound

pkg/client/msp/msp_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,36 @@ func TestMSP(t *testing.T) {
4949
}
5050

5151
// Empty enrollment secret
52-
err = msp.Enroll("enrolledUserName", WithSecret(""))
52+
err = msp.Enroll("enrolledUsername", WithSecret(""))
5353
if err == nil {
5454
t.Fatalf("Enroll should return error for empty enrollment secret")
5555
}
5656

5757
// Successful enrollment scenario
5858

59-
enrollUserName := randomUserName()
59+
enrollUsername := randomUsername()
6060

61-
_, err = msp.GetSigningIdentity(enrollUserName)
61+
_, err = msp.GetSigningIdentity(enrollUsername)
6262
if err != ErrUserNotFound {
6363
t.Fatalf("Expected to not find user")
6464
}
6565

66-
err = msp.Enroll(enrollUserName, WithSecret("enrollmentSecret"))
66+
err = msp.Enroll(enrollUsername, WithSecret("enrollmentSecret"))
6767
if err != nil {
6868
t.Fatalf("Enroll return error %v", err)
6969
}
7070

71-
_, err = msp.GetSigningIdentity(enrollUserName)
71+
_, err = msp.GetSigningIdentity(enrollUsername)
7272
if err != nil {
7373
t.Fatalf("Expected to find user")
7474
}
7575

76-
enrolledUser, err := msp.GetUser(enrollUserName)
76+
enrolledUser, err := msp.GetUser(enrollUsername)
7777
if err != nil {
7878
t.Fatalf("Expected to find user")
7979
}
8080

81-
if enrolledUser.Name() != enrollUserName {
81+
if enrolledUser.Name() != enrollUsername {
8282
t.Fatalf("Enrolled user name doesn't match")
8383
}
8484

@@ -107,19 +107,19 @@ func TestMSP(t *testing.T) {
107107
t.Fatalf("failed to create CA client: %v", err)
108108
}
109109

110-
org2lUserName := randomUserName()
110+
org2lUsername := randomUsername()
111111

112-
err = msp.Enroll(org2lUserName, WithSecret("enrollmentSecret"))
112+
err = msp.Enroll(org2lUsername, WithSecret("enrollmentSecret"))
113113
if err != nil {
114114
t.Fatalf("Enroll return error %v", err)
115115
}
116116

117-
org2EnrolledUser, err := msp.GetUser(org2lUserName)
117+
org2EnrolledUser, err := msp.GetUser(org2lUsername)
118118
if err != nil {
119119
t.Fatalf("Expected to find user")
120120
}
121121

122-
if org2EnrolledUser.Name() != org2lUserName {
122+
if org2EnrolledUser.Name() != org2lUsername {
123123
t.Fatalf("Enrolled user name doesn't match")
124124
}
125125

@@ -197,6 +197,6 @@ func myMSPID(t *testing.T, c core.Config) string {
197197
return orgConfig.MSPID
198198
}
199199

200-
func randomUserName() string {
200+
func randomUsername() string {
201201
return "user" + strconv.Itoa(rand.Intn(500000))
202202
}

pkg/client/msp/testdata/config_test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ organizations:
171171
mspid: Org1MSP
172172

173173
# This org's MSP store (absolute path or relative to client.cryptoconfig)
174-
cryptoPath: peerOrganizations/org1.example.com/users/{userName}@org1.example.com/msp
174+
cryptoPath: peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp
175175

176176
peers:
177177
- peer0.org1.example.com
@@ -205,7 +205,7 @@ organizations:
205205
mspid: Org2MSP
206206

207207
# This org's MSP store (absolute path or relative to client.cryptoconfig)
208-
cryptoPath: peerOrganizations/org2.example.com/users/{userName}@org2.example.com/msp
208+
cryptoPath: peerOrganizations/org2.example.com/users/{username}@org2.example.com/msp
209209

210210
peers:
211211
- peer0.org2.example.com
@@ -219,7 +219,7 @@ organizations:
219219
mspID: "OrdererOrg"
220220

221221
# Needed to load users crypto keys and certs for this org (absolute path or relative to global crypto path, DEV mode)
222-
cryptoPath: ordererOrganizations/example.com/users/{userName}@example.com/msp
222+
cryptoPath: ordererOrganizations/example.com/users/{username}@example.com/msp
223223

224224

225225
#

pkg/client/msp/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ type UserIdentifier struct {
8282
// PrivKeyKey is a composite key for accessing a private key in the key store
8383
type PrivKeyKey struct {
8484
MSPID string
85-
UserName string
85+
Username string
8686
SKI []byte
8787
}
8888

8989
// CertKey is a composite key for accessing a cert in the cert store
9090
type CertKey struct {
9191
MSPID string
92-
UserName string
92+
Username string
9393
}

pkg/client/resmgmt/resmgmt_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,8 @@ func setupResMgmtClient(fabCtx context.Client, discErr error, t *testing.T, opts
12661266

12671267
}
12681268

1269-
func setupTestContext(userName string, mspID string) *fcmocks.MockContext {
1270-
user := fcmocks.NewMockUserWithMSPID(userName, mspID)
1269+
func setupTestContext(username string, mspID string) *fcmocks.MockContext {
1270+
user := fcmocks.NewMockUserWithMSPID(username, mspID)
12711271
ctx := fcmocks.NewMockContext(user)
12721272
return ctx
12731273
}
@@ -1279,8 +1279,8 @@ func setupCustomOrderer(ctx *fcmocks.MockContext, mockOrderer fab.Orderer) *fcmo
12791279
return ctx
12801280
}
12811281

1282-
func setupTestContextWithDiscoveryError(userName string, mspID string, discErr error) *fcmocks.MockContext {
1283-
user := fcmocks.NewMockUserWithMSPID(userName, mspID)
1282+
func setupTestContextWithDiscoveryError(username string, mspID string, discErr error) *fcmocks.MockContext {
1283+
user := fcmocks.NewMockUserWithMSPID(username, mspID)
12841284
dscPvdr, _ := setupTestDiscovery(discErr, nil)
12851285
//ignore err and set whatever you get in dscPvdr
12861286
ctx := fcmocks.NewMockContextWithCustomDiscovery(user, dscPvdr)

0 commit comments

Comments
 (0)