Skip to content

Commit 230be1d

Browse files
authored
NOISSUE - Fix typos (#2927)
Signed-off-by: fbugarski <[email protected]>
1 parent 99493d8 commit 230be1d

31 files changed

+436
-436
lines changed

auth/api/grpc/auth/endpoint_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const (
3232
usersType = "users"
3333
description = "Description"
3434
groupName = "smqx"
35-
adminpermission = "admin"
35+
adminPermission = "admin"
3636

3737
authoritiesObj = "authorities"
3838
memberRelation = "member"
@@ -134,7 +134,7 @@ func TestAuthorize(t *testing.T) {
134134
Object: authoritiesObj,
135135
ObjectType: usersType,
136136
Relation: memberRelation,
137-
Permission: adminpermission,
137+
Permission: adminPermission,
138138
},
139139
authResponse: &grpcAuthV1.AuthZRes{Authorized: true},
140140
err: nil,
@@ -148,7 +148,7 @@ func TestAuthorize(t *testing.T) {
148148
Object: authoritiesObj,
149149
ObjectType: usersType,
150150
Relation: memberRelation,
151-
Permission: adminpermission,
151+
Permission: adminPermission,
152152
},
153153
authResponse: &grpcAuthV1.AuthZRes{Authorized: false},
154154
err: svcerr.ErrAuthorization,
@@ -162,7 +162,7 @@ func TestAuthorize(t *testing.T) {
162162
Object: authoritiesObj,
163163
ObjectType: usersType,
164164
Relation: memberRelation,
165-
Permission: adminpermission,
165+
Permission: adminPermission,
166166
},
167167
authResponse: &grpcAuthV1.AuthZRes{Authorized: false},
168168
err: apiutil.ErrMissingPolicySub,
@@ -176,7 +176,7 @@ func TestAuthorize(t *testing.T) {
176176
Object: authoritiesObj,
177177
ObjectType: usersType,
178178
Relation: memberRelation,
179-
Permission: adminpermission,
179+
Permission: adminPermission,
180180
},
181181
authResponse: &grpcAuthV1.AuthZRes{Authorized: false},
182182
err: apiutil.ErrMissingPolicySub,
@@ -190,7 +190,7 @@ func TestAuthorize(t *testing.T) {
190190
Object: "",
191191
ObjectType: usersType,
192192
Relation: memberRelation,
193-
Permission: adminpermission,
193+
Permission: adminPermission,
194194
},
195195
authResponse: &grpcAuthV1.AuthZRes{Authorized: false},
196196
err: apiutil.ErrMissingPolicyObj,
@@ -204,7 +204,7 @@ func TestAuthorize(t *testing.T) {
204204
Object: authoritiesObj,
205205
ObjectType: "",
206206
Relation: memberRelation,
207-
Permission: adminpermission,
207+
Permission: adminPermission,
208208
},
209209
authResponse: &grpcAuthV1.AuthZRes{Authorized: false},
210210
err: apiutil.ErrMissingPolicyObj,
@@ -226,13 +226,13 @@ func TestAuthorize(t *testing.T) {
226226
}
227227
for _, tc := range cases {
228228
t.Run(tc.desc, func(t *testing.T) {
229-
svccall := svc.On("Authorize", mock.Anything, mock.Anything).Return(tc.err)
229+
svcCall := svc.On("Authorize", mock.Anything, mock.Anything).Return(tc.err)
230230
ar, err := grpcClient.Authorize(context.Background(), tc.authRequest)
231231
if ar != nil {
232232
assert.Equal(t, tc.authResponse, ar, fmt.Sprintf("%s: expected %v got %v", tc.desc, tc.authResponse, ar))
233233
}
234234
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
235-
svccall.Unset()
235+
svcCall.Unset()
236236
})
237237
}
238238
}
@@ -354,7 +354,7 @@ func TestAuthorizePAT(t *testing.T) {
354354
}
355355
for _, tc := range cases {
356356
t.Run(tc.desc, func(t *testing.T) {
357-
svccall := svc.On("AuthorizePAT",
357+
svcCall := svc.On("AuthorizePAT",
358358
mock.Anything,
359359
tc.authRequest.UserId,
360360
tc.authRequest.PatId,
@@ -368,7 +368,7 @@ func TestAuthorizePAT(t *testing.T) {
368368
assert.Equal(t, tc.authResponse, ar, fmt.Sprintf("%s: expected %v got %v", tc.desc, tc.authResponse, ar))
369369
}
370370
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
371-
svccall.Unset()
371+
svcCall.Unset()
372372
})
373373
}
374374
}

auth/api/grpc/token/endpoint_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const (
3232
usersType = "users"
3333
description = "Description"
3434
groupName = "smqx"
35-
adminpermission = "admin"
35+
adminPermission = "admin"
3636

3737
authoritiesObj = "authorities"
3838
memberRelation = "member"

auth/api/http/keys/endpoint_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ func TestIssue(t *testing.T) {
201201
token: tc.token,
202202
body: strings.NewReader(tc.req),
203203
}
204-
repocall := krepo.On("Save", mock.Anything, mock.Anything).Return("", nil)
204+
repoCall := krepo.On("Save", mock.Anything, mock.Anything).Return("", nil)
205205
policyCall := pEvaluator.On("CheckPolicy", mock.Anything, mock.Anything).Return(nil)
206206
res, err := req.make()
207207
assert.Nil(t, err, fmt.Sprintf("%s: unexpected error %s", tc.desc, err))
208208
assert.Equal(t, tc.status, res.StatusCode, fmt.Sprintf("%s: expected status code %d got %d", tc.desc, tc.status, res.StatusCode))
209-
repocall.Unset()
209+
repoCall.Unset()
210210
policyCall.Unset()
211211
}
212212
}
@@ -218,10 +218,10 @@ func TestRetrieve(t *testing.T) {
218218
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
219219
key := auth.Key{Type: auth.APIKey, IssuedAt: time.Now(), Subject: id}
220220

221-
repocall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
221+
repoCall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
222222
k, err := svc.Issue(context.Background(), token.AccessToken, key)
223223
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
224-
repocall.Unset()
224+
repoCall.Unset()
225225
policyCall.Unset()
226226

227227
ts := newServer(svc)
@@ -280,11 +280,11 @@ func TestRetrieve(t *testing.T) {
280280
token: tc.token,
281281
}
282282
policyCall := pEvaluator.On("CheckPolicy", mock.Anything, mock.Anything).Return(nil)
283-
repocall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(tc.key, tc.err)
283+
repoCall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(tc.key, tc.err)
284284
res, err := req.make()
285285
assert.Nil(t, err, fmt.Sprintf("%s: unexpected error %s", tc.desc, err))
286286
assert.Equal(t, tc.status, res.StatusCode, fmt.Sprintf("%s: expected status code %d got %d", tc.desc, tc.status, res.StatusCode))
287-
repocall.Unset()
287+
repoCall.Unset()
288288
policyCall.Unset()
289289
}
290290
}
@@ -296,10 +296,10 @@ func TestRevoke(t *testing.T) {
296296
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
297297
key := auth.Key{Type: auth.APIKey, IssuedAt: time.Now(), Subject: id}
298298

299-
repocall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
299+
repoCall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
300300
k, err := svc.Issue(context.Background(), token.AccessToken, key)
301301
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
302-
repocall.Unset()
302+
repoCall.Unset()
303303
policyCall.Unset()
304304

305305
ts := newServer(svc)
@@ -345,10 +345,10 @@ func TestRevoke(t *testing.T) {
345345
url: fmt.Sprintf("%s/keys/%s", ts.URL, tc.id),
346346
token: tc.token,
347347
}
348-
repocall := krepo.On("Remove", mock.Anything, mock.Anything, mock.Anything).Return(nil)
348+
repoCall := krepo.On("Remove", mock.Anything, mock.Anything, mock.Anything).Return(nil)
349349
res, err := req.make()
350350
assert.Nil(t, err, fmt.Sprintf("%s: unexpected error %s", tc.desc, err))
351351
assert.Equal(t, tc.status, res.StatusCode, fmt.Sprintf("%s: expected status code %d got %d", tc.desc, tc.status, res.StatusCode))
352-
repocall.Unset()
352+
repoCall.Unset()
353353
}
354354
}

