Linter fixes PR 3 (#4415)
* Linter fixes * fix(bsr): update test to register TEST protocol once --------- Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
This commit is contained in:
1 parent
e95eda7ca2
commit
35cef97bd4
119 files changed
+365
-300
No files matched your search
@@ -93,7 +93,7 @@ func WithAnonymousUserNotAllowed(notAllowed bool) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithResource specifies a resouce to use
|
||||
// WithResource specifies a resource to use
|
||||
func WithResource(resource *perms.Resource) Option {
|
||||
return func(o *options) {
|
||||
o.withResource = resource
|
||||
|
||||
@@ -551,7 +551,7 @@ func (c *Controller) Start() error {
|
||||
-1,
|
||||
)
|
||||
if err != nil {
|
||||
errors.Wrap(c.baseContext, err, op)
|
||||
event.WriteError(c.baseContext, op, fmt.Errorf("connection management ticker exited with error: %w", err))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -3028,9 +3028,9 @@ func TestUpdatePassword(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Account{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
@@ -3425,9 +3425,9 @@ func TestUpdateOidc(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Account{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
@@ -3814,7 +3814,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
{
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Account{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -202,7 +202,7 @@ func Test_UpdateLdap(t *testing.T) {
|
||||
{
|
||||
name: "non-existent-paths-in-mask",
|
||||
req: &pbs.UpdateAuthMethodRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -493,9 +493,9 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateAuthMethodRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -181,9 +181,9 @@ func TestUpdate_Password(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateAuthMethodRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.AuthMethod{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestPkAndClientCerts(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
s := vault.NewTestVaultServer(t, vault.WithTestVaultTLS(vault.TestClientTLS))
|
||||
|
||||
t.Run("seperate client cert and key", func(t *testing.T) {
|
||||
t.Run("separate client cert and key", func(t *testing.T) {
|
||||
c, k, err := extractClientCertAndPk(ctx, string(s.ClientCert), string(s.ClientKey))
|
||||
assert.NoError(t, err)
|
||||
require.NotNil(t, k)
|
||||
|
||||
@@ -21,7 +21,7 @@ type Filter struct {
|
||||
eval *bexpr.Evaluator
|
||||
}
|
||||
|
||||
// NewFilter returns a Filter which can be evluated against. An empty string paramter indicates
|
||||
// NewFilter returns a Filter which can be evaluated against. An empty string parameter indicates
|
||||
// all items passed to it should succeed.
|
||||
func NewFilter(ctx context.Context, f string) (*Filter, error) {
|
||||
const op = "handlers.NewFilter"
|
||||
|
||||
@@ -157,7 +157,7 @@ func TestGet(t *testing.T) {
|
||||
res: &pbs.GetGroupResponse{Item: wantOrgGroup},
|
||||
},
|
||||
{
|
||||
name: "Get a non existant Group",
|
||||
name: "Get a non existent Group",
|
||||
req: &pbs.GetGroupRequest{Id: globals.GroupPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
@@ -181,7 +181,7 @@ func TestGet(t *testing.T) {
|
||||
res: &pbs.GetGroupResponse{Item: wantProjGroup},
|
||||
},
|
||||
{
|
||||
name: "Project Scoped Get a non existant Group",
|
||||
name: "Project Scoped Get a non existent Group",
|
||||
scopeId: pg.GetScopeId(),
|
||||
req: &pbs.GetGroupRequest{Id: globals.GroupPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
@@ -1254,10 +1254,10 @@ func TestUpdate(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
scopeId: og.GetScopeId(),
|
||||
req: &pbs.UpdateGroupRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Group{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -1588,9 +1588,9 @@ func TestUpdate_Static(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateHostCatalogRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.HostCatalog{
|
||||
Name: &wrappers.StringValue{Value: "updated name"},
|
||||
Description: &wrappers.StringValue{Value: "updated desc"},
|
||||
@@ -2049,8 +2049,8 @@ func TestUpdate_Plugin(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
masks: []string{"nonexistant_field"},
|
||||
name: "Only non-existent paths in Mask",
|
||||
masks: []string{"nonexistent_field"},
|
||||
changes: []updateFn{
|
||||
clearReadOnlyFields(),
|
||||
updateName(wrapperspb.String("new")),
|
||||
|
||||
@@ -1921,9 +1921,9 @@ func TestUpdate_Static(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateHostSetRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.HostSet{
|
||||
Name: &wrappers.StringValue{Value: "updated name"},
|
||||
Description: &wrappers.StringValue{Value: "updated desc"},
|
||||
@@ -2376,8 +2376,8 @@ func TestUpdate_Plugin(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
masks: []string{"nonexistant_field"},
|
||||
name: "Only non-existent paths in Mask",
|
||||
masks: []string{"nonexistent_field"},
|
||||
changes: []updateFn{
|
||||
clearReadOnlyFields(),
|
||||
updateName(wrapperspb.String("new")),
|
||||
|
||||
@@ -1625,7 +1625,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateHostRequest{
|
||||
Id: h.GetPublicId(),
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Host{
|
||||
Name: &wrappers.StringValue{Value: "updated name"},
|
||||
Description: &wrappers.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -2060,7 +2060,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
{
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateManagedGroupRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.ManagedGroup{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
@@ -2452,7 +2452,7 @@ func TestUpdateLdap(t *testing.T) {
|
||||
{
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateManagedGroupRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.ManagedGroup{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -137,7 +137,7 @@ func TestGet(t *testing.T) {
|
||||
res: &pbs.GetRoleResponse{Item: wantOrgRole},
|
||||
},
|
||||
{
|
||||
name: "Get a non existant Role",
|
||||
name: "Get a non existent Role",
|
||||
req: &pbs.GetRoleRequest{Id: globals.RolePrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
@@ -161,7 +161,7 @@ func TestGet(t *testing.T) {
|
||||
res: &pbs.GetRoleResponse{Item: wantProjRole},
|
||||
},
|
||||
{
|
||||
name: "Project Scoped Get a non existant Role",
|
||||
name: "Project Scoped Get a non existent Role",
|
||||
scopeId: pr.GetScopeId(),
|
||||
req: &pbs.GetRoleRequest{Id: globals.RolePrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
@@ -1254,10 +1254,10 @@ func TestUpdate(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
scopeId: or.GetScopeId(),
|
||||
req: &pbs.UpdateRoleRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Role{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
@@ -2491,7 +2491,7 @@ func TestRemoveGrants(t *testing.T) {
|
||||
result: []string{"ids=hcst_2;type=*;actions=delete"},
|
||||
},
|
||||
{
|
||||
name: "Remove non existant",
|
||||
name: "Remove non existent",
|
||||
existing: []string{"ids=hcst_2;type=*;actions=delete"},
|
||||
remove: []string{"ids=hcst_1;type=*;actions=read"},
|
||||
result: []string{"ids=hcst_2;type=*;actions=delete"},
|
||||
@@ -3266,7 +3266,7 @@ func TestRemoveGrantScopes(t *testing.T) {
|
||||
result: []string{"this"},
|
||||
},
|
||||
{
|
||||
name: "Remove non existant - global",
|
||||
name: "Remove non existent - global",
|
||||
scopeId: scope.Global.String(),
|
||||
existing: []string{"this", "descendants"},
|
||||
remove: []string{"p_foobar1234"},
|
||||
@@ -3300,7 +3300,7 @@ func TestRemoveGrantScopes(t *testing.T) {
|
||||
result: []string{"this"},
|
||||
},
|
||||
{
|
||||
name: "Remove non existant - org",
|
||||
name: "Remove non existent - org",
|
||||
scopeId: o.PublicId,
|
||||
existing: []string{"this", "children"},
|
||||
remove: []string{"p_foobar1234"},
|
||||
@@ -3327,7 +3327,7 @@ func TestRemoveGrantScopes(t *testing.T) {
|
||||
result: []string{},
|
||||
},
|
||||
{
|
||||
name: "Remove non existant - proj",
|
||||
name: "Remove non existent - proj",
|
||||
scopeId: p.PublicId,
|
||||
existing: []string{"this"},
|
||||
remove: []string{"p_foobar1234"},
|
||||
|
||||
@@ -1782,10 +1782,10 @@ func TestUpdate(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
scopeId: org.GetPublicId(),
|
||||
req: &pbs.UpdateScopeRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Scope{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -1390,9 +1390,9 @@ func TestUpdate(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateTargetRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Target{
|
||||
Name: wrapperspb.String("updated name"),
|
||||
Description: wrapperspb.String("updated desc"),
|
||||
|
||||
@@ -125,7 +125,7 @@ func TestGet(t *testing.T) {
|
||||
res: &pbs.GetUserResponse{Item: wantU},
|
||||
},
|
||||
{
|
||||
name: "Get a non existant User",
|
||||
name: "Get a non existent User",
|
||||
req: &pbs.GetUserRequest{Id: globals.UserPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
@@ -1022,9 +1022,9 @@ func TestUpdate(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateUserRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.User{
|
||||
Name: &wrapperspb.StringValue{Value: "updated name"},
|
||||
Description: &wrapperspb.StringValue{Value: "updated desc"},
|
||||
|
||||
@@ -717,9 +717,9 @@ func TestUpdate(t *testing.T) {
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Only non-existant paths in Mask",
|
||||
name: "Only non-existent paths in Mask",
|
||||
req: &pbs.UpdateWorkerRequest{
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}},
|
||||
UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistent_field"}},
|
||||
Item: &pb.Worker{
|
||||
Name: wrapperspb.String("updated name"),
|
||||
Description: wrapperspb.String("updated desc"),
|
||||
|
||||
@@ -46,6 +46,8 @@ func closeListener(_ context.Context, l net.Listener, _ any) error {
|
||||
}
|
||||
|
||||
func (c *Controller) startListeners() error {
|
||||
const op = "controller.startListeners"
|
||||
|
||||
servers := make([]func(), 0, len(c.conf.Listeners))
|
||||
|
||||
grpcServer, gwTicket, err := newGrpcServer(c.baseContext, c.IamRepoFn, c.AuthTokenRepoFn, c.ServersRepoFn, c.PasswordAuthRepoFn, c.OidcRepoFn, c.LdapRepoFn, c.kms, c.conf.Eventer)
|
||||
@@ -62,7 +64,13 @@ func (c *Controller) startListeners() error {
|
||||
|
||||
c.apiGrpcServerListener = newGrpcServerListener()
|
||||
servers = append(servers, func() {
|
||||
go c.apiGrpcServer.Serve(c.apiGrpcServerListener)
|
||||
go func() {
|
||||
if err := c.apiGrpcServer.Serve(c.apiGrpcServerListener); err != nil {
|
||||
// Use a background context as we might be shutting down and the
|
||||
// base context might be canceled.
|
||||
event.WriteError(context.Background(), op, fmt.Errorf("api grpc server returned with non-nil err: %w", err))
|
||||
}
|
||||
}()
|
||||
})
|
||||
|
||||
for i := range c.apiListeners {
|
||||
|
||||
@@ -52,7 +52,7 @@ func Test_TestController(t *testing.T) {
|
||||
// copy the output in a separate goroutine so writing to stderr can't block indefinitely
|
||||
go func() {
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, r)
|
||||
_, _ = io.Copy(&buf, r)
|
||||
outC <- buf.String()
|
||||
}()
|
||||
|
||||
|
||||
Reference in new issue
Block a user