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
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/hashicorp/nodeenrollment/rotation"
|
||||
nodeefile "github.com/hashicorp/nodeenrollment/storage/file"
|
||||
"github.com/hashicorp/nodeenrollment/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
@@ -35,7 +36,9 @@ func TestUpstreamService(t *testing.T) (UpstreamMessageServiceClientProducer, *t
|
||||
// sending upstream requests
|
||||
initStorage, err := nodeefile.New(testCtx)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { initStorage.Cleanup(testCtx) })
|
||||
t.Cleanup(func() {
|
||||
assert.NoError(t, initStorage.Cleanup(testCtx))
|
||||
})
|
||||
_, err = rotation.RotateRootCertificates(testCtx, initStorage)
|
||||
require.NoError(t, err)
|
||||
initNodeCreds, err := types.NewNodeCredentials(testCtx, initStorage)
|
||||
|
||||
@@ -105,7 +105,7 @@ func Test_controllerUpstreamMessageServiceServer_UpstreamMessage(t *testing.T) {
|
||||
// Get an initial set of authorized node credentials
|
||||
initStorage, err := nodeefile.New(testCtx)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { initStorage.Cleanup(testCtx) })
|
||||
t.Cleanup(func() { assert.NoError(t, initStorage.Cleanup(testCtx)) })
|
||||
_, err = rotation.RotateRootCertificates(testCtx, initStorage)
|
||||
require.NoError(t, err)
|
||||
initNodeCreds, err := types.NewNodeCredentials(testCtx, initStorage)
|
||||
|
||||
@@ -46,11 +46,14 @@ func TestStatus(t *testing.T) {
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iamRepo)
|
||||
|
||||
serverRepo, _ := server.NewRepository(ctx, rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
serverRepo, err := server.NewRepository(ctx, rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
_, err = serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serverRepo, nil
|
||||
}
|
||||
@@ -482,11 +485,14 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := server.NewRepository(ctx, rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
serverRepo, err := server.NewRepository(ctx, rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
_, err = serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serverRepo, nil
|
||||
}
|
||||
@@ -672,10 +678,11 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := server.NewRepository(ctx, rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
_, err := serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
@@ -826,11 +833,13 @@ func TestStatusWorkerWithKeyId(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := server.NewRepository(ctx, rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
serverRepo, err := server.NewRepository(ctx, rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
_, err = serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serverRepo, nil
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ func TestLookupSession(t *testing.T) {
|
||||
wantErrMsg: "rpc error: code = InvalidArgument desc = Did not receive worker id when looking up session",
|
||||
},
|
||||
{
|
||||
name: "nonexistant worker id",
|
||||
name: "nonexistent worker id",
|
||||
req: &pbs.LookupSessionRequest{
|
||||
SessionId: sessWithWorkerFilter.PublicId,
|
||||
WorkerId: "w_nonexistingworker",
|
||||
|
||||
@@ -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()
|
||||
}()
|
||||
|
||||
|
||||
@@ -136,7 +136,9 @@ func createTestServers(t *testing.T) ([]*serverTestInfo, error) {
|
||||
lInfo := &serverTestInfo{srv: srv, address: listener.Addr().String()}
|
||||
servers = append(servers, lInfo)
|
||||
go func(i int) {
|
||||
servers[i].srv.Serve(listener)
|
||||
if err := servers[i].srv.Serve(listener); err != nil {
|
||||
t.Logf("error serving: %v", err)
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +228,8 @@ func TestHijack_MultipleCalls(t *testing.T) {
|
||||
|
||||
n := 10
|
||||
for i := 0; i < n; i++ {
|
||||
mw.Hijack()
|
||||
_, _, err := mw.Hijack()
|
||||
require.NoError(t, err)
|
||||
}
|
||||
require.Equal(t, n, thh.hijackCalledN)
|
||||
require.Equal(t, 1, tpg.incCalledN)
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestProxyDialer(t *testing.T) {
|
||||
l, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
require.NoError(t, err)
|
||||
go func() {
|
||||
l.Accept()
|
||||
_, _ = l.Accept()
|
||||
}()
|
||||
defer l.Close()
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -48,6 +48,7 @@ func TestWsConn(t testing.TB, ctx context.Context) (clientConn, proxyConn *webso
|
||||
time.Sleep(time.Duration(1.5 * float64(time.Second)))
|
||||
clientConn, _, err = websocket.Dial(ctx, fmt.Sprintf("ws://%s", l.Addr().String()), nil)
|
||||
require.NoError(err)
|
||||
t.Cleanup(func() { _ = clientConn.Close(websocket.StatusGoingAway, "done") })
|
||||
wg.Wait()
|
||||
return
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (s *sess) GetLocalConnections() map[string]ConnInfo {
|
||||
return res
|
||||
}
|
||||
|
||||
// Return local tofu token, if availble; otherwise return the tofu token from the resp
|
||||
// Return local tofu token, if available; otherwise return the tofu token from the resp
|
||||
func (s *sess) GetTofuToken() string {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
@@ -352,7 +352,9 @@ func (s *sess) RequestConnectConnection(ctx context.Context, info *pbs.ConnectCo
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.ApplyLocalConnectionStatus(info.GetConnectionId(), st)
|
||||
if err := s.ApplyLocalConnectionStatus(info.GetConnectionId(), st); err != nil {
|
||||
return fmt.Errorf("error applying local connection status: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ func NewTestMultihopWorkers(t testing.TB,
|
||||
}
|
||||
|
||||
// NewAuthorizedPkiTestWorker creates a new test worker with the provided upstreams
|
||||
// and creates it in the provided repo as an authroized worker. It returns
|
||||
// and creates it in the provided repo as an authorized worker. It returns
|
||||
// The TestWorker and it's boundary id.
|
||||
func NewAuthorizedPkiTestWorker(t *testing.T, repo *server.Repository, name string, upstreams []string) (*TestWorker, string) {
|
||||
t.Helper()
|
||||
|
||||
Reference in new issue
Block a user