auth/api/http/pats/requests.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ type addScopeReq struct {
199199
Scopes []auth.Scope `json:"scopes,omitempty"`
200200
}
201201

202-
func (aser *addScopeReq) UnmarshalJSON(data []byte) error {
202+
func (req *addScopeReq) UnmarshalJSON(data []byte) error {
203203
type Alias addScopeReq
204204
aux := &struct {
205205
*Alias
206206
}{
207-
Alias: (*Alias)(aser),
207+
Alias: (*Alias)(req),
208208
}
209209

210210
if err := json.Unmarshal(data, aux); err != nil {

auth/service_test.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,12 @@ func TestIssue(t *testing.T) {
321321

322322
func TestRevoke(t *testing.T) {
323323
svc, _ := newService()
324-
repocall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, errIssueUser)
324+
repoCall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, errIssueUser)
325325
policyCall := pEvaluator.On("CheckPolicy", mock.Anything, mock.Anything).Return(nil)
326326
secret, err := svc.Issue(context.Background(), "", auth.Key{Type: auth.AccessKey, Role: auth.UserRole, IssuedAt: time.Now(), Subject: userID})
327-
repocall.Unset()
327+
repoCall.Unset()
328328
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
329-
repocall1 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
329+
repoCall1 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
330330
key := auth.Key{
331331
Type: auth.APIKey,
332332
Role: auth.UserRole,
@@ -335,7 +335,7 @@ func TestRevoke(t *testing.T) {
335335
}
336336
_, err = svc.Issue(context.Background(), secret.AccessToken, key)
337337
assert.Nil(t, err, fmt.Sprintf("Issuing user's key expected to succeed: %s", err))
338-
repocall1.Unset()
338+
repoCall1.Unset()
339339
policyCall.Unset()
340340

341341
cases := []struct {
@@ -368,20 +368,20 @@ func TestRevoke(t *testing.T) {
368368
}
369369

370370
for _, tc := range cases {
371-
repocall := krepo.On("Remove", mock.Anything, mock.Anything, mock.Anything).Return(tc.err)
371+
repoCall := krepo.On("Remove", mock.Anything, mock.Anything, mock.Anything).Return(tc.err)
372372
err := svc.Revoke(context.Background(), tc.token, tc.id)
373373
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s expected %s got %s\n", tc.desc, tc.err, err))
374-
repocall.Unset()
374+
repoCall.Unset()
375375
}
376376
}
377377

378378
func TestRetrieve(t *testing.T) {
379379
svc, _ := newService()
380-
repocall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
381-
repocall1 := pEvaluator.On("CheckPolicy", mock.Anything, mock.Anything).Return(nil)
380+
repoCall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
381+
repoCall1 := pEvaluator.On("CheckPolicy", mock.Anything, mock.Anything).Return(nil)
382382
secret, err := svc.Issue(context.Background(), "", auth.Key{Type: auth.AccessKey, Subject: userID, Role: auth.UserRole, IssuedAt: time.Now()})
383383
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
384-
repocall.Unset()
384+
repoCall.Unset()
385385
key := auth.Key{
386386
ID: "id",
387387
Type: auth.APIKey,
@@ -390,21 +390,21 @@ func TestRetrieve(t *testing.T) {
390390
IssuedAt: time.Now(),
391391
}
392392

393-
repocall3 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
393+
repoCall3 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
394394
userToken, err := svc.Issue(context.Background(), "", auth.Key{Type: auth.AccessKey, Subject: userID, Role: auth.UserRole, IssuedAt: time.Now()})
395395
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
396-
repocall3.Unset()
396+
repoCall3.Unset()
397397

398-
repocall4 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
398+
repoCall4 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
399399
apiToken, err := svc.Issue(context.Background(), secret.AccessToken, key)
400400
assert.Nil(t, err, fmt.Sprintf("Issuing login's key expected to succeed: %s", err))
401-
repocall4.Unset()
401+
repoCall4.Unset()
402402

403-
repocall5 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
403+
repoCall5 := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
404404
resetToken, err := svc.Issue(context.Background(), "", auth.Key{Type: auth.RecoveryKey, Subject: userID, Role: auth.UserRole, IssuedAt: time.Now()})
405405
assert.Nil(t, err, fmt.Sprintf("Issuing reset key expected to succeed: %s", err))
406-
repocall5.Unset()
407-
repocall1.Unset()
406+
repoCall5.Unset()
407+
repoCall1.Unset()
408408

409409
cases := []struct {
410410
desc string
@@ -441,18 +441,18 @@ func TestRetrieve(t *testing.T) {
441441
}
442442

443443
for _, tc := range cases {
444-
repocall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(auth.Key{}, tc.err)
444+
repoCall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(auth.Key{}, tc.err)
445445
_, err := svc.RetrieveKey(context.Background(), tc.token, tc.id)
446446
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s expected %s got %s\n", tc.desc, tc.err, err))
447-
repocall.Unset()
447+
repoCall.Unset()
448448
}
449449
}
450450

451451
func TestIdentify(t *testing.T) {
452452
svc, _ := newService()
453453

454-
repocall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
455-
repocall1 := pEvaluator.On("CheckPolicy", mock.Anything, mock.Anything).Return(nil)
454+
repoCall := krepo.On("Save", mock.Anything, mock.Anything).Return(mock.Anything, nil)
455+
repoCall1 := pEvaluator.On("CheckPolicy", mock.Anything, mock.Anything).Return(nil)
456456
loginSecret, err := svc.Issue(context.Background(), "", auth.Key{Type: auth.AccessKey, Subject: userID, Role: auth.UserRole, IssuedAt: time.Now()})
457457
assert.Nil(t, err, fmt.Sprintf("Issuing login key expected to succeed: %s", err))
458458

@@ -466,8 +466,8 @@ func TestIdentify(t *testing.T) {
466466
exp1 := time.Now().UTC().Add(-1 * time.Minute).Round(time.Second)
467467
expSecret, err := svc.Issue(context.Background(), loginSecret.AccessToken, auth.Key{Type: auth.APIKey, Role: auth.UserRole, IssuedAt: exp0, ExpiresAt: exp1})
468468
assert.Nil(t, err, fmt.Sprintf("Issuing expired login key expected to succeed: %s", err))
469-
repocall.Unset()
470-
repocall1.Unset()
469+
repoCall.Unset()
470+
repoCall1.Unset()
471471

472472
te := jwt.New([]byte(secret))
473473
key := auth.Key{
@@ -536,13 +536,13 @@ func TestIdentify(t *testing.T) {
536536
}
537537

538538
for _, tc := range cases {
539-
repocall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(auth.Key{}, tc.err)
540-
repocall1 := krepo.On("Remove", mock.Anything, mock.Anything, mock.Anything).Return(tc.err)
539+
repoCall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(auth.Key{}, tc.err)
540+
repoCall1 := krepo.On("Remove", mock.Anything, mock.Anything, mock.Anything).Return(tc.err)
541541
idt, err := svc.Identify(context.Background(), tc.key)
542542
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s expected %s got %s\n", tc.desc, tc.err, err))
543543
assert.Equal(t, tc.subject, idt.Subject, fmt.Sprintf("%s expected %s got %s\n", tc.desc, tc.subject, idt))
544-
repocall.Unset()
545-
repocall1.Unset()
544+
repoCall.Unset()
545+
repoCall1.Unset()
546546
}
547547
}
548548

channels/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ func (svc service) CreateChannels(ctx context.Context, session authn.Session, ch
110110
},
111111
)
112112
}
113-
nrps, err := svc.AddNewEntitiesRoles(ctx, session.DomainID, session.UserID, chIDs, optionalPolicies, newBuiltInRoleMembers)
113+
rp, err := svc.AddNewEntitiesRoles(ctx, session.DomainID, session.UserID, chIDs, optionalPolicies, newBuiltInRoleMembers)
114114
if err != nil {
115115
return []Channel{}, []roles.RoleProvision{}, errors.Wrap(svcerr.ErrAddPolicies, err)
116116
}
117-
return savedChs, nrps, nil
117+
return savedChs, rp, nil
118118
}
119119

120120
func (svc service) UpdateChannel(ctx context.Context, session authn.Session, ch Channel) (Channel, error) {

0 commit comments

Comments
 (0)