Rename package servers to server (#2222)
This commit is contained in:
79 files changed
+608
-604
No files matched your search
+5
-2
@@ -46,6 +46,9 @@ core/authtoken:
|
||||
core/cmd:
|
||||
- internal/cmd/**/8
|
||||
|
||||
core/daemon:
|
||||
- internal/daemon/**/*
|
||||
|
||||
core/db:
|
||||
- internal/db/**/*
|
||||
|
||||
@@ -76,8 +79,8 @@ core/proto:
|
||||
core/proxy:
|
||||
- internal/proxy/**/*
|
||||
|
||||
core/servers:
|
||||
- internal/servers/**/*
|
||||
core/server:
|
||||
- internal/server/**/*
|
||||
|
||||
core/session:
|
||||
- internal/session/**/*
|
||||
|
||||
@@ -148,10 +148,10 @@ protobuild:
|
||||
@protoc-go-inject-tag -input=./internal/kms/store/token_key.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/kms/store/session_key.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/kms/store/oidc_key.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/servers/store/controller.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/servers/store/worker.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/servers/store/root_certificate.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/servers/store/worker_auth.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/server/store/controller.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/server/store/worker.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/server/store/root_certificate.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/server/store/worker_auth.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/target/store/target.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/target/targettest/store/target.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/target/tcp/store/target.pb.go
|
||||
@@ -160,7 +160,7 @@ protobuild:
|
||||
@protoc-go-inject-tag -input=./internal/credential/store/credential.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/credential/vault/store/vault.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/credential/static/store/static.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/servers/servers.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/server/servers.pb.go
|
||||
@protoc-go-inject-tag -input=./internal/kms/store/audit_key.pb.go
|
||||
|
||||
# inject classification tags (see: https://github.com/hashicorp/go-eventlogger/tree/main/filters/encrypt)
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
authmethodsservice "github.com/hashicorp/boundary/internal/daemon/controller/handlers/authmethods"
|
||||
authpb "github.com/hashicorp/boundary/internal/gen/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
@@ -37,7 +37,7 @@ func TestFetchActionSetForId(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return tc.IamRepo(), nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return tc.ServersRepo(), nil
|
||||
}
|
||||
authTokenRepoFn := func() (*authtoken.Repository, error) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
berrors "github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
kms_plugin_assets "github.com/hashicorp/boundary/plugins/kms"
|
||||
plgpb "github.com/hashicorp/boundary/sdk/pbs/plugin"
|
||||
@@ -51,9 +51,9 @@ const (
|
||||
// defaultStatusGracePeriod is the default status grace period, or the period
|
||||
// of time that we will go without a status report before we start
|
||||
// disconnecting and marking connections as closed. This is tied to the
|
||||
// server default liveness setting, a related value. See the servers package
|
||||
// server default liveness setting, a related value. See the server package
|
||||
// for more details.
|
||||
defaultStatusGracePeriod = servers.DefaultLiveness
|
||||
defaultStatusGracePeriod = server.DefaultLiveness
|
||||
|
||||
// statusGracePeriodEnvVar is the environment variable that can be used to
|
||||
// configure the status grace period. This setting is provided in seconds,
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/go-secure-stdlib/parseutil"
|
||||
@@ -845,14 +845,14 @@ func authorizeWorker(ctx context.Context, c *controller.Controller, request stri
|
||||
|
||||
serversRepo, err := c.ServersRepoFn()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error fetching servers repo: %w", err)
|
||||
return fmt.Errorf("error fetching server repo: %w", err)
|
||||
}
|
||||
|
||||
_, err = serversRepo.CreateWorker(ctx, &servers.Worker{
|
||||
_, err = serversRepo.CreateWorker(ctx, &server.Worker{
|
||||
Worker: &store.Worker{
|
||||
ScopeId: scope.Global.String(),
|
||||
},
|
||||
}, servers.WithFetchNodeCredentialsRequest(req))
|
||||
}, server.WithFetchNodeCredentialsRequest(req))
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating worker: %w", err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
|
||||
@@ -76,31 +76,31 @@ func (ws *workerServiceServer) Status(ctx context.Context, req *pbs.StatusReques
|
||||
|
||||
serverRepo, err := ws.serversRepoFn()
|
||||
if err != nil {
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("error getting servers repo"))
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("error getting server repo"))
|
||||
return &pbs.StatusResponse{}, status.Errorf(codes.Internal, "Error acquiring repo to store worker status: %v", err)
|
||||
}
|
||||
|
||||
// Convert API tags to storage tags
|
||||
wTags := wStat.GetTags()
|
||||
workerTags := make([]*servers.Tag, 0, len(wTags))
|
||||
workerTags := make([]*server.Tag, 0, len(wTags))
|
||||
for _, v := range wTags {
|
||||
workerTags = append(workerTags, &servers.Tag{
|
||||
workerTags = append(workerTags, &server.Tag{
|
||||
Key: v.GetKey(),
|
||||
Value: v.GetValue(),
|
||||
})
|
||||
}
|
||||
|
||||
wConf := servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(wStat.GetName()),
|
||||
servers.WithDescription(wStat.GetDescription()),
|
||||
servers.WithAddress(wStat.GetAddress()),
|
||||
servers.WithWorkerTags(workerTags...))
|
||||
opts := []servers.Option{servers.WithUpdateTags(req.GetUpdateTags())}
|
||||
wConf := server.NewWorker(scope.Global.String(),
|
||||
server.WithName(wStat.GetName()),
|
||||
server.WithDescription(wStat.GetDescription()),
|
||||
server.WithAddress(wStat.GetAddress()),
|
||||
server.WithWorkerTags(workerTags...))
|
||||
opts := []server.Option{server.WithUpdateTags(req.GetUpdateTags())}
|
||||
if wStat.GetPublicId() != "" {
|
||||
opts = append(opts, servers.WithPublicId(wStat.GetPublicId()))
|
||||
opts = append(opts, server.WithPublicId(wStat.GetPublicId()))
|
||||
}
|
||||
if wStat.GetKeyId() != "" {
|
||||
opts = append(opts, servers.WithKeyId(wStat.GetKeyId()))
|
||||
opts = append(opts, server.WithKeyId(wStat.GetKeyId()))
|
||||
}
|
||||
wrk, err := serverRepo.UpsertWorkerStatus(ctx, wConf, opts...)
|
||||
if err != nil {
|
||||
@@ -227,7 +227,7 @@ func (ws *workerServiceServer) LookupSession(ctx context.Context, req *pbs.Looku
|
||||
}
|
||||
serversRepo, err := ws.serversRepoFn()
|
||||
if err != nil {
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("error getting servers repo"))
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("error getting server repo"))
|
||||
return &pbs.LookupSessionResponse{}, status.Errorf(codes.Internal, "Error acquiring server repo when looking up session: %v", err)
|
||||
}
|
||||
w, err := serversRepo.LookupWorker(ctx, req.WorkerId)
|
||||
@@ -375,7 +375,7 @@ func (ws *workerServiceServer) AuthorizeConnection(ctx context.Context, req *pbs
|
||||
|
||||
serversRepo, err := ws.serversRepoFn()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "error getting servers repo: %v", err)
|
||||
return nil, status.Errorf(codes.Internal, "error getting server repo: %v", err)
|
||||
}
|
||||
w, err := serversRepo.LookupWorker(ctx, req.GetWorkerId())
|
||||
if err != nil {
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
@@ -38,12 +38,12 @@ func TestStatus(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := servers.NewRepository(rw, rw, kms)
|
||||
serverRepo, _ := server.NewRepository(rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serverRepo, nil
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
@@ -71,7 +71,7 @@ func TestStatus(t *testing.T) {
|
||||
target.WithSessionConnectionLimit(-1),
|
||||
)
|
||||
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
@@ -105,7 +105,7 @@ func TestStatus(t *testing.T) {
|
||||
name: "No Sessions",
|
||||
wantErr: false,
|
||||
req: &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
PublicId: worker1.GetPublicId(),
|
||||
Name: worker1.GetName(),
|
||||
Address: worker1.GetAddress(),
|
||||
@@ -125,7 +125,7 @@ func TestStatus(t *testing.T) {
|
||||
name: "Still Active",
|
||||
wantErr: false,
|
||||
req: &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
PublicId: worker1.GetPublicId(),
|
||||
Name: worker1.GetName(),
|
||||
Address: worker1.GetAddress(),
|
||||
@@ -164,7 +164,7 @@ func TestStatus(t *testing.T) {
|
||||
name: "No Name or keyId",
|
||||
wantErr: true,
|
||||
req: &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
PublicId: worker1.GetPublicId(),
|
||||
Address: worker1.GetAddress(),
|
||||
},
|
||||
@@ -175,7 +175,7 @@ func TestStatus(t *testing.T) {
|
||||
name: "No Address",
|
||||
wantErr: true,
|
||||
req: &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
PublicId: worker1.GetPublicId(),
|
||||
Name: worker1.GetName(),
|
||||
},
|
||||
@@ -201,7 +201,7 @@ func TestStatus(t *testing.T) {
|
||||
got,
|
||||
cmpopts.IgnoreUnexported(
|
||||
pbs.StatusResponse{},
|
||||
servers.ServerWorkerStatus{},
|
||||
server.ServerWorkerStatus{},
|
||||
pbs.UpstreamServer{},
|
||||
pbs.JobChangeRequest{},
|
||||
pbs.Job{},
|
||||
@@ -209,7 +209,7 @@ func TestStatus(t *testing.T) {
|
||||
pbs.SessionJobInfo{},
|
||||
pbs.Connection{},
|
||||
),
|
||||
cmpopts.IgnoreFields(servers.ServerWorkerStatus{}, "Tags"),
|
||||
cmpopts.IgnoreFields(server.ServerWorkerStatus{}, "Tags"),
|
||||
),
|
||||
)
|
||||
})
|
||||
@@ -224,12 +224,12 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := servers.NewRepository(rw, rw, kms)
|
||||
serverRepo, _ := server.NewRepository(rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serverRepo, nil
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
@@ -257,7 +257,7 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
target.WithSessionConnectionLimit(-1),
|
||||
)
|
||||
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
@@ -308,7 +308,7 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
},
|
||||
req: &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
PublicId: worker1.GetPublicId(),
|
||||
Name: worker1.GetName(),
|
||||
Address: worker1.GetAddress(),
|
||||
@@ -379,7 +379,7 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
got,
|
||||
cmpopts.IgnoreUnexported(
|
||||
pbs.StatusResponse{},
|
||||
servers.ServerWorkerStatus{},
|
||||
server.ServerWorkerStatus{},
|
||||
pbs.UpstreamServer{},
|
||||
pbs.JobChangeRequest{},
|
||||
pbs.Job{},
|
||||
@@ -387,7 +387,7 @@ func TestStatusSessionClosed(t *testing.T) {
|
||||
pbs.SessionJobInfo{},
|
||||
pbs.Connection{},
|
||||
),
|
||||
cmpopts.IgnoreFields(servers.ServerWorkerStatus{}, "Tags"),
|
||||
cmpopts.IgnoreFields(server.ServerWorkerStatus{}, "Tags"),
|
||||
),
|
||||
)
|
||||
})
|
||||
@@ -402,15 +402,15 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := servers.NewRepository(rw, rw, kms)
|
||||
serverRepo, _ := server.NewRepository(rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serverRepo, nil
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
@@ -475,7 +475,7 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
require.NotEqual(t, deadConn.PublicId, connection.PublicId)
|
||||
|
||||
req := &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
PublicId: worker1.GetPublicId(),
|
||||
Name: worker1.GetName(),
|
||||
Address: worker1.GetAddress(),
|
||||
@@ -517,7 +517,7 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
got,
|
||||
cmpopts.IgnoreUnexported(
|
||||
pbs.StatusResponse{},
|
||||
servers.ServerWorkerStatus{},
|
||||
server.ServerWorkerStatus{},
|
||||
pbs.UpstreamServer{},
|
||||
pbs.JobChangeRequest{},
|
||||
pbs.Job{},
|
||||
@@ -525,7 +525,7 @@ func TestStatusDeadConnection(t *testing.T) {
|
||||
pbs.SessionJobInfo{},
|
||||
pbs.Connection{},
|
||||
),
|
||||
cmpopts.IgnoreFields(servers.ServerWorkerStatus{}, "Tags"),
|
||||
cmpopts.IgnoreFields(server.ServerWorkerStatus{}, "Tags"),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -545,12 +545,12 @@ func TestStatusWorkerWithKeyId(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := servers.NewRepository(rw, rw, kms)
|
||||
serverRepo, _ := server.NewRepository(rw, rw, kms)
|
||||
serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
})
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serverRepo, nil
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
@@ -578,16 +578,16 @@ func TestStatusWorkerWithKeyId(t *testing.T) {
|
||||
target.WithSessionConnectionLimit(-1),
|
||||
)
|
||||
|
||||
worker1 := servers.TestPkiWorker(t, conn, wrapper)
|
||||
worker1 := server.TestPkiWorker(t, conn, wrapper)
|
||||
|
||||
rootStorage, err := servers.NewRepositoryStorage(ctx, rw, rw, kms)
|
||||
rootStorage, err := server.NewRepositoryStorage(ctx, rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = rotation.RotateRootCertificates(ctx, rootStorage)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create struct to pass in with workerId that will be passed along to storage
|
||||
state, err := servers.AttachWorkerIdToState(ctx, worker1.PublicId)
|
||||
state, err := server.AttachWorkerIdToState(ctx, worker1.PublicId)
|
||||
require.NoError(t, err)
|
||||
|
||||
// This happens on the worker
|
||||
@@ -635,7 +635,7 @@ func TestStatusWorkerWithKeyId(t *testing.T) {
|
||||
name: "Identify workerID based on keyId in status",
|
||||
wantErr: false,
|
||||
req: &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
Address: "someaddress",
|
||||
KeyId: nodeInfo.Id,
|
||||
},
|
||||
@@ -654,7 +654,7 @@ func TestStatusWorkerWithKeyId(t *testing.T) {
|
||||
name: "Active keyId Worker",
|
||||
wantErr: false,
|
||||
req: &pbs.StatusRequest{
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
KeyId: nodeInfo.Id,
|
||||
Address: "someaddress",
|
||||
},
|
||||
@@ -708,7 +708,7 @@ func TestStatusWorkerWithKeyId(t *testing.T) {
|
||||
got,
|
||||
cmpopts.IgnoreUnexported(
|
||||
pbs.StatusResponse{},
|
||||
servers.ServerWorkerStatus{},
|
||||
server.ServerWorkerStatus{},
|
||||
pbs.UpstreamServer{},
|
||||
pbs.JobChangeRequest{},
|
||||
pbs.Job{},
|
||||
@@ -716,7 +716,7 @@ func TestStatusWorkerWithKeyId(t *testing.T) {
|
||||
pbs.SessionJobInfo{},
|
||||
pbs.Connection{},
|
||||
),
|
||||
cmpopts.IgnoreFields(servers.ServerWorkerStatus{}, "Tags"),
|
||||
cmpopts.IgnoreFields(server.ServerWorkerStatus{}, "Tags"),
|
||||
),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
@@ -31,8 +31,8 @@ func TestLookupSession(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
return session.NewRepository(rw, rw, kms)
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
@@ -418,11 +418,11 @@ func (v *verifier) decryptToken(ctx context.Context) {
|
||||
}
|
||||
repo, err := v.serversRepoFn()
|
||||
if err != nil {
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("decrypt recovery token: error fetching servers repo"))
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("decrypt recovery token: error fetching server repo"))
|
||||
v.requestInfo.TokenFormat = uint32(AuthTokenTypeUnknown)
|
||||
return
|
||||
}
|
||||
if err := repo.AddNonce(v.ctx, info.Nonce, servers.NoncePurposeRecovery); err != nil {
|
||||
if err := repo.AddNonce(v.ctx, info.Nonce, server.NoncePurposeRecovery); err != nil {
|
||||
event.WriteError(ctx, op, err, event.WithInfoMsg("decrypt recovery token: error adding nonce to database (possible replay attack)"))
|
||||
v.requestInfo.TokenFormat = uint32(AuthTokenTypeUnknown)
|
||||
return
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/tests/api"
|
||||
"github.com/hashicorp/eventlogger/filters/encrypt"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
@@ -38,8 +38,8 @@ func TestAuthTokenAuthenticator(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
o, _ := iam.TestScopes(t, iamRepo)
|
||||
@@ -161,8 +161,8 @@ func TestVerify_AuditEvent(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, testKms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, testKms)
|
||||
}
|
||||
|
||||
o, _ := iam.TestScopes(t, iamRepo)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
)
|
||||
@@ -21,12 +21,12 @@ type (
|
||||
IamRepoFactory func() (*iam.Repository, error)
|
||||
OidcAuthRepoFactory = oidc.OidcRepoFactory
|
||||
PasswordAuthRepoFactory func() (*password.Repository, error)
|
||||
ServersRepoFactory func() (*servers.Repository, error)
|
||||
ServersRepoFactory func() (*server.Repository, error)
|
||||
StaticRepoFactory func() (*static.Repository, error)
|
||||
PluginHostRepoFactory func() (*pluginhost.Repository, error)
|
||||
HostPluginRepoFactory func() (*hostplugin.Repository, error)
|
||||
SessionRepoFactory func() (*session.Repository, error)
|
||||
ConnectionRepoFactory func() (*session.ConnectionRepository, error)
|
||||
TargetRepoFactory func() (*target.Repository, error)
|
||||
WorkerAuthRepoStorageFactory func() (*servers.WorkerAuthRepositoryStorage, error)
|
||||
WorkerAuthRepoStorageFactory func() (*server.WorkerAuthRepositoryStorage, error)
|
||||
)
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
authpb "github.com/hashicorp/boundary/internal/gen/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -38,8 +38,8 @@ func TestListingScopeIds(t *testing.T) {
|
||||
authTokenRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authtoken.NewRepository(rw, rw, kms)
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
s, err := groups.NewService(iamRepoFn)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -27,8 +27,8 @@ import (
|
||||
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/scheduler/job"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
serversjob "github.com/hashicorp/boundary/internal/servers/job"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
serversjob "github.com/hashicorp/boundary/internal/server/job"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
@@ -283,8 +283,8 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
|
||||
c.StaticCredentialRepoFn = func() (*credstatic.Repository, error) {
|
||||
return credstatic.NewRepository(ctx, dbase, dbase, c.kms)
|
||||
}
|
||||
c.ServersRepoFn = func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(dbase, dbase, c.kms)
|
||||
c.ServersRepoFn = func() (*server.Repository, error) {
|
||||
return server.NewRepository(dbase, dbase, c.kms)
|
||||
}
|
||||
c.OidcRepoFn = func() (*oidc.Repository, error) {
|
||||
return oidc.NewRepository(ctx, dbase, dbase, c.kms)
|
||||
@@ -301,17 +301,17 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
|
||||
c.ConnectionRepoFn = func() (*session.ConnectionRepository, error) {
|
||||
return session.NewConnectionRepository(ctx, dbase, dbase, c.kms)
|
||||
}
|
||||
c.WorkerAuthRepoStorageFn = func() (*servers.WorkerAuthRepositoryStorage, error) {
|
||||
return servers.NewRepositoryStorage(ctx, dbase, dbase, c.kms)
|
||||
c.WorkerAuthRepoStorageFn = func() (*server.WorkerAuthRepositoryStorage, error) {
|
||||
return server.NewRepositoryStorage(ctx, dbase, dbase, c.kms)
|
||||
}
|
||||
|
||||
// Check that credentials are available at startup, to avoid some harmless
|
||||
// but nasty-looking errors
|
||||
serversRepo, err := servers.NewRepositoryStorage(ctx, dbase, dbase, c.kms)
|
||||
serversRepo, err := server.NewRepositoryStorage(ctx, dbase, dbase, c.kms)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to instantiate worker auth repository: %w", err)
|
||||
}
|
||||
err = servers.RotateRoots(ctx, serversRepo)
|
||||
err = server.RotateRoots(ctx, serversRepo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to ensure worker auth roots exist: %w", err)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/authmethods"
|
||||
scopepb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -151,8 +151,8 @@ func TestList_FilterNonPublic(t *testing.T) {
|
||||
atRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authtoken.NewRepository(rw, rw, kmsCache)
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kmsCache)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kmsCache)
|
||||
}
|
||||
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/authtokens"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -43,8 +43,8 @@ func TestGetSelf(t *testing.T) {
|
||||
tokenRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authtoken.NewRepository(rw, rw, kms)
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
a, err := authtokens.NewService(tokenRepoFn, iamRepoFn)
|
||||
@@ -202,8 +202,8 @@ func TestList_Self(t *testing.T) {
|
||||
tokenRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authtoken.NewRepository(rw, rw, kms)
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
// This will result in the scope having default permissions, which now
|
||||
@@ -426,8 +426,8 @@ func TestDeleteSelf(t *testing.T) {
|
||||
tokenRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authtoken.NewRepository(rw, rw, kms)
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
a, err := authtokens.NewService(tokenRepoFn, iamRepoFn)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
authpb "github.com/hashicorp/boundary/internal/gen/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/testing/dbtest"
|
||||
@@ -93,7 +93,7 @@ func BenchmarkSessionList(b *testing.B) {
|
||||
pwRepo, err := password.NewRepository(rw, rw, kmsThing)
|
||||
require.NoError(b, err)
|
||||
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kmsThing)
|
||||
serversRepo, err := server.NewRepository(rw, rw, kmsThing)
|
||||
require.NoError(b, err)
|
||||
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
@@ -105,7 +105,7 @@ func BenchmarkSessionList(b *testing.B) {
|
||||
authTokenRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authTokenRepo, nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return serversRepo, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
@@ -162,8 +162,8 @@ func TestList_Self(t *testing.T) {
|
||||
tokenRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authtoken.NewRepository(rw, rw, kms)
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
o, pWithSessions := iam.TestScopes(t, iamRepo)
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
@@ -115,7 +115,7 @@ func NewService(
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing iam repository")
|
||||
}
|
||||
if serversRepoFn == nil {
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing servers repository")
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing server repository")
|
||||
}
|
||||
if sessionRepoFn == nil {
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing session repository")
|
||||
@@ -1918,7 +1918,7 @@ func validateAuthorizeSessionRequest(req *pbs.AuthorizeSessionRequest) error {
|
||||
}
|
||||
|
||||
// workerList is a helper type to make the selection of workers clearer and more declarative.
|
||||
type workerList []*servers.Worker
|
||||
type workerList []*server.Worker
|
||||
|
||||
// addresses converts the slice of workers to a slice of their addresses
|
||||
func (w workerList) addresses() []string {
|
||||
@@ -1941,7 +1941,7 @@ func (w workerList) workerInfos() []*pb.WorkerInfo {
|
||||
// filtered returns a new workerList where all elements contained in it are the
|
||||
// ones which from the original workerList that pass the evaluator's evaluation.
|
||||
func (w workerList) filtered(eval *bexpr.Evaluator) (workerList, error) {
|
||||
var ret []*servers.Worker
|
||||
var ret []*server.Worker
|
||||
for _, worker := range w {
|
||||
filterInput := map[string]interface{}{
|
||||
"name": worker.GetName(),
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
|
||||
"github.com/hashicorp/go-bexpr"
|
||||
@@ -24,9 +24,9 @@ func TestWorkerList_Addresses(t *testing.T) {
|
||||
var tested workerList
|
||||
for _, a := range addresses {
|
||||
workerInfos = append(workerInfos, &pb.WorkerInfo{Address: a})
|
||||
tested = append(tested, servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(a),
|
||||
servers.WithAddress(a)))
|
||||
tested = append(tested, server.NewWorker(scope.Global.String(),
|
||||
server.WithName(a),
|
||||
server.WithAddress(a)))
|
||||
}
|
||||
assert.Equal(t, addresses, tested.addresses())
|
||||
assert.Equal(t, workerInfos, tested.workerInfos())
|
||||
@@ -35,20 +35,20 @@ func TestWorkerList_Addresses(t *testing.T) {
|
||||
func TestWorkerList_Filter(t *testing.T) {
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
wrapper := db.TestWrapper(t)
|
||||
var workers []*servers.Worker
|
||||
var workers []*server.Worker
|
||||
for i := 0; i < 5; i++ {
|
||||
switch {
|
||||
case i%2 == 0:
|
||||
workers = append(workers, servers.TestKmsWorker(t, conn, wrapper,
|
||||
servers.WithName(fmt.Sprintf("test_worker_%d", i)),
|
||||
servers.WithWorkerTags(&servers.Tag{
|
||||
workers = append(workers, server.TestKmsWorker(t, conn, wrapper,
|
||||
server.WithName(fmt.Sprintf("test_worker_%d", i)),
|
||||
server.WithWorkerTags(&server.Tag{
|
||||
Key: fmt.Sprintf("key%d", i),
|
||||
Value: fmt.Sprintf("value%d", i),
|
||||
})))
|
||||
default:
|
||||
workers = append(workers, servers.TestPkiWorker(t, conn, wrapper,
|
||||
servers.WithName(fmt.Sprintf("test_worker_%d", i)),
|
||||
servers.WithWorkerTags(&servers.Tag{
|
||||
workers = append(workers, server.TestPkiWorker(t, conn, wrapper,
|
||||
server.WithName(fmt.Sprintf("test_worker_%d", i)),
|
||||
server.WithWorkerTags(&server.Tag{
|
||||
Key: "key",
|
||||
Value: "configvalue",
|
||||
})))
|
||||
|
||||
@@ -33,8 +33,8 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/host"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
spb "github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
spb "github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
@@ -85,8 +85,8 @@ func testService(t *testing.T, ctx context.Context, conn *db.DB, kms *kms.Kms, w
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iam.TestRepo(t, conn, wrapper), nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
return session.NewRepository(rw, rw, kms)
|
||||
@@ -2365,8 +2365,8 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
return session.NewRepository(rw, rw, kms)
|
||||
@@ -2529,7 +2529,7 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Tell our DB that there is a worker ready to serve the data
|
||||
servers.TestKmsWorker(t, conn, wrapper)
|
||||
server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
asRes1, err := s.AuthorizeSession(ctx, &pbs.AuthorizeSessionRequest{
|
||||
Id: tar.GetPublicId(),
|
||||
@@ -2625,8 +2625,8 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
return session.NewRepository(rw, rw, kms)
|
||||
@@ -2874,7 +2874,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Tell our DB that there is a worker ready to serve the data
|
||||
servers.TestKmsWorker(t, conn, wrapper)
|
||||
server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
asRes, err := s.AuthorizeSession(ctx, &pbs.AuthorizeSessionRequest{
|
||||
Id: tar.GetPublicId(),
|
||||
@@ -2931,8 +2931,8 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
sessionRepoFn := func() (*session.Repository, error) {
|
||||
return session.NewRepository(rw, rw, kms)
|
||||
@@ -3164,8 +3164,8 @@ func TestAddTargetCredentialLibraryPerms(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iam.TestRepo(t, conn, wrapper), nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
@@ -3250,8 +3250,8 @@ func TestSetTargetCredentialLibraryPerms(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iam.TestRepo(t, conn, wrapper), nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
@@ -3336,8 +3336,8 @@ func TestRemoveTargetCredentialLibraryPerms(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iam.TestRepo(t, conn, wrapper), nil
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
@@ -73,7 +73,7 @@ type Service struct {
|
||||
func NewService(ctx context.Context, repo common.ServersRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) {
|
||||
const op = "workers.NewService"
|
||||
if repo == nil {
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing servers repository")
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing server repository")
|
||||
}
|
||||
if iamRepoFn == nil {
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing iam repository")
|
||||
@@ -297,19 +297,19 @@ func (s Service) UpdateWorker(ctx context.Context, req *pbs.UpdateWorkerRequest)
|
||||
return &pbs.UpdateWorkerResponse{Item: item}, nil
|
||||
}
|
||||
|
||||
func (s Service) listFromRepo(ctx context.Context, scopeIds []string) ([]*servers.Worker, error) {
|
||||
func (s Service) listFromRepo(ctx context.Context, scopeIds []string) ([]*server.Worker, error) {
|
||||
repo, err := s.repoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
wl, err := repo.ListWorkers(ctx, scopeIds, servers.WithLiveness(-1))
|
||||
wl, err := repo.ListWorkers(ctx, scopeIds, server.WithLiveness(-1))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return wl, nil
|
||||
}
|
||||
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (*servers.Worker, error) {
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (*server.Worker, error) {
|
||||
repo, err := s.repoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -327,18 +327,18 @@ func (s Service) getFromRepo(ctx context.Context, id string) (*servers.Worker, e
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func (s Service) createInRepo(ctx context.Context, worker *pb.Worker, creds *types.FetchNodeCredentialsRequest) (*servers.Worker, error) {
|
||||
func (s Service) createInRepo(ctx context.Context, worker *pb.Worker, creds *types.FetchNodeCredentialsRequest) (*server.Worker, error) {
|
||||
const op = "workers.(Service).createInRepo"
|
||||
repo, err := s.repoFn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newWorker := servers.NewWorker(
|
||||
newWorker := server.NewWorker(
|
||||
worker.GetScopeId(),
|
||||
servers.WithName(worker.GetName().GetValue()),
|
||||
servers.WithDescription(worker.GetDescription().GetValue()),
|
||||
server.WithName(worker.GetName().GetValue()),
|
||||
server.WithDescription(worker.GetDescription().GetValue()),
|
||||
)
|
||||
retWorker, err := repo.CreateWorker(ctx, newWorker, servers.WithFetchNodeCredentialsRequest(creds))
|
||||
retWorker, err := repo.CreateWorker(ctx, newWorker, server.WithFetchNodeCredentialsRequest(creds))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to create worker"))
|
||||
}
|
||||
@@ -361,16 +361,16 @@ func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
|
||||
return rows > 0, nil
|
||||
}
|
||||
|
||||
func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []string, item *pb.Worker) (*servers.Worker, error) {
|
||||
func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []string, item *pb.Worker) (*server.Worker, error) {
|
||||
const op = "workers.(Service).updateInRepo"
|
||||
var opts []servers.Option
|
||||
var opts []server.Option
|
||||
if desc := item.GetDescription(); desc != nil {
|
||||
opts = append(opts, servers.WithDescription(desc.GetValue()))
|
||||
opts = append(opts, server.WithDescription(desc.GetValue()))
|
||||
}
|
||||
if name := item.GetName(); name != nil {
|
||||
opts = append(opts, servers.WithName(name.GetValue()))
|
||||
opts = append(opts, server.WithName(name.GetValue()))
|
||||
}
|
||||
w := servers.NewWorker(scopeId, opts...)
|
||||
w := server.NewWorker(scopeId, opts...)
|
||||
w.PublicId = id
|
||||
dbMask := maskManager.Translate(mask)
|
||||
if len(dbMask) == 0 {
|
||||
@@ -420,7 +420,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
return auth.Verify(ctx, opts...)
|
||||
}
|
||||
|
||||
func toProto(ctx context.Context, in *servers.Worker, opt ...handlers.Option) (*pb.Worker, error) {
|
||||
func toProto(ctx context.Context, in *server.Worker, opt ...handlers.Option) (*pb.Worker, error) {
|
||||
const op = "workers.toProto"
|
||||
opts := handlers.GetOpts(opt...)
|
||||
if opts.WithOutputFields == nil {
|
||||
@@ -522,7 +522,7 @@ func tagsToMapProto(in map[string][]string) (map[string]*structpb.ListValue, err
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetWorkerRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, servers.WorkerPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, server.WorkerPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListWorkersRequest) error {
|
||||
@@ -540,7 +540,7 @@ func validateListRequest(req *pbs.ListWorkersRequest) error {
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteWorkerRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, servers.WorkerPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, server.WorkerPrefix)
|
||||
}
|
||||
|
||||
func validateUpdateRequest(req *pbs.UpdateWorkerRequest) error {
|
||||
@@ -567,7 +567,7 @@ func validateUpdateRequest(req *pbs.UpdateWorkerRequest) error {
|
||||
badFields[globals.DescriptionField] = "Contains non-printable characters."
|
||||
}
|
||||
return badFields
|
||||
}, servers.WorkerPrefix)
|
||||
}, server.WorkerPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateWorkerLedRequest) error {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -59,17 +59,17 @@ func TestGet(t *testing.T) {
|
||||
}
|
||||
rw := db.New(conn)
|
||||
kms := kms.TestKms(t, conn, wrap)
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
kmsWorker := servers.TestKmsWorker(t, conn, wrap,
|
||||
servers.WithName("test kms worker names"),
|
||||
servers.WithDescription("test kms worker description"),
|
||||
servers.WithAddress("test kms worker address"),
|
||||
servers.WithWorkerTags(&servers.Tag{Key: "key", Value: "val"}))
|
||||
kmsWorker := server.TestKmsWorker(t, conn, wrap,
|
||||
server.WithName("test kms worker names"),
|
||||
server.WithDescription("test kms worker description"),
|
||||
server.WithAddress("test kms worker address"),
|
||||
server.WithWorkerTags(&server.Tag{Key: "key", Value: "val"}))
|
||||
|
||||
kmsAuthzActions := make([]string, len(testAuthorizedActions))
|
||||
copy(kmsAuthzActions, testAuthorizedActions)
|
||||
@@ -97,21 +97,21 @@ func TestGet(t *testing.T) {
|
||||
}
|
||||
|
||||
var pkiWorkerKeyId string
|
||||
pkiWorker := servers.TestPkiWorker(t, conn, wrap,
|
||||
servers.WithName("test pki worker names"),
|
||||
servers.WithDescription("test pki worker description"),
|
||||
servers.WithTestPkiWorkerAuthorizedKeyId(&pkiWorkerKeyId))
|
||||
pkiWorker := server.TestPkiWorker(t, conn, wrap,
|
||||
server.WithName("test pki worker names"),
|
||||
server.WithDescription("test pki worker description"),
|
||||
server.WithTestPkiWorkerAuthorizedKeyId(&pkiWorkerKeyId))
|
||||
// Add config tags to the created worker
|
||||
pkiWorker, err = repo.UpsertWorkerStatus(context.Background(),
|
||||
servers.NewWorker(pkiWorker.GetScopeId(),
|
||||
servers.WithAddress("test kms worker address"),
|
||||
servers.WithWorkerTags(&servers.Tag{
|
||||
server.NewWorker(pkiWorker.GetScopeId(),
|
||||
server.WithAddress("test kms worker address"),
|
||||
server.WithWorkerTags(&server.Tag{
|
||||
Key: "config",
|
||||
Value: "test",
|
||||
})),
|
||||
servers.WithUpdateTags(true),
|
||||
servers.WithPublicId(pkiWorker.GetPublicId()),
|
||||
servers.WithKeyId(pkiWorkerKeyId))
|
||||
server.WithUpdateTags(true),
|
||||
server.WithPublicId(pkiWorker.GetPublicId()),
|
||||
server.WithKeyId(pkiWorkerKeyId))
|
||||
require.NoError(t, err)
|
||||
|
||||
wantPkiWorker := &pb.Worker{
|
||||
@@ -157,7 +157,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non-existent Worker",
|
||||
req: &pbs.GetWorkerRequest{Id: servers.WorkerPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetWorkerRequest{Id: server.WorkerPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -169,7 +169,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Space in id",
|
||||
req: &pbs.GetWorkerRequest{Id: servers.WorkerPrefix + "_1 23456789"},
|
||||
req: &pbs.GetWorkerRequest{Id: server.WorkerPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -200,13 +200,13 @@ func TestList(t *testing.T) {
|
||||
}
|
||||
rw := db.New(conn)
|
||||
kms := kms.TestKms(t, conn, wrap)
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
|
||||
var wantKmsWorkers []*pb.Worker
|
||||
for i := 0; i < 10; i++ {
|
||||
w := servers.TestKmsWorker(t, conn, wrap, servers.WithName(fmt.Sprintf("kms-worker%d", i)))
|
||||
w := server.TestKmsWorker(t, conn, wrap, server.WithName(fmt.Sprintf("kms-worker%d", i)))
|
||||
kmsAuthzActions := make([]string, len(testAuthorizedActions))
|
||||
copy(kmsAuthzActions, testAuthorizedActions)
|
||||
wantKmsWorkers = append(wantKmsWorkers, &pb.Worker{
|
||||
@@ -227,7 +227,7 @@ func TestList(t *testing.T) {
|
||||
|
||||
var wantPkiWorkers []*pb.Worker
|
||||
for i := 0; i < 10; i++ {
|
||||
w := servers.TestPkiWorker(t, conn, wrap, servers.WithName(fmt.Sprintf("pki-worker%d", i)))
|
||||
w := server.TestPkiWorker(t, conn, wrap, server.WithName(fmt.Sprintf("pki-worker%d", i)))
|
||||
wantPkiWorkers = append(wantPkiWorkers, &pb.Worker{
|
||||
Id: w.GetPublicId(),
|
||||
ScopeId: w.GetScopeId(),
|
||||
@@ -332,15 +332,15 @@ func TestDelete(t *testing.T) {
|
||||
}
|
||||
rw := db.New(conn)
|
||||
kms := kms.TestKms(t, conn, wrap)
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kms)
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kms)
|
||||
}
|
||||
ctx := context.Background()
|
||||
|
||||
s, err := NewService(ctx, repoFn, iamRepoFn)
|
||||
require.NoError(t, err, "Error when getting new worker service.")
|
||||
|
||||
w := servers.TestKmsWorker(t, conn, wrap)
|
||||
w := server.TestKmsWorker(t, conn, wrap)
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
@@ -360,7 +360,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Delete bad worker id",
|
||||
scopeId: w.GetScopeId(),
|
||||
req: &pbs.DeleteWorkerRequest{
|
||||
Id: servers.WorkerPrefix + "_doesntexis",
|
||||
Id: server.WorkerPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -398,15 +398,15 @@ func TestUpdate(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
wkr := servers.TestPkiWorker(t, conn, wrapper,
|
||||
servers.WithName("default"),
|
||||
servers.WithDescription("default"))
|
||||
wkr := server.TestPkiWorker(t, conn, wrapper,
|
||||
server.WithName("default"),
|
||||
server.WithDescription("default"))
|
||||
|
||||
version := wkr.GetVersion()
|
||||
|
||||
@@ -630,7 +630,7 @@ func TestUpdate(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Worker",
|
||||
req: &pbs.UpdateWorkerRequest{
|
||||
Id: servers.WorkerPrefix + "_DoesntExis",
|
||||
Id: server.WorkerPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
@@ -809,15 +809,15 @@ func TestUpdate_KMS(t *testing.T) {
|
||||
iamRepoFn := func() (*iam.Repository, error) {
|
||||
return iamRepo, nil
|
||||
}
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
wkr := servers.TestKmsWorker(t, conn, wrapper,
|
||||
servers.WithName("default"),
|
||||
servers.WithDescription("default"))
|
||||
wkr := server.TestKmsWorker(t, conn, wrapper,
|
||||
server.WithName("default"),
|
||||
server.WithDescription("default"))
|
||||
|
||||
toMerge := &pbs.UpdateWorkerRequest{
|
||||
Id: wkr.GetPublicId(),
|
||||
@@ -891,9 +891,9 @@ func TestUpdate_BadVersion(t *testing.T) {
|
||||
_, proj := iam.TestScopes(t, iamRepo)
|
||||
|
||||
rw := db.New(conn)
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err, "Couldn't create new worker repo.")
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return repo, nil
|
||||
}
|
||||
ctx := context.Background()
|
||||
@@ -901,7 +901,7 @@ func TestUpdate_BadVersion(t *testing.T) {
|
||||
workerService, err := NewService(ctx, repoFn, iamRepoFn)
|
||||
require.NoError(t, err, "Failed to create a new host set service.")
|
||||
|
||||
wkr := servers.TestPkiWorker(t, conn, wrapper)
|
||||
wkr := server.TestPkiWorker(t, conn, wrapper)
|
||||
|
||||
upTar, err := workerService.UpdateWorker(auth.DisabledAuthTestContext(iamRepoFn, proj.GetPublicId()), &pbs.UpdateWorkerRequest{
|
||||
Id: wkr.GetPublicId(),
|
||||
@@ -926,8 +926,8 @@ func TestCreateWorkerLed(t *testing.T) {
|
||||
}
|
||||
rw := db.New(conn)
|
||||
testKms := kms.TestKms(t, conn, testRootWrapper)
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, testKms)
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, testKms)
|
||||
}
|
||||
testCtx := context.Background()
|
||||
|
||||
@@ -935,7 +935,7 @@ func TestCreateWorkerLed(t *testing.T) {
|
||||
require.NoError(t, err, "Error when getting new worker service.")
|
||||
|
||||
// Get an initial set of authorized node credentials
|
||||
rootStorage, err := servers.NewRepositoryStorage(testCtx, rw, rw, testKms)
|
||||
rootStorage, err := server.NewRepositoryStorage(testCtx, rw, rw, testKms)
|
||||
require.NoError(t, err)
|
||||
_, err = rotation.RotateRootCertificates(testCtx, rootStorage)
|
||||
require.NoError(t, err)
|
||||
@@ -1180,8 +1180,8 @@ func TestCreateWorkerLed(t *testing.T) {
|
||||
{
|
||||
name: "create-error",
|
||||
service: func() Service {
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, &db.Db{}, testKms)
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, &db.Db{}, testKms)
|
||||
}
|
||||
testSrv, err := NewService(testCtx, repoFn, iamRepoFn)
|
||||
require.NoError(t, err, "Error when getting new worker service.")
|
||||
@@ -1207,13 +1207,13 @@ func TestCreateWorkerLed(t *testing.T) {
|
||||
// CreateWorker(...) and test the createInRepo(...) failure
|
||||
// path if the repoFn returns and err.
|
||||
cnt := 0
|
||||
repoFn := func() (*servers.Repository, error) {
|
||||
repoFn := func() (*server.Repository, error) {
|
||||
cnt = cnt + 1
|
||||
switch {
|
||||
case cnt > 1:
|
||||
return nil, errors.New(testCtx, errors.Internal, "bad-repo-function", "error creating repo")
|
||||
default:
|
||||
return servers.NewRepository(rw, rw, testKms)
|
||||
return server.NewRepository(rw, rw, testKms)
|
||||
}
|
||||
}
|
||||
testSrv, err := NewService(testCtx, repoFn, iamRepoFn)
|
||||
|
||||
@@ -60,7 +60,7 @@ func requestCtxInterceptor(
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing auth token repo function")
|
||||
}
|
||||
if serversRepoFn == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing servers repo function")
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing server repo function")
|
||||
}
|
||||
if kms == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing kms")
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/mr-tron/base58"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -45,8 +45,8 @@ func Test_requestCtxInterceptor(t *testing.T) {
|
||||
atRepoFn := func() (*authtoken.Repository, error) {
|
||||
return authtoken.NewRepository(rw, rw, kmsCache)
|
||||
}
|
||||
serversRepoFn := func() (*servers.Repository, error) {
|
||||
return servers.NewRepository(rw, rw, kmsCache)
|
||||
serversRepoFn := func() (*server.Repository, error) {
|
||||
return server.NewRepository(rw, rw, kmsCache)
|
||||
}
|
||||
|
||||
validGatewayTicket := "valid-ticket"
|
||||
@@ -143,7 +143,7 @@ func Test_requestCtxInterceptor(t *testing.T) {
|
||||
eventer: testEventer,
|
||||
wantFactoryErr: true,
|
||||
wantFactoryErrMatch: errors.T(errors.InvalidParameter),
|
||||
wantFactoryErrContains: "missing servers repo function",
|
||||
wantFactoryErrContains: "missing server repo function",
|
||||
},
|
||||
{
|
||||
name: "missing-kms",
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
@@ -112,7 +112,7 @@ func (tc *TestController) AuthTokenRepo() *authtoken.Repository {
|
||||
return repo
|
||||
}
|
||||
|
||||
func (tc *TestController) ServersRepo() *servers.Repository {
|
||||
func (tc *TestController) ServersRepo() *server.Repository {
|
||||
repo, err := tc.c.ServersRepoFn()
|
||||
if err != nil {
|
||||
tc.t.Fatal(err)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -99,9 +99,9 @@ func (c Controller) v1WorkerAuthConfig(protos []string) (*tls.Config, *base.Work
|
||||
// Check for replays
|
||||
serversRepo, err := c.ServersRepoFn()
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("unable to fetch servers repo: %w", err)
|
||||
return nil, nil, fmt.Errorf("unable to fetch server repo: %w", err)
|
||||
}
|
||||
if err := serversRepo.AddNonce(c.baseContext, info.ConnectionNonce, servers.NoncePurposeWorkerAuth); err != nil {
|
||||
if err := serversRepo.AddNonce(c.baseContext, info.ConnectionNonce, server.NoncePurposeWorkerAuth); err != nil {
|
||||
return nil, nil, fmt.Errorf("unable to add connection nonce to database: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller"
|
||||
"github.com/hashicorp/boundary/internal/daemon/worker"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/nodeenrollment"
|
||||
@@ -48,7 +48,7 @@ func TestRotationTicking(t *testing.T) {
|
||||
})
|
||||
t.Cleanup(w.Shutdown)
|
||||
|
||||
// Get a servers repo and worker auth repo
|
||||
// Get a server repo and worker auth repo
|
||||
serversRepo, err := c.Controller().ServersRepoFn()
|
||||
require.NoError(err)
|
||||
workerAuthRepo, err := c.Controller().WorkerAuthRepoStorageFn()
|
||||
@@ -70,11 +70,11 @@ func TestRotationTicking(t *testing.T) {
|
||||
// Decode the proto into the request and create the worker
|
||||
req := new(types.FetchNodeCredentialsRequest)
|
||||
require.NoError(proto.Unmarshal(reqBytes, req))
|
||||
_, err = serversRepo.CreateWorker(c.Context(), &servers.Worker{
|
||||
_, err = serversRepo.CreateWorker(c.Context(), &server.Worker{
|
||||
Worker: &store.Worker{
|
||||
ScopeId: scope.Global.String(),
|
||||
},
|
||||
}, servers.WithFetchNodeCredentialsRequest(req))
|
||||
}, server.WithFetchNodeCredentialsRequest(req))
|
||||
require.NoError(err)
|
||||
|
||||
// Verify we see one authorized set of credentials now
|
||||
|
||||
@@ -7,11 +7,12 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/daemon/worker/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/worker/session"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
@@ -138,11 +139,11 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context) {
|
||||
|
||||
// Send status information
|
||||
client := w.controllerStatusConn.Load().(pbs.ServerCoordinationServiceClient)
|
||||
var tags []*servers.TagPair
|
||||
var tags []*server.TagPair
|
||||
// If we're not going to request a tag update, no reason to have these
|
||||
// marshaled on every status call.
|
||||
if w.updateTags.Load() {
|
||||
tags = w.tags.Load().([]*servers.TagPair)
|
||||
tags = w.tags.Load().([]*server.TagPair)
|
||||
}
|
||||
statusCtx, statusCancel := context.WithTimeout(cancelCtx, common.StatusTimeout)
|
||||
defer statusCancel()
|
||||
@@ -156,7 +157,7 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context) {
|
||||
|
||||
result, err := client.Status(statusCtx, &pbs.StatusRequest{
|
||||
Jobs: activeJobs,
|
||||
WorkerStatus: &servers.ServerWorkerStatus{
|
||||
WorkerStatus: &server.ServerWorkerStatus{
|
||||
Name: w.conf.RawConfig.Worker.Name,
|
||||
Description: w.conf.RawConfig.Worker.Description,
|
||||
Address: w.conf.RawConfig.Worker.PublicAddr,
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/nodeenrollment"
|
||||
"github.com/mr-tron/base58"
|
||||
|
||||
@@ -388,13 +388,13 @@ func (w *Worker) Resolver() *manual.Resolver {
|
||||
|
||||
func (w *Worker) ParseAndStoreTags(incoming map[string][]string) {
|
||||
if len(incoming) == 0 {
|
||||
w.tags.Store([]*servers.TagPair{})
|
||||
w.tags.Store([]*server.TagPair{})
|
||||
return
|
||||
}
|
||||
tags := []*servers.TagPair{}
|
||||
tags := []*server.TagPair{}
|
||||
for k, vals := range incoming {
|
||||
for _, v := range vals {
|
||||
tags = append(tags, &servers.TagPair{
|
||||
tags = append(tags, &server.TagPair{
|
||||
Key: k,
|
||||
Value: v,
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
servers "github.com/hashicorp/boundary/internal/servers"
|
||||
server "github.com/hashicorp/boundary/internal/server"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
@@ -586,7 +586,7 @@ type StatusRequest struct {
|
||||
// The worker info. We could use information from the TLS connection but this
|
||||
// is easier and going the other route doesn't provide much benefit -- if you
|
||||
// get access to the key and spoof the connection, you're already compromised.
|
||||
WorkerStatus *servers.ServerWorkerStatus `protobuf:"bytes,40,opt,name=worker_status,json=workerStatus,proto3" json:"worker_status,omitempty"`
|
||||
WorkerStatus *server.ServerWorkerStatus `protobuf:"bytes,40,opt,name=worker_status,json=workerStatus,proto3" json:"worker_status,omitempty"`
|
||||
}
|
||||
|
||||
func (x *StatusRequest) Reset() {
|
||||
@@ -635,7 +635,7 @@ func (x *StatusRequest) GetUpdateTags() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *StatusRequest) GetWorkerStatus() *servers.ServerWorkerStatus {
|
||||
func (x *StatusRequest) GetWorkerStatus() *server.ServerWorkerStatus {
|
||||
if x != nil {
|
||||
return x.WorkerStatus
|
||||
}
|
||||
@@ -924,20 +924,20 @@ func file_controller_servers_services_v1_server_coordination_service_proto_rawDe
|
||||
var file_controller_servers_services_v1_server_coordination_service_proto_enumTypes = make([]protoimpl.EnumInfo, 5)
|
||||
var file_controller_servers_services_v1_server_coordination_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_controller_servers_services_v1_server_coordination_service_proto_goTypes = []interface{}{
|
||||
(CONNECTIONSTATUS)(0), // 0: controller.servers.services.v1.CONNECTIONSTATUS
|
||||
(SESSIONSTATUS)(0), // 1: controller.servers.services.v1.SESSIONSTATUS
|
||||
(JOBTYPE)(0), // 2: controller.servers.services.v1.JOBTYPE
|
||||
(CHANGETYPE)(0), // 3: controller.servers.services.v1.CHANGETYPE
|
||||
(UpstreamServer_TYPE)(0), // 4: controller.servers.services.v1.UpstreamServer.TYPE
|
||||
(*Connection)(nil), // 5: controller.servers.services.v1.Connection
|
||||
(*SessionJobInfo)(nil), // 6: controller.servers.services.v1.SessionJobInfo
|
||||
(*Job)(nil), // 7: controller.servers.services.v1.Job
|
||||
(*JobStatus)(nil), // 8: controller.servers.services.v1.JobStatus
|
||||
(*UpstreamServer)(nil), // 9: controller.servers.services.v1.UpstreamServer
|
||||
(*StatusRequest)(nil), // 10: controller.servers.services.v1.StatusRequest
|
||||
(*JobChangeRequest)(nil), // 11: controller.servers.services.v1.JobChangeRequest
|
||||
(*StatusResponse)(nil), // 12: controller.servers.services.v1.StatusResponse
|
||||
(*servers.ServerWorkerStatus)(nil), // 13: controller.servers.v1.ServerWorkerStatus
|
||||
(CONNECTIONSTATUS)(0), // 0: controller.servers.services.v1.CONNECTIONSTATUS
|
||||
(SESSIONSTATUS)(0), // 1: controller.servers.services.v1.SESSIONSTATUS
|
||||
(JOBTYPE)(0), // 2: controller.servers.services.v1.JOBTYPE
|
||||
(CHANGETYPE)(0), // 3: controller.servers.services.v1.CHANGETYPE
|
||||
(UpstreamServer_TYPE)(0), // 4: controller.servers.services.v1.UpstreamServer.TYPE
|
||||
(*Connection)(nil), // 5: controller.servers.services.v1.Connection
|
||||
(*SessionJobInfo)(nil), // 6: controller.servers.services.v1.SessionJobInfo
|
||||
(*Job)(nil), // 7: controller.servers.services.v1.Job
|
||||
(*JobStatus)(nil), // 8: controller.servers.services.v1.JobStatus
|
||||
(*UpstreamServer)(nil), // 9: controller.servers.services.v1.UpstreamServer
|
||||
(*StatusRequest)(nil), // 10: controller.servers.services.v1.StatusRequest
|
||||
(*JobChangeRequest)(nil), // 11: controller.servers.services.v1.JobChangeRequest
|
||||
(*StatusResponse)(nil), // 12: controller.servers.services.v1.StatusResponse
|
||||
(*server.ServerWorkerStatus)(nil), // 13: controller.servers.v1.ServerWorkerStatus
|
||||
}
|
||||
var file_controller_servers_services_v1_server_coordination_service_proto_depIdxs = []int32{
|
||||
0, // 0: controller.servers.services.v1.Connection.status:type_name -> controller.servers.services.v1.CONNECTIONSTATUS
|
||||
|
||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
||||
|
||||
package controller.servers.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers;servers";
|
||||
option go_package = "github.com/hashicorp/boundary/internal/server;server";
|
||||
|
||||
// TagPair matches a key to a value.
|
||||
message TagPair {
|
||||
|
||||
@@ -4,7 +4,7 @@ package controller.storage.servers.store.v1;
|
||||
|
||||
import "controller/storage/timestamp/v1/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
option go_package = "github.com/hashicorp/boundary/internal/server/store;store";
|
||||
|
||||
// Controller contains all fields related to a Controller resource
|
||||
message Controller {
|
||||
|
||||
@@ -5,7 +5,7 @@ package controller.storage.servers.store.v1;
|
||||
|
||||
import "controller/storage/timestamp/v1/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
option go_package = "github.com/hashicorp/boundary/internal/server/store;store";
|
||||
|
||||
// CertificateAuthority is a versioned entity used to lock the database when rotation RootCertificates
|
||||
message CertificateAuthority {
|
||||
|
||||
@@ -5,7 +5,7 @@ package controller.storage.servers.store.v1;
|
||||
import "controller/custom_options/v1/options.proto";
|
||||
import "controller/storage/timestamp/v1/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
option go_package = "github.com/hashicorp/boundary/internal/server/store;store";
|
||||
|
||||
// Worker contains all fields related to a Worker resource
|
||||
message Worker {
|
||||
|
||||
@@ -3,7 +3,7 @@ syntax = "proto3";
|
||||
// Package store provides protobufs for storing types in the pki package.
|
||||
package controller.storage.servers.store.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/servers/store;store";
|
||||
option go_package = "github.com/hashicorp/boundary/internal/server/store;store";
|
||||
|
||||
// WorkerAuth contains all fields related to an authorized Worker resource
|
||||
message WorkerAuth {
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/go-uuid"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -94,7 +94,7 @@ func testController(t *testing.T, conn *db.DB, wrapper wrapping.Wrapper) *store.
|
||||
t.Helper()
|
||||
rw := db.New(conn)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kms)
|
||||
serversRepo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
|
||||
id, err := uuid.GenerateUUID()
|
||||
|
||||
@@ -6,13 +6,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler/job"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/go-uuid"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -28,7 +28,7 @@ func TestScheduler(t testing.TB, conn *db.DB, wrapper wrapping.Wrapper, opt ...O
|
||||
|
||||
rw := db.New(conn)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kmsCache)
|
||||
serversRepo, err := server.NewRepository(rw, rw, kmsCache)
|
||||
require.NoError(t, err)
|
||||
iam.TestRepo(t, conn, wrapper)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
// RegisterJobs registers the rotate roots job with the provided scheduler.
|
||||
func RegisterJobs(ctx context.Context, scheduler *scheduler.Scheduler, r db.Reader, w db.Writer, kms *kms.Kms) error {
|
||||
const op = "servers.(Jobs).RegisterJobs"
|
||||
const op = "server.(Jobs).RegisterJobs"
|
||||
|
||||
if isNil(scheduler) {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing scheduler")
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
)
|
||||
|
||||
const rotateFrequency = time.Hour
|
||||
@@ -17,14 +17,14 @@ const rotateFrequency = time.Hour
|
||||
// It runs every hour; the root rotation function in the library is designed to not
|
||||
// do anything if it's not time to rotate (roots are within their valid ranges)
|
||||
type rotateRootsJob struct {
|
||||
workerAuthRepo *servers.WorkerAuthRepositoryStorage
|
||||
workerAuthRepo *server.WorkerAuthRepositoryStorage
|
||||
|
||||
totalRotates int
|
||||
}
|
||||
|
||||
// newRotateRootsJob instantiates the rotate roots job.
|
||||
func newRotateRootsJob(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms) (*rotateRootsJob, error) {
|
||||
const op = "servers.newRotateRootsJob"
|
||||
const op = "server.newRotateRootsJob"
|
||||
switch {
|
||||
case isNil(r):
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing reader")
|
||||
@@ -34,7 +34,7 @@ func newRotateRootsJob(ctx context.Context, r db.Reader, w db.Writer, kms *kms.K
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing kms")
|
||||
}
|
||||
|
||||
workerAuthRepo, err := servers.NewRepositoryStorage(ctx, r, w, kms)
|
||||
workerAuthRepo, err := server.NewRepositoryStorage(ctx, r, w, kms)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
@@ -69,9 +69,9 @@ func (r *rotateRootsJob) Status() scheduler.JobStatus {
|
||||
|
||||
// Run executes the job by calling the rotateRoots domain function
|
||||
func (r *rotateRootsJob) Run(ctx context.Context) error {
|
||||
const op = "servers.(rotateRootsJob).Run"
|
||||
const op = "server.(rotateRootsJob).Run"
|
||||
|
||||
err := servers.RotateRoots(ctx, r.workerAuthRepo)
|
||||
err := server.RotateRoots(ctx, r.workerAuthRepo)
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
+4
-4
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/nodeenrollment/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -27,7 +27,7 @@ func TestRotateRootsJob(t *testing.T) {
|
||||
err := kmsCache.CreateKeys(context.Background(), scope.Global.String(), kms.WithRandomReader(rand.Reader))
|
||||
require.NoError(err)
|
||||
|
||||
workerAuthRepo, err := servers.NewRepositoryStorage(ctx, rw, rw, kmsCache)
|
||||
workerAuthRepo, err := server.NewRepositoryStorage(ctx, rw, rw, kmsCache)
|
||||
require.NoError(err)
|
||||
|
||||
type args struct {
|
||||
@@ -38,7 +38,7 @@ func TestRotateRootsJob(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
options []servers.Option
|
||||
options []server.Option
|
||||
wantLimit int
|
||||
wantErr bool
|
||||
wantErrCode errors.Code
|
||||
@@ -150,7 +150,7 @@ func TestRegisterRotateRootsJob(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
options []servers.Option
|
||||
options []server.Option
|
||||
wantLimit int
|
||||
wantErr bool
|
||||
wantErrCode errors.Code
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
)
|
||||
|
||||
// PublicId prefixes for the resources in the servers package.
|
||||
// PublicId prefixes for the resources in the server package.
|
||||
const (
|
||||
WorkerPrefix = "w"
|
||||
)
|
||||
@@ -15,7 +15,7 @@ const (
|
||||
func newWorkerId(ctx context.Context) (string, error) {
|
||||
id, err := db.NewPublicId(WorkerPrefix)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(ctx, err, "servers.newWorkerId")
|
||||
return "", errors.Wrap(ctx, err, "server.newWorkerId")
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
@@ -24,10 +24,10 @@ func newWorkerId(ctx context.Context) (string, error) {
|
||||
// scope and the worker name. This should only be used on kms workers at
|
||||
// upsert time.
|
||||
func newWorkerIdFromScopeAndName(ctx context.Context, scope, name string) (string, error) {
|
||||
const op = "servers.newWorkerIdFromScopeAndName"
|
||||
const op = "server.newWorkerIdFromScopeAndName"
|
||||
id, err := db.NewPublicId(WorkerPrefix, db.WithPrngValues([]string{scope, name}))
|
||||
if err != nil {
|
||||
return "", errors.Wrap(ctx, err, "servers.newWorkerId")
|
||||
return "", errors.Wrap(ctx, err, "server.newWorkerId")
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
const (
|
||||
deleteWhereCreateTimeSql = `create_time < ?`
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
@@ -21,7 +21,7 @@ const (
|
||||
DefaultLiveness = 15 * time.Second
|
||||
)
|
||||
|
||||
// Repository is the servers database repository
|
||||
// Repository is the server database repository
|
||||
type Repository struct {
|
||||
reader db.Reader
|
||||
writer db.Writer
|
||||
@@ -30,10 +30,10 @@ type Repository struct {
|
||||
defaultLimit int
|
||||
}
|
||||
|
||||
// NewRepository creates a new servers Repository. Supports the options: WithLimit
|
||||
// NewRepository creates a new server Repository. Supports the options: WithLimit
|
||||
// which sets a default limit on results returned by repo operations.
|
||||
func NewRepository(r db.Reader, w db.Writer, kms *kms.Kms, opt ...Option) (*Repository, error) {
|
||||
const op = "servers.NewRepository"
|
||||
const op = "server.NewRepository"
|
||||
if r == nil {
|
||||
return nil, errors.NewDeprecated(errors.InvalidParameter, op, "nil reader")
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
)
|
||||
|
||||
func (r *Repository) ListControllers(ctx context.Context, opt ...Option) ([]*store.Controller, error) {
|
||||
@@ -43,7 +43,7 @@ func (r *Repository) listControllersWithReader(ctx context.Context, reader db.Re
|
||||
}
|
||||
|
||||
func (r *Repository) UpsertController(ctx context.Context, controller *store.Controller) (int, error) {
|
||||
const op = "servers.UpsertController"
|
||||
const op = "server.UpsertController"
|
||||
|
||||
if controller == nil {
|
||||
return db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "controller is nil")
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
|
||||
// AddNonce adds a nonce
|
||||
func (r *Repository) AddNonce(ctx context.Context, nonce, purpose string, opt ...Option) error {
|
||||
const op = "servers.AddNonce"
|
||||
const op = "server.AddNonce"
|
||||
if nonce == "" {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "empty nonce")
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (r *Repository) CleanupNonces(ctx context.Context, opt ...Option) (int, err
|
||||
|
||||
rows, err := r.writer.Delete(ctx, &Nonce{}, db.WithWhere(deleteWhereCreateTimeSql, endTime))
|
||||
if err != nil {
|
||||
return db.NoRowsAffected, errors.Wrap(ctx, err, "servers.CleanupNonces")
|
||||
return db.NoRowsAffected, errors.Wrap(ctx, err, "server.CleanupNonces")
|
||||
}
|
||||
return rows, nil
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (r *Repository) CleanupNonces(ctx context.Context, opt ...Option) (int, err
|
||||
func (r *Repository) ListNonces(ctx context.Context, purpose string, opt ...Option) ([]*Nonce, error) {
|
||||
var nonces []*Nonce
|
||||
if err := r.reader.SearchWhere(ctx, &nonces, "purpose = ?", []interface{}{purpose}, db.WithLimit(-1)); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, "servers.ListNonces")
|
||||
return nil, errors.Wrap(ctx, err, "server.ListNonces")
|
||||
}
|
||||
return nonces, nil
|
||||
}
|
||||
+7
-7
@@ -1,4 +1,4 @@
|
||||
package servers_test
|
||||
package server_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller"
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -50,14 +50,14 @@ func TestRecoveryNonces(t *testing.T) {
|
||||
roleClient := roles.NewClient(client)
|
||||
_, err = roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.NoError(err)
|
||||
nonces, err := repo.ListNonces(tc.Context(), servers.NoncePurposeRecovery)
|
||||
nonces, err := repo.ListNonces(tc.Context(), server.NoncePurposeRecovery)
|
||||
require.NoError(err)
|
||||
assert.Len(nonces, 1)
|
||||
|
||||
// Token 1, try 2
|
||||
_, err = roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.Error(err)
|
||||
nonces, err = repo.ListNonces(tc.Context(), servers.NoncePurposeRecovery)
|
||||
nonces, err = repo.ListNonces(tc.Context(), server.NoncePurposeRecovery)
|
||||
require.NoError(err)
|
||||
assert.Len(nonces, 1)
|
||||
|
||||
@@ -65,13 +65,13 @@ func TestRecoveryNonces(t *testing.T) {
|
||||
roleClient.ApiClient().SetToken(token2)
|
||||
_, err = roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.NoError(err)
|
||||
nonces, err = repo.ListNonces(tc.Context(), servers.NoncePurposeRecovery)
|
||||
nonces, err = repo.ListNonces(tc.Context(), server.NoncePurposeRecovery)
|
||||
require.NoError(err)
|
||||
assert.Len(nonces, 2)
|
||||
|
||||
// Make sure they get cleaned up
|
||||
time.Sleep(2 * controller.NonceCleanupInterval)
|
||||
nonces, err = repo.ListNonces(tc.Context(), servers.NoncePurposeRecovery)
|
||||
nonces, err = repo.ListNonces(tc.Context(), server.NoncePurposeRecovery)
|
||||
require.NoError(err)
|
||||
assert.Len(nonces, 0)
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestRecoveryNonces(t *testing.T) {
|
||||
roleClient.ApiClient().SetToken(token)
|
||||
_, err = roleClient.Create(tc.Context(), scope.Global.String())
|
||||
require.Error(err)
|
||||
nonces, err = repo.ListNonces(tc.Context(), servers.NoncePurposeRecovery)
|
||||
nonces, err = repo.ListNonces(tc.Context(), server.NoncePurposeRecovery)
|
||||
require.NoError(err)
|
||||
assert.Len(nonces, 0)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
dbcommon "github.com/hashicorp/boundary/internal/db/common"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/nodeenrollment"
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
// DeleteWorker will delete a worker from the repository.
|
||||
func (r *Repository) DeleteWorker(ctx context.Context, publicId string, _ ...Option) (int, error) {
|
||||
const op = "servers.(Repository).DeleteWorker"
|
||||
const op = "server.(Repository).DeleteWorker"
|
||||
if publicId == "" {
|
||||
return db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "missing public id")
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (r *Repository) DeleteWorker(ctx context.Context, publicId string, _ ...Opt
|
||||
// LookupWorkerByName returns the worker with the provided name. In the event
|
||||
// that no worker is found that matches then nil, nil will be returned.
|
||||
func (r *Repository) LookupWorkerByName(ctx context.Context, name string) (*Worker, error) {
|
||||
const op = "servers.(Repository).LookupWorkerByName"
|
||||
const op = "server.(Repository).LookupWorkerByName"
|
||||
switch {
|
||||
case name == "":
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "name is empty")
|
||||
@@ -73,7 +73,7 @@ func (r *Repository) LookupWorkerByName(ctx context.Context, name string) (*Work
|
||||
}
|
||||
|
||||
func lookupWorkerByName(ctx context.Context, reader db.Reader, name string) (*Worker, error) {
|
||||
const op = "servers.lookupWorkerByName"
|
||||
const op = "server.lookupWorkerByName"
|
||||
switch {
|
||||
case isNil(reader):
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "reader is nil")
|
||||
@@ -97,7 +97,7 @@ func lookupWorkerByName(ctx context.Context, reader db.Reader, name string) (*Wo
|
||||
}
|
||||
|
||||
func (r *Repository) LookupWorkerIdByKeyId(ctx context.Context, keyId string) (string, error) {
|
||||
const op = "servers.(Repository).LookupWorkerIdByKeyId"
|
||||
const op = "server.(Repository).LookupWorkerIdByKeyId"
|
||||
switch {
|
||||
case keyId == "":
|
||||
return "", errors.New(ctx, errors.InvalidParameter, op, "keyId is empty")
|
||||
@@ -121,7 +121,7 @@ func (r *Repository) LookupWorkerIdByKeyId(ctx context.Context, keyId string) (s
|
||||
// LookupWorker returns the worker for the provided publicId. This returns
|
||||
// nil nil in the situation where no worker can be found with that public id.
|
||||
func (r *Repository) LookupWorker(ctx context.Context, publicId string, _ ...Option) (*Worker, error) {
|
||||
const op = "servers.(Repository).LookupWorker"
|
||||
const op = "server.(Repository).LookupWorker"
|
||||
switch {
|
||||
case publicId == "":
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "publicId is empty")
|
||||
@@ -136,7 +136,7 @@ func (r *Repository) LookupWorker(ctx context.Context, publicId string, _ ...Opt
|
||||
// lookupWorker returns the worker for the provided id. This returns
|
||||
// nil nil in the situation where no worker can be found with that public id.
|
||||
func lookupWorker(ctx context.Context, reader db.Reader, id string) (*Worker, error) {
|
||||
const op = "servers.lookupWorker"
|
||||
const op = "server.lookupWorker"
|
||||
switch {
|
||||
case id == "":
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "id is empty")
|
||||
@@ -163,7 +163,7 @@ func lookupWorker(ctx context.Context, reader db.Reader, id string) (*Worker, er
|
||||
// If WithLimit < 0, then unlimited results are returned. If WithLimit == 0, then
|
||||
// default limits are used for results.
|
||||
func (r *Repository) ListWorkers(ctx context.Context, scopeIds []string, opt ...Option) ([]*Worker, error) {
|
||||
const op = "servers.(Repository).ListWorkers"
|
||||
const op = "server.(Repository).ListWorkers"
|
||||
switch {
|
||||
case len(scopeIds) == 0:
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "no scope ids set")
|
||||
@@ -221,7 +221,7 @@ func (r *Repository) ListWorkers(ctx context.Context, scopeIds []string, opt ...
|
||||
// the only ones used. All others are ignored.
|
||||
// Workers are intentionally not oplogged.
|
||||
func (r *Repository) UpsertWorkerStatus(ctx context.Context, worker *Worker, opt ...Option) (*Worker, error) {
|
||||
const op = "servers.UpsertWorkerStatus"
|
||||
const op = "server.UpsertWorkerStatus"
|
||||
|
||||
opts := getOpts(opt...)
|
||||
switch {
|
||||
@@ -353,7 +353,7 @@ func (r *Repository) UpsertWorkerStatus(ctx context.Context, worker *Worker, opt
|
||||
// called from inside a db transaction.
|
||||
// Workers/worker tags are intentionally not oplogged.
|
||||
func setWorkerTags(ctx context.Context, w db.Writer, id string, ts TagSource, tags []*Tag) error {
|
||||
const op = "servers.setWorkerTags"
|
||||
const op = "server.setWorkerTags"
|
||||
switch {
|
||||
case !ts.isValid():
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "invalid tag source provided")
|
||||
@@ -404,7 +404,7 @@ func (r *Repository) UpdateWorker(ctx context.Context, worker *Worker, version u
|
||||
nameField = "name"
|
||||
descField = "description"
|
||||
)
|
||||
const op = "servers.(Repository).UpdateWorker"
|
||||
const op = "server.(Repository).UpdateWorker"
|
||||
switch {
|
||||
case worker == nil:
|
||||
return nil, db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "worker is nil")
|
||||
@@ -485,7 +485,7 @@ func (r *Repository) UpdateWorker(ctx context.Context, worker *Worker, version u
|
||||
// Options supported: WithFetchNodeCredentialsRequest and WithNewIdFunc (this
|
||||
// option is likely only useful for tests)
|
||||
func (r *Repository) CreateWorker(ctx context.Context, worker *Worker, opt ...Option) (*Worker, error) {
|
||||
const op = "servers.CreateWorker"
|
||||
const op = "server.CreateWorker"
|
||||
switch {
|
||||
case worker == nil:
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing worker")
|
||||
+182
-182
@@ -1,4 +1,4 @@
|
||||
package servers_test
|
||||
package server_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/go-dbw"
|
||||
@@ -34,12 +34,12 @@ func TestDeleteWorker(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
|
||||
type args struct {
|
||||
worker *servers.Worker
|
||||
worker *server.Worker
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -51,7 +51,7 @@ func TestDeleteWorker(t *testing.T) {
|
||||
{
|
||||
name: "valid",
|
||||
args: args{
|
||||
worker: servers.TestKmsWorker(t, conn, wrapper),
|
||||
worker: server.TestKmsWorker(t, conn, wrapper),
|
||||
},
|
||||
wantRowsDeleted: 1,
|
||||
wantErr: false,
|
||||
@@ -59,20 +59,20 @@ func TestDeleteWorker(t *testing.T) {
|
||||
{
|
||||
name: "no-public-id",
|
||||
args: args{
|
||||
worker: func() *servers.Worker {
|
||||
w := servers.Worker{Worker: &store.Worker{}}
|
||||
worker: func() *server.Worker {
|
||||
w := server.Worker{Worker: &store.Worker{}}
|
||||
return &w
|
||||
}(),
|
||||
},
|
||||
wantRowsDeleted: 0,
|
||||
wantErr: true,
|
||||
wantErrMsg: "servers.(Repository).DeleteWorker: missing public id: parameter violation: error #100",
|
||||
wantErrMsg: "server.(Repository).DeleteWorker: missing public id: parameter violation: error #100",
|
||||
},
|
||||
{
|
||||
name: "not-found",
|
||||
args: args{
|
||||
worker: func() *servers.Worker {
|
||||
w := servers.Worker{Worker: &store.Worker{}}
|
||||
worker: func() *server.Worker {
|
||||
w := server.Worker{Worker: &store.Worker{}}
|
||||
id, err := db.NewPublicId("w")
|
||||
require.NoError(t, err)
|
||||
w.PublicId = id
|
||||
@@ -81,7 +81,7 @@ func TestDeleteWorker(t *testing.T) {
|
||||
},
|
||||
wantRowsDeleted: 0,
|
||||
wantErr: true,
|
||||
wantErrMsg: "servers.(Repository).DeleteWorker: delete failed for worker with workerId:",
|
||||
wantErrMsg: "server.(Repository).DeleteWorker: delete failed for worker with workerId:",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@@ -110,11 +110,11 @@ func TestLookupWorkerByName(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
|
||||
w := servers.TestKmsWorker(t, conn, wrapper)
|
||||
w := server.TestKmsWorker(t, conn, wrapper)
|
||||
t.Run("success", func(t *testing.T) {
|
||||
got, err := repo.LookupWorkerByName(ctx, w.GetName())
|
||||
require.NoError(t, err)
|
||||
@@ -129,11 +129,11 @@ func TestLookupWorkerByName(t *testing.T) {
|
||||
conn, mock := db.TestSetupWithMock(t)
|
||||
rw := db.New(conn)
|
||||
mock.ExpectQuery(`SELECT`).WillReturnError(errors.New(context.Background(), errors.Internal, "test", "lookup-error"))
|
||||
r, err := servers.NewRepository(rw, rw, kms)
|
||||
r, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
got, err := r.LookupWorkerByName(ctx, w.GetName())
|
||||
assert.NoError(t, mock.ExpectationsWereMet())
|
||||
assert.Truef(t, errors.Match(errors.T(errors.Op("servers.(Repository).LookupWorkerByName")), err), "got error %v", err)
|
||||
assert.Truef(t, errors.Match(errors.T(errors.Op("server.(Repository).LookupWorkerByName")), err), "got error %v", err)
|
||||
assert.Nil(t, got)
|
||||
})
|
||||
}
|
||||
@@ -143,11 +143,11 @@ func TestLookupWorkerIdByKeyId(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := servers.NewRepository(rw, rw, kmsCache)
|
||||
repo, err := server.NewRepository(rw, rw, kmsCache)
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
var workerKeyId string
|
||||
w := servers.TestPkiWorker(t, conn, wrapper, servers.WithTestPkiWorkerAuthorizedKeyId(&workerKeyId))
|
||||
w := server.TestPkiWorker(t, conn, wrapper, server.WithTestPkiWorkerAuthorizedKeyId(&workerKeyId))
|
||||
t.Run("success", func(t *testing.T) {
|
||||
got, err := repo.LookupWorkerIdByKeyId(ctx, workerKeyId)
|
||||
require.NoError(t, err)
|
||||
@@ -162,11 +162,11 @@ func TestLookupWorkerIdByKeyId(t *testing.T) {
|
||||
conn, mock := db.TestSetupWithMock(t)
|
||||
rw := db.New(conn)
|
||||
mock.ExpectQuery(`SELECT`).WillReturnError(errors.New(context.Background(), errors.Internal, "test", "lookup-error"))
|
||||
r, err := servers.NewRepository(rw, rw, kmsCache)
|
||||
r, err := server.NewRepository(rw, rw, kmsCache)
|
||||
require.NoError(t, err)
|
||||
got, err := r.LookupWorkerIdByKeyId(ctx, "somekey")
|
||||
assert.NoError(t, mock.ExpectationsWereMet())
|
||||
assert.Truef(t, errors.Match(errors.T(errors.Op("servers.(Repository).LookupWorkerIdByKeyId")), err), "got error %v", err)
|
||||
assert.Truef(t, errors.Match(errors.T(errors.Op("server.(Repository).LookupWorkerIdByKeyId")), err), "got error %v", err)
|
||||
assert.Empty(t, got)
|
||||
})
|
||||
}
|
||||
@@ -176,15 +176,15 @@ func TestLookupWorker(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
|
||||
w := servers.TestKmsWorker(t, conn, wrapper,
|
||||
servers.WithName("name"),
|
||||
servers.WithDescription("description"),
|
||||
servers.WithAddress("address"),
|
||||
servers.WithWorkerTags(&servers.Tag{"key", "val"}))
|
||||
w := server.TestKmsWorker(t, conn, wrapper,
|
||||
server.WithName("name"),
|
||||
server.WithDescription("description"),
|
||||
server.WithAddress("address"),
|
||||
server.WithWorkerTags(&server.Tag{"key", "val"}))
|
||||
require.NoError(t, err)
|
||||
|
||||
sessRepo, err := session.NewRepository(rw, rw, kms)
|
||||
@@ -238,11 +238,11 @@ func TestLookupWorker(t *testing.T) {
|
||||
conn, mock := db.TestSetupWithMock(t)
|
||||
rw := db.New(conn)
|
||||
mock.ExpectQuery(`SELECT`).WillReturnError(errors.New(context.Background(), errors.Internal, "test", "lookup-error"))
|
||||
r, err := servers.NewRepository(rw, rw, kms)
|
||||
r, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(t, err)
|
||||
got, err := r.LookupWorker(ctx, w.GetPublicId())
|
||||
assert.NoError(t, mock.ExpectationsWereMet())
|
||||
assert.Truef(t, errors.Match(errors.T(errors.Op("servers.(Repository).LookupWorker")), err), "got error %v", err)
|
||||
assert.Truef(t, errors.Match(errors.T(errors.Op("server.(Repository).LookupWorker")), err), "got error %v", err)
|
||||
assert.Nil(t, got)
|
||||
})
|
||||
}
|
||||
@@ -252,15 +252,15 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := servers.NewRepository(rw, rw, kmsCache)
|
||||
repo, err := server.NewRepository(rw, rw, kmsCache)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
t.Run("create an initial kms worker and update status", func(t *testing.T) {
|
||||
wStatus1 := servers.NewWorker(scope.Global.String(),
|
||||
servers.WithAddress("address"), servers.WithName("config_name1"),
|
||||
servers.WithDescription("kms_description1"))
|
||||
wStatus1 := server.NewWorker(scope.Global.String(),
|
||||
server.WithAddress("address"), server.WithName("config_name1"),
|
||||
server.WithDescription("kms_description1"))
|
||||
worker, err := repo.UpsertWorkerStatus(ctx, wStatus1)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -273,8 +273,8 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
assert.Equal(t, "address", worker.GetAddress())
|
||||
|
||||
// update again and see updated last status time
|
||||
wStatus2 := servers.NewWorker(scope.Global.String(),
|
||||
servers.WithAddress("new_address"), servers.WithName("config_name1"))
|
||||
wStatus2 := server.NewWorker(scope.Global.String(),
|
||||
server.WithAddress("new_address"), server.WithName("config_name1"))
|
||||
worker, err = repo.UpsertWorkerStatus(ctx, wStatus2)
|
||||
require.NoError(t, err)
|
||||
assert.Greater(t, worker.GetLastStatusTime().AsTime(), worker.GetCreateTime().AsTime())
|
||||
@@ -286,12 +286,12 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
|
||||
// Setup and use a pki worker
|
||||
var pkiWorkerKeyId string
|
||||
pkiWorker := servers.TestPkiWorker(t, conn, wrapper, servers.WithName("pki"), servers.WithDescription("pki_description1"), servers.WithTestPkiWorkerAuthorizedKeyId(&pkiWorkerKeyId))
|
||||
pkiWorker := server.TestPkiWorker(t, conn, wrapper, server.WithName("pki"), server.WithDescription("pki_description1"), server.WithTestPkiWorkerAuthorizedKeyId(&pkiWorkerKeyId))
|
||||
|
||||
t.Run("update status for pki worker", func(t *testing.T) {
|
||||
wStatus1 := servers.NewWorker(scope.Global.String(),
|
||||
servers.WithAddress("pki_address"), servers.WithDescription("pki_description2"))
|
||||
worker, err := repo.UpsertWorkerStatus(ctx, wStatus1, servers.WithKeyId(pkiWorkerKeyId))
|
||||
wStatus1 := server.NewWorker(scope.Global.String(),
|
||||
server.WithAddress("pki_address"), server.WithDescription("pki_description2"))
|
||||
worker, err := repo.UpsertWorkerStatus(ctx, wStatus1, server.WithKeyId(pkiWorkerKeyId))
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.True(t, strings.HasPrefix(worker.GetPublicId(), "w_"))
|
||||
@@ -306,17 +306,17 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
|
||||
failureCases := []struct {
|
||||
name string
|
||||
repo *servers.Repository
|
||||
status *servers.Worker
|
||||
options []servers.Option
|
||||
repo *server.Repository
|
||||
status *server.Worker
|
||||
options []server.Option
|
||||
errAssert func(*testing.T, error)
|
||||
}{
|
||||
{
|
||||
name: "conflicting name with pki",
|
||||
repo: repo,
|
||||
status: servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(pkiWorker.GetName()),
|
||||
servers.WithAddress("someaddress")),
|
||||
status: server.NewWorker(scope.Global.String(),
|
||||
server.WithName(pkiWorker.GetName()),
|
||||
server.WithAddress("someaddress")),
|
||||
errAssert: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
assert.True(t, errors.Match(errors.T(errors.NotUnique), err), err)
|
||||
@@ -325,8 +325,8 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
{
|
||||
name: "no address",
|
||||
repo: repo,
|
||||
status: servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName("worker_with_no_address")),
|
||||
status: server.NewWorker(scope.Global.String(),
|
||||
server.WithName("worker_with_no_address")),
|
||||
errAssert: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
assert.True(t, errors.Match(errors.T(errors.InvalidParameter), err))
|
||||
@@ -335,10 +335,10 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
{
|
||||
name: "cant specify public id",
|
||||
repo: repo,
|
||||
status: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName("worker_with_no_address"),
|
||||
servers.WithAddress("workeraddress"))
|
||||
status: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String(),
|
||||
server.WithName("worker_with_no_address"),
|
||||
server.WithAddress("workeraddress"))
|
||||
w.PublicId = "w_specified"
|
||||
return w
|
||||
}(),
|
||||
@@ -350,10 +350,10 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
{
|
||||
name: "name and key id provided",
|
||||
repo: repo,
|
||||
status: servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName("name and key id provided"),
|
||||
servers.WithAddress("someaddress")),
|
||||
options: []servers.Option{servers.WithKeyId(pkiWorkerKeyId)},
|
||||
status: server.NewWorker(scope.Global.String(),
|
||||
server.WithName("name and key id provided"),
|
||||
server.WithAddress("someaddress")),
|
||||
options: []server.Option{server.WithKeyId(pkiWorkerKeyId)},
|
||||
errAssert: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
assert.True(t, errors.Match(errors.T(errors.InvalidParameter), err), err)
|
||||
@@ -362,8 +362,8 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
{
|
||||
name: "no name or key id",
|
||||
repo: repo,
|
||||
status: servers.NewWorker(scope.Global.String(),
|
||||
servers.WithAddress("no_name_address")),
|
||||
status: server.NewWorker(scope.Global.String(),
|
||||
server.WithAddress("no_name_address")),
|
||||
errAssert: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
assert.True(t, errors.Match(errors.T(errors.InvalidParameter), err))
|
||||
@@ -381,9 +381,9 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
{
|
||||
name: "empty scope",
|
||||
repo: repo,
|
||||
status: servers.NewWorker("",
|
||||
servers.WithAddress("address"),
|
||||
servers.WithName("config_name1")),
|
||||
status: server.NewWorker("",
|
||||
server.WithAddress("address"),
|
||||
server.WithName("config_name1")),
|
||||
errAssert: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
assert.True(t, errors.Match(errors.T(errors.InvalidParameter), err))
|
||||
@@ -391,19 +391,19 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "database failure",
|
||||
repo: func() *servers.Repository {
|
||||
repo: func() *server.Repository {
|
||||
conn, mock := db.TestSetupWithMock(t)
|
||||
rw := db.New(conn)
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectQuery(`INSERT`).WillReturnError(errors.New(context.Background(), errors.Internal, "test", "create-error"))
|
||||
mock.ExpectRollback()
|
||||
r, err := servers.NewRepository(rw, rw, kmsCache)
|
||||
r, err := server.NewRepository(rw, rw, kmsCache)
|
||||
require.NoError(t, err)
|
||||
return r
|
||||
}(),
|
||||
status: servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName("database failure"),
|
||||
servers.WithAddress("address")),
|
||||
status: server.NewWorker(scope.Global.String(),
|
||||
server.WithName("database failure"),
|
||||
server.WithAddress("address")),
|
||||
errAssert: func(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
assert.Error(t, err)
|
||||
@@ -424,9 +424,9 @@ func TestUpsertWorkerStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("add another status", func(t *testing.T) {
|
||||
anotherStatus := servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName("another_test_worker"),
|
||||
servers.WithAddress("address"))
|
||||
anotherStatus := server.NewWorker(scope.Global.String(),
|
||||
server.WithName("another_test_worker"),
|
||||
server.WithAddress("address"))
|
||||
_, err = repo.UpsertWorkerStatus(ctx, anotherStatus)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -442,40 +442,40 @@ func TestTagUpdatingListing(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
repo, err := servers.NewRepository(rw, rw, kms)
|
||||
repo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
ctx := context.Background()
|
||||
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
wStatus := servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(worker1.GetName()),
|
||||
servers.WithAddress("somethingnew"),
|
||||
servers.WithWorkerTags(
|
||||
&servers.Tag{
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
wStatus := server.NewWorker(scope.Global.String(),
|
||||
server.WithName(worker1.GetName()),
|
||||
server.WithAddress("somethingnew"),
|
||||
server.WithWorkerTags(
|
||||
&server.Tag{
|
||||
Key: "tag1",
|
||||
Value: "value1",
|
||||
},
|
||||
&servers.Tag{
|
||||
&server.Tag{
|
||||
Key: "tag1",
|
||||
Value: "value2",
|
||||
}))
|
||||
|
||||
worker1, err = repo.UpsertWorkerStatus(ctx, wStatus,
|
||||
servers.WithUpdateTags(true))
|
||||
server.WithUpdateTags(true))
|
||||
require.NoError(err)
|
||||
assert.Len(t, worker1.CanonicalTags(), 1)
|
||||
assert.ElementsMatch(t, []string{"value1", "value2"}, worker1.CanonicalTags()["tag1"])
|
||||
|
||||
// Update without saying to update tags
|
||||
wStatus = servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(worker1.GetName()),
|
||||
servers.WithAddress(worker1.GetAddress()),
|
||||
servers.WithWorkerTags(
|
||||
&servers.Tag{
|
||||
wStatus = server.NewWorker(scope.Global.String(),
|
||||
server.WithName(worker1.GetName()),
|
||||
server.WithAddress(worker1.GetAddress()),
|
||||
server.WithWorkerTags(
|
||||
&server.Tag{
|
||||
Key: "tag22",
|
||||
Value: "value21",
|
||||
},
|
||||
&servers.Tag{
|
||||
&server.Tag{
|
||||
Key: "tag22",
|
||||
Value: "value22",
|
||||
}))
|
||||
@@ -485,7 +485,7 @@ func TestTagUpdatingListing(t *testing.T) {
|
||||
assert.ElementsMatch(t, []string{"value1", "value2"}, worker1.CanonicalTags()["tag1"])
|
||||
|
||||
// Update tags and test again
|
||||
worker1, err = repo.UpsertWorkerStatus(ctx, wStatus, servers.WithUpdateTags(true))
|
||||
worker1, err = repo.UpsertWorkerStatus(ctx, wStatus, server.WithUpdateTags(true))
|
||||
require.NoError(err)
|
||||
assert.Len(t, worker1.CanonicalTags(), 1)
|
||||
assert.ElementsMatch(t, []string{"value21", "value22"}, worker1.CanonicalTags()["tag22"])
|
||||
@@ -498,7 +498,7 @@ func TestListWorkers(t *testing.T) {
|
||||
wrapper := db.TestWrapper(t)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
const testLimit = 10
|
||||
repo, err := servers.NewRepository(rw, rw, kms, servers.WithLimit(testLimit))
|
||||
repo, err := server.NewRepository(rw, rw, kms, server.WithLimit(testLimit))
|
||||
require.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -506,7 +506,7 @@ func TestListWorkers(t *testing.T) {
|
||||
name string
|
||||
createCnt int
|
||||
reqScopes []string
|
||||
opts []servers.Option
|
||||
opts []server.Option
|
||||
wantCnt int
|
||||
wantErr bool
|
||||
}{
|
||||
@@ -514,7 +514,7 @@ func TestListWorkers(t *testing.T) {
|
||||
name: "no-limit",
|
||||
createCnt: testLimit + 1,
|
||||
reqScopes: []string{scope.Global.String()},
|
||||
opts: []servers.Option{servers.WithLimit(-1)},
|
||||
opts: []server.Option{server.WithLimit(-1)},
|
||||
wantCnt: testLimit + 1,
|
||||
wantErr: false,
|
||||
},
|
||||
@@ -529,7 +529,7 @@ func TestListWorkers(t *testing.T) {
|
||||
name: "custom-limit",
|
||||
createCnt: testLimit + 1,
|
||||
reqScopes: []string{scope.Global.String()},
|
||||
opts: []servers.Option{servers.WithLimit(3)},
|
||||
opts: []server.Option{server.WithLimit(3)},
|
||||
wantCnt: 3,
|
||||
wantErr: false,
|
||||
},
|
||||
@@ -542,14 +542,14 @@ func TestListWorkers(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
db.TestDeleteWhere(t, conn, w, "true")
|
||||
for i := 0; i < tt.createCnt; i++ {
|
||||
servers.TestKmsWorker(t, conn, wrapper)
|
||||
server.TestKmsWorker(t, conn, wrapper)
|
||||
}
|
||||
// the purpose of these tests isn't to check liveness, so disable
|
||||
// liveness checking.
|
||||
opts := append(tt.opts, servers.WithLiveness(-1))
|
||||
opts := append(tt.opts, server.WithLiveness(-1))
|
||||
got, err := repo.ListWorkers(ctx, tt.reqScopes, opts...)
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
@@ -568,13 +568,13 @@ func TestListWorkers_WithLiveness(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kms)
|
||||
serversRepo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
ctx := context.Background()
|
||||
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker3 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := server.TestKmsWorker(t, conn, wrapper)
|
||||
worker3 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
// Sleep the default liveness time (15sec currently) +1s
|
||||
time.Sleep(time.Second * 16)
|
||||
@@ -582,13 +582,13 @@ func TestListWorkers_WithLiveness(t *testing.T) {
|
||||
// Push an upsert to the first worker so that its status has been
|
||||
// updated.
|
||||
_, err = serversRepo.UpsertWorkerStatus(ctx,
|
||||
servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(worker1.GetName()),
|
||||
servers.WithAddress(worker1.GetAddress())),
|
||||
servers.WithPublicId(worker1.GetPublicId()))
|
||||
server.NewWorker(scope.Global.String(),
|
||||
server.WithName(worker1.GetName()),
|
||||
server.WithAddress(worker1.GetAddress())),
|
||||
server.WithPublicId(worker1.GetPublicId()))
|
||||
require.NoError(err)
|
||||
|
||||
requireIds := func(expected []string, actual []*servers.Worker) {
|
||||
requireIds := func(expected []string, actual []*server.Worker) {
|
||||
require.Len(expected, len(actual))
|
||||
want := make(map[string]struct{})
|
||||
for _, v := range expected {
|
||||
@@ -611,21 +611,21 @@ func TestListWorkers_WithLiveness(t *testing.T) {
|
||||
|
||||
// Upsert second server.
|
||||
_, err = serversRepo.UpsertWorkerStatus(ctx,
|
||||
servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(worker2.GetName()),
|
||||
servers.WithAddress(worker2.GetAddress())),
|
||||
servers.WithPublicId(worker2.GetPublicId()))
|
||||
server.NewWorker(scope.Global.String(),
|
||||
server.WithName(worker2.GetName()),
|
||||
server.WithAddress(worker2.GetAddress())),
|
||||
server.WithPublicId(worker2.GetPublicId()))
|
||||
require.NoError(err)
|
||||
|
||||
// Static liveness. Should get two, so long as this did not take
|
||||
// more than 5s to execute.
|
||||
result, err = serversRepo.ListWorkers(ctx, []string{scope.Global.String()}, servers.WithLiveness(time.Second*5))
|
||||
result, err = serversRepo.ListWorkers(ctx, []string{scope.Global.String()}, server.WithLiveness(time.Second*5))
|
||||
require.NoError(err)
|
||||
require.Len(result, 2)
|
||||
requireIds([]string{worker1.GetPublicId(), worker2.GetPublicId()}, result)
|
||||
|
||||
// Liveness disabled, should get all three workers.
|
||||
result, err = serversRepo.ListWorkers(ctx, []string{scope.Global.String()}, servers.WithLiveness(-1))
|
||||
result, err = serversRepo.ListWorkers(ctx, []string{scope.Global.String()}, server.WithLiveness(-1))
|
||||
require.NoError(err)
|
||||
require.Len(result, 3)
|
||||
requireIds([]string{worker1.GetPublicId(), worker2.GetPublicId(), worker3.GetPublicId()}, result)
|
||||
@@ -638,7 +638,7 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
testKms := kms.TestKms(t, conn, wrapper)
|
||||
testRepo, err := servers.NewRepository(rw, rw, testKms)
|
||||
testRepo, err := server.NewRepository(rw, rw, testKms)
|
||||
require.NoError(t, err)
|
||||
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
@@ -648,27 +648,27 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
return "", errors.New(testCtx, errors.Internal, "test", "testNewIdFn-error")
|
||||
}
|
||||
|
||||
kmsWorker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
kmsWorker := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
rootStorage, err := servers.NewRepositoryStorage(testCtx, rw, rw, testKms)
|
||||
rootStorage, err := server.NewRepositoryStorage(testCtx, rw, rw, testKms)
|
||||
require.NoError(t, err)
|
||||
_, err = rotation.RotateRootCertificates(testCtx, rootStorage)
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
setup func() *servers.Worker
|
||||
repo *servers.Repository
|
||||
setup func() *server.Worker
|
||||
repo *server.Repository
|
||||
fetchReq *types.FetchNodeCredentialsRequest
|
||||
reader db.Reader
|
||||
opt []servers.Option
|
||||
opt []server.Option
|
||||
wantErr bool
|
||||
wantErrIs errors.Code
|
||||
wantErrContains string
|
||||
}{
|
||||
{
|
||||
name: "missing-worker",
|
||||
setup: func() *servers.Worker {
|
||||
setup: func() *server.Worker {
|
||||
return nil
|
||||
},
|
||||
repo: testRepo,
|
||||
@@ -678,10 +678,10 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "public-id-not-empty",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
var err error
|
||||
w.PublicId, err = db.NewPublicId(servers.WorkerPrefix)
|
||||
w.PublicId, err = db.NewPublicId(server.WorkerPrefix)
|
||||
require.NoError(t, err)
|
||||
return w
|
||||
},
|
||||
@@ -692,8 +692,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "empty-scope-id",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
w.ScopeId = ""
|
||||
return w
|
||||
},
|
||||
@@ -704,8 +704,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "org-scope-id",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(org.PublicId)
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(org.PublicId)
|
||||
return w
|
||||
},
|
||||
repo: testRepo,
|
||||
@@ -715,29 +715,29 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "new-id-error",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
return w
|
||||
},
|
||||
repo: testRepo,
|
||||
opt: []servers.Option{servers.WithNewIdFunc(testNewIdFn)},
|
||||
opt: []server.Option{server.WithNewIdFunc(testNewIdFn)},
|
||||
wantErr: true,
|
||||
wantErrIs: errors.Internal,
|
||||
wantErrContains: "testNewIdFn-error",
|
||||
},
|
||||
{
|
||||
name: "create-error",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
return w
|
||||
},
|
||||
repo: func() *servers.Repository {
|
||||
repo: func() *server.Repository {
|
||||
conn, mock := db.TestSetupWithMock(t)
|
||||
writer := db.New(conn)
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectQuery(`INSERT`).WillReturnError(errors.New(testCtx, errors.Internal, "test", "create-error"))
|
||||
mock.ExpectRollback()
|
||||
r, err := servers.NewRepository(rw, writer, testKms)
|
||||
r, err := server.NewRepository(rw, writer, testKms)
|
||||
require.NoError(t, err)
|
||||
return r
|
||||
}(),
|
||||
@@ -746,8 +746,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no worker reported address",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
w.Address = "foo"
|
||||
return w
|
||||
},
|
||||
@@ -758,8 +758,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no last status update",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
w.LastStatusTime = timestamp.Now()
|
||||
return w
|
||||
},
|
||||
@@ -770,8 +770,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no-database-key",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
return w
|
||||
},
|
||||
reader: rw,
|
||||
@@ -788,12 +788,12 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
return fetchReq
|
||||
}(),
|
||||
repo: func() *servers.Repository {
|
||||
repo: func() *server.Repository {
|
||||
mockConn, mock := db.TestSetupWithMock(t)
|
||||
mock.ExpectQuery(`SELECT`).WillReturnRows(sqlmock.NewRows([]string{"version", "create_time"}).AddRow(migrations.Version, time.Now()))
|
||||
mock.ExpectQuery(`SELECT`).WillReturnError(errors.New(context.Background(), errors.Internal, "test", "no-database-key"))
|
||||
k := kms.TestKms(t, mockConn, wrapper)
|
||||
r, err := servers.NewRepository(rw, rw, k)
|
||||
r, err := server.NewRepository(rw, rw, k)
|
||||
require.NoError(t, err)
|
||||
return r
|
||||
}(),
|
||||
@@ -802,8 +802,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "bad-fetch-node-req",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
return w
|
||||
},
|
||||
reader: rw,
|
||||
@@ -814,8 +814,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "unique name violation with kms worker",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
w.Name = kmsWorker.GetName()
|
||||
return w
|
||||
},
|
||||
@@ -826,8 +826,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "success",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
w.Name = "success"
|
||||
return w
|
||||
},
|
||||
@@ -837,8 +837,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
// This case must follow the one above it.
|
||||
{
|
||||
name: "unique name violation with pki worker",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
w.Name = "success"
|
||||
return w
|
||||
},
|
||||
@@ -849,8 +849,8 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "success-with-fetch-node-req",
|
||||
setup: func() *servers.Worker {
|
||||
w := servers.NewWorker(scope.Global.String())
|
||||
setup: func() *server.Worker {
|
||||
w := server.NewWorker(scope.Global.String())
|
||||
w.Name = "success-with-fetch-node-req"
|
||||
return w
|
||||
},
|
||||
@@ -876,7 +876,7 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
testWorker := tc.setup()
|
||||
|
||||
tc.opt = append(tc.opt, servers.WithFetchNodeCredentialsRequest(tc.fetchReq))
|
||||
tc.opt = append(tc.opt, server.WithFetchNodeCredentialsRequest(tc.fetchReq))
|
||||
|
||||
got, err := tc.repo.CreateWorker(testCtx, testWorker, tc.opt...)
|
||||
if tc.wantErr {
|
||||
@@ -896,7 +896,7 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
assert.NotEmpty(got.UpdateTime)
|
||||
assert.NotEmpty(got.CreateTime)
|
||||
|
||||
found := &servers.Worker{
|
||||
found := &server.Worker{
|
||||
Worker: &store.Worker{
|
||||
PublicId: got.PublicId,
|
||||
},
|
||||
@@ -906,7 +906,7 @@ func TestRepository_CreateWorker(t *testing.T) {
|
||||
assert.Equal(got, found)
|
||||
|
||||
if tc.fetchReq != nil {
|
||||
worker := &servers.WorkerAuth{
|
||||
worker := &server.WorkerAuth{
|
||||
WorkerAuth: &store.WorkerAuth{},
|
||||
}
|
||||
require.NoError(tc.reader.LookupWhere(testCtx, worker, "worker_id = ?", []any{found.PublicId}))
|
||||
@@ -923,24 +923,24 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
wrapper := db.TestWrapper(t)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
|
||||
repo, err := servers.NewRepository(rw, rw, kmsCache)
|
||||
repo, err := server.NewRepository(rw, rw, kmsCache)
|
||||
require.NoError(t, err)
|
||||
|
||||
pkiCases := []struct {
|
||||
name string
|
||||
modifyWorker func(*testing.T, *servers.Worker)
|
||||
modifyWorker func(*testing.T, *server.Worker)
|
||||
path []string
|
||||
assertGot func(*testing.T, *servers.Worker)
|
||||
assertGot func(*testing.T, *server.Worker)
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "update name",
|
||||
modifyWorker: func(t *testing.T, w *servers.Worker) {
|
||||
modifyWorker: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
w.Name = "foo"
|
||||
},
|
||||
path: []string{"Name"},
|
||||
assertGot: func(t *testing.T, w *servers.Worker) {
|
||||
assertGot: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
assert.Equal(t, "foo", w.GetName())
|
||||
assert.Equal(t, uint32(2), w.GetVersion())
|
||||
@@ -950,12 +950,12 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "update description",
|
||||
modifyWorker: func(t *testing.T, w *servers.Worker) {
|
||||
modifyWorker: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
w.Description = "foo"
|
||||
},
|
||||
path: []string{"Description"},
|
||||
assertGot: func(t *testing.T, w *servers.Worker) {
|
||||
assertGot: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
assert.Equal(t, "foo", w.GetDescription())
|
||||
assert.Equal(t, uint32(2), w.GetVersion())
|
||||
@@ -966,7 +966,7 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
}
|
||||
for _, tt := range pkiCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
wkr := servers.TestPkiWorker(t, conn, wrapper)
|
||||
wkr := server.TestPkiWorker(t, conn, wrapper)
|
||||
defer func() {
|
||||
_, err := repo.DeleteWorker(ctx, wkr.GetPublicId())
|
||||
require.NoError(t, err)
|
||||
@@ -986,19 +986,19 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
// Clear cases
|
||||
clearCases := []struct {
|
||||
name string
|
||||
modifyWorker func(*testing.T, *servers.Worker)
|
||||
modifyWorker func(*testing.T, *server.Worker)
|
||||
path []string
|
||||
assertGot func(*testing.T, *servers.Worker)
|
||||
assertGot func(*testing.T, *server.Worker)
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "clear name",
|
||||
modifyWorker: func(t *testing.T, w *servers.Worker) {
|
||||
modifyWorker: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
w.Name = ""
|
||||
},
|
||||
path: []string{"Name"},
|
||||
assertGot: func(t *testing.T, w *servers.Worker) {
|
||||
assertGot: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
assert.Empty(t, w.GetName())
|
||||
assert.Nil(t, w.GetLastStatusTime())
|
||||
@@ -1007,12 +1007,12 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "clear description",
|
||||
modifyWorker: func(t *testing.T, w *servers.Worker) {
|
||||
modifyWorker: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
w.Description = ""
|
||||
},
|
||||
path: []string{"Description"},
|
||||
assertGot: func(t *testing.T, w *servers.Worker) {
|
||||
assertGot: func(t *testing.T, w *server.Worker) {
|
||||
t.Helper()
|
||||
assert.Empty(t, w.GetDescription())
|
||||
assert.Nil(t, w.GetLastStatusTime())
|
||||
@@ -1022,7 +1022,7 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
}
|
||||
for _, tt := range clearCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
wkr := servers.TestPkiWorker(t, conn, wrapper)
|
||||
wkr := server.TestPkiWorker(t, conn, wrapper)
|
||||
wkr.Name = tt.name
|
||||
wkr.Description = tt.name
|
||||
wkr, _, err := repo.UpdateWorker(ctx, wkr, 1, []string{"name", "description"})
|
||||
@@ -1041,7 +1041,7 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("version is wrong", func(t *testing.T) {
|
||||
wkr := servers.TestPkiWorker(t, conn, wrapper)
|
||||
wkr := server.TestPkiWorker(t, conn, wrapper)
|
||||
wkr.Name = "version is wrong"
|
||||
result, numUpdated, err := repo.UpdateWorker(ctx, wkr, 2, []string{"name"})
|
||||
require.NoError(t, err)
|
||||
@@ -1051,7 +1051,7 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
|
||||
errorCases := []struct {
|
||||
name string
|
||||
input *servers.Worker
|
||||
input *server.Worker
|
||||
path []string
|
||||
version uint32
|
||||
wantErr *errors.Template
|
||||
@@ -1064,21 +1064,21 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "empty path",
|
||||
input: servers.TestPkiWorker(t, conn, wrapper),
|
||||
input: server.TestPkiWorker(t, conn, wrapper),
|
||||
version: 1,
|
||||
wantErr: errors.T(errors.EmptyFieldMask),
|
||||
},
|
||||
{
|
||||
name: "0 version",
|
||||
input: servers.TestPkiWorker(t, conn, wrapper),
|
||||
input: server.TestPkiWorker(t, conn, wrapper),
|
||||
path: []string{"name"},
|
||||
version: 0,
|
||||
wantErr: errors.T(errors.InvalidParameter),
|
||||
},
|
||||
{
|
||||
name: "changing kms name",
|
||||
input: func() *servers.Worker {
|
||||
w := servers.TestKmsWorker(t, conn, wrapper)
|
||||
input: func() *server.Worker {
|
||||
w := server.TestKmsWorker(t, conn, wrapper)
|
||||
w.Name = "some change"
|
||||
w.Description = ""
|
||||
w.Type = ""
|
||||
@@ -1089,8 +1089,8 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "clearing kms name",
|
||||
input: func() *servers.Worker {
|
||||
w := servers.TestKmsWorker(t, conn, wrapper)
|
||||
input: func() *server.Worker {
|
||||
w := server.TestKmsWorker(t, conn, wrapper)
|
||||
w.Name = ""
|
||||
w.Description = ""
|
||||
w.Type = ""
|
||||
@@ -1101,8 +1101,8 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "changing kms description",
|
||||
input: func() *servers.Worker {
|
||||
w := servers.TestKmsWorker(t, conn, wrapper)
|
||||
input: func() *server.Worker {
|
||||
w := server.TestKmsWorker(t, conn, wrapper)
|
||||
w.Description = "some change"
|
||||
w.Name = ""
|
||||
w.Type = ""
|
||||
@@ -1113,8 +1113,8 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "clearing kms description",
|
||||
input: func() *servers.Worker {
|
||||
w := servers.TestKmsWorker(t, conn, wrapper)
|
||||
input: func() *server.Worker {
|
||||
w := server.TestKmsWorker(t, conn, wrapper)
|
||||
w.Description = ""
|
||||
w.Name = ""
|
||||
w.Type = ""
|
||||
@@ -1125,8 +1125,8 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "no public id",
|
||||
input: func() *servers.Worker {
|
||||
w := servers.TestPkiWorker(t, conn, wrapper)
|
||||
input: func() *server.Worker {
|
||||
w := server.TestPkiWorker(t, conn, wrapper)
|
||||
w.PublicId = ""
|
||||
return w
|
||||
}(),
|
||||
@@ -1136,15 +1136,15 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "unrecognized path",
|
||||
input: servers.TestPkiWorker(t, conn, wrapper),
|
||||
input: server.TestPkiWorker(t, conn, wrapper),
|
||||
path: []string{"UnrecognizedField"},
|
||||
version: 1,
|
||||
wantErr: errors.T(errors.InvalidFieldMask),
|
||||
},
|
||||
{
|
||||
name: "not found worker",
|
||||
input: func() *servers.Worker {
|
||||
w := servers.TestPkiWorker(t, conn, wrapper)
|
||||
input: func() *server.Worker {
|
||||
w := server.TestPkiWorker(t, conn, wrapper)
|
||||
w.PublicId = "w_notfoundworker"
|
||||
return w
|
||||
}(),
|
||||
@@ -1154,12 +1154,12 @@ func TestRepository_UpdateWorker(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "duplicate name",
|
||||
input: func() *servers.Worker {
|
||||
w1 := servers.TestPkiWorker(t, conn, wrapper)
|
||||
input: func() *server.Worker {
|
||||
w1 := server.TestPkiWorker(t, conn, wrapper)
|
||||
w1.Name = "somenamethatijustmadeup"
|
||||
w1, _, err := repo.UpdateWorker(ctx, w1, w1.Version, []string{"name"}, nil)
|
||||
require.NoError(t, err)
|
||||
w2 := servers.TestPkiWorker(t, conn, wrapper)
|
||||
w2 := server.TestPkiWorker(t, conn, wrapper)
|
||||
w2.Name = w1.Name
|
||||
return w2
|
||||
}(),
|
||||
+23
-23
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/go-dbw"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
@@ -43,7 +43,7 @@ type WorkerAuthRepositoryStorage struct {
|
||||
|
||||
// NewRepositoryStorage creates a new WorkerAuthRepositoryStorage that implements the Storage interface
|
||||
func NewRepositoryStorage(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms) (*WorkerAuthRepositoryStorage, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).NewRepositoryStorage"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).NewRepositoryStorage"
|
||||
switch {
|
||||
case isNil(r):
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "reader is nil")
|
||||
@@ -64,7 +64,7 @@ func NewRepositoryStorage(ctx context.Context, r db.Reader, w db.Writer, kms *km
|
||||
|
||||
// Store implements the Storage interface
|
||||
func (r *WorkerAuthRepositoryStorage) Store(ctx context.Context, msg nodee.MessageWithId) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).Store"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).Store"
|
||||
if err := types.ValidateMessage(msg); err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func (r *WorkerAuthRepositoryStorage) Store(ctx context.Context, msg nodee.Messa
|
||||
// * the workerAuth record is stored with a reference to a worker
|
||||
// * certificate bundles are stored with a reference to the workerAuth record and issuing root certificate
|
||||
func StoreNodeInformationTx(ctx context.Context, writer db.Writer, databaseWrapper wrapping.Wrapper, node *types.NodeInformation, _ ...Option) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).storeNodeInformation"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).storeNodeInformation"
|
||||
if isNil(writer) {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing writer")
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func storeWorkerCertBundle(
|
||||
workerKeyIdentifier string,
|
||||
writer db.Writer,
|
||||
) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).storeWorkerCertBundle"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).storeWorkerCertBundle"
|
||||
if bundle == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing CertificateBundle")
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func storeWorkerCertBundle(
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) convertRootCertificate(ctx context.Context, cert *types.RootCertificate) (*RootCertificate, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).convertRootCertificate"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).convertRootCertificate"
|
||||
if cert == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing RootCertificate")
|
||||
}
|
||||
@@ -252,7 +252,7 @@ func (r *WorkerAuthRepositoryStorage) convertRootCertificate(ctx context.Context
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) storeRootCertificates(ctx context.Context, cert *types.RootCertificates) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).storeRootCertificates"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).storeRootCertificates"
|
||||
if cert == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing RootCertificate")
|
||||
}
|
||||
@@ -330,7 +330,7 @@ func (r *WorkerAuthRepositoryStorage) storeRootCertificates(ctx context.Context,
|
||||
// Load loads values into the given message. The message must be populated
|
||||
// with the ID value. If not found, the returned error should be ErrNotFound.
|
||||
func (r *WorkerAuthRepositoryStorage) Load(ctx context.Context, msg nodee.MessageWithId) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).Load"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).Load"
|
||||
if err := types.ValidateMessage(msg); err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
@@ -365,7 +365,7 @@ func (r *WorkerAuthRepositoryStorage) Load(ctx context.Context, msg nodee.Messag
|
||||
// * the workerAuth record
|
||||
// * its certificate bundles
|
||||
func (r *WorkerAuthRepositoryStorage) loadNodeInformation(ctx context.Context, node *types.NodeInformation) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).loadNodeInformation"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).loadNodeInformation"
|
||||
if node == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing NodeInformation")
|
||||
}
|
||||
@@ -417,7 +417,7 @@ func (r *WorkerAuthRepositoryStorage) loadNodeInformation(ctx context.Context, n
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) findCertBundles(ctx context.Context, workerKeyId string) ([]*types.CertificateBundle, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).findCertBundles"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).findCertBundles"
|
||||
if workerKeyId == "" {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "empty workerKeyId")
|
||||
}
|
||||
@@ -441,7 +441,7 @@ func (r *WorkerAuthRepositoryStorage) findCertBundles(ctx context.Context, worke
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) findWorkerAuth(ctx context.Context, node *types.NodeInformation) (*WorkerAuth, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).findWorkerAuth"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).findWorkerAuth"
|
||||
if node == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "node is nil")
|
||||
}
|
||||
@@ -461,7 +461,7 @@ func (r *WorkerAuthRepositoryStorage) findWorkerAuth(ctx context.Context, node *
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) loadRootCertificates(ctx context.Context, cert *types.RootCertificates) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).loadRootCertificates"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).loadRootCertificates"
|
||||
if cert == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "cert is nil")
|
||||
}
|
||||
@@ -531,7 +531,7 @@ func (r *WorkerAuthRepositoryStorage) loadRootCertificates(ctx context.Context,
|
||||
// Remove implements the Storage interface.
|
||||
// Remove removes the given message. Only the ID field of the message is considered.
|
||||
func (r *WorkerAuthRepositoryStorage) Remove(ctx context.Context, msg nodee.MessageWithId) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).Remove"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).Remove"
|
||||
if err := types.ValidateMessage(msg); err != nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "given message cannot be removed as it has no ID")
|
||||
}
|
||||
@@ -556,7 +556,7 @@ func (r *WorkerAuthRepositoryStorage) Remove(ctx context.Context, msg nodee.Mess
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) removeNodeInformation(ctx context.Context, id string) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).removeNodeInformation"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).removeNodeInformation"
|
||||
if id == "" {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "empty id")
|
||||
}
|
||||
@@ -586,7 +586,7 @@ func (r *WorkerAuthRepositoryStorage) removeNodeInformation(ctx context.Context,
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) removeCertificateAuthority(ctx context.Context, cert *types.RootCertificates) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).removeCertificateAuthority"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).removeCertificateAuthority"
|
||||
|
||||
var result rootCertificatesVersion
|
||||
err := mapstructure.Decode(cert.State.AsMap(), &result)
|
||||
@@ -637,7 +637,7 @@ func (r *WorkerAuthRepositoryStorage) removeCertificateAuthority(ctx context.Con
|
||||
}
|
||||
|
||||
func (r *WorkerAuthRepositoryStorage) removeRootCertificateWithWriter(ctx context.Context, id string, writer db.Writer) error {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).removeRootCertificateWithWriter"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).removeRootCertificateWithWriter"
|
||||
if id == "" {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "empty id")
|
||||
}
|
||||
@@ -660,7 +660,7 @@ func (r *WorkerAuthRepositoryStorage) removeRootCertificateWithWriter(ctx contex
|
||||
// List implements the Storage interface.
|
||||
// List returns a list of IDs; the type of the message is used to disambiguate what to list.
|
||||
func (r *WorkerAuthRepositoryStorage) List(ctx context.Context, msg proto.Message) ([]string, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).List"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).List"
|
||||
|
||||
var err error
|
||||
var ids []string
|
||||
@@ -683,7 +683,7 @@ func (r *WorkerAuthRepositoryStorage) List(ctx context.Context, msg proto.Messag
|
||||
|
||||
// Returns a list of node auth IDs
|
||||
func (r *WorkerAuthRepositoryStorage) listNodeInformation(ctx context.Context) ([]string, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).listNodeCertificates"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).listNodeCertificates"
|
||||
|
||||
var where string
|
||||
var nodeAuths []*WorkerAuth
|
||||
@@ -701,7 +701,7 @@ func (r *WorkerAuthRepositoryStorage) listNodeInformation(ctx context.Context) (
|
||||
|
||||
// Returns a list of root certificates
|
||||
func (r *WorkerAuthRepositoryStorage) listRootCertificates(ctx context.Context) ([]string, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).listRootCertificates"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).listRootCertificates"
|
||||
|
||||
var where string
|
||||
var rootCertificates []*RootCertificate
|
||||
@@ -720,7 +720,7 @@ func (r *WorkerAuthRepositoryStorage) listRootCertificates(ctx context.Context)
|
||||
|
||||
// Returns a list of certificate authorities
|
||||
func (r *WorkerAuthRepositoryStorage) listCertificateAuthority(ctx context.Context) ([]string, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).listCertificateAuthority"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).listCertificateAuthority"
|
||||
|
||||
var where string
|
||||
var rootCertificates []*CertificateAuthority
|
||||
@@ -739,7 +739,7 @@ func (r *WorkerAuthRepositoryStorage) listCertificateAuthority(ctx context.Conte
|
||||
|
||||
// encrypt value before writing it to the db
|
||||
func encrypt(ctx context.Context, value []byte, wrapper wrapping.Wrapper) ([]byte, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).encrypt"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).encrypt"
|
||||
if value == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing value")
|
||||
}
|
||||
@@ -759,7 +759,7 @@ func encrypt(ctx context.Context, value []byte, wrapper wrapping.Wrapper) ([]byt
|
||||
}
|
||||
|
||||
func decrypt(ctx context.Context, value []byte, wrapper wrapping.Wrapper) ([]byte, error) {
|
||||
const op = "servers.(WorkerAuthRepositoryStorage).decrypt"
|
||||
const op = "server.(WorkerAuthRepositoryStorage).decrypt"
|
||||
if value == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing value")
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
|
||||
timestamp "github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -59,7 +59,7 @@ type RootCertificateKeys struct {
|
||||
func newRootCertificate(ctx context.Context, serialNumber uint64, certificate []byte, notValidBefore, notValidAfter *timestamp.Timestamp,
|
||||
rootCertificateKeys RootCertificateKeys, keyId string, state CertificateState,
|
||||
) (*RootCertificate, error) {
|
||||
const op = "servers.newRootCertificate"
|
||||
const op = "server.newRootCertificate"
|
||||
|
||||
if &serialNumber == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "no serialNumber")
|
||||
@@ -117,7 +117,7 @@ func (r *RootCertificate) clone() *RootCertificate {
|
||||
|
||||
// Validate the RootCertificate. On success, return nil
|
||||
func (r *RootCertificate) ValidateNewRootCertificate(ctx context.Context) error {
|
||||
const op = "servers.(RootCertificate).ValidateNewRootCertificate"
|
||||
const op = "server.(RootCertificate).ValidateNewRootCertificate"
|
||||
if &r.SerialNumber == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing SerialNumber")
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// protoc (unknown)
|
||||
// source: controller/servers/v1/servers.proto
|
||||
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -192,11 +192,11 @@ var file_controller_servers_v1_servers_proto_rawDesc = []byte{
|
||||
0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x67, 0x50, 0x61, 0x69,
|
||||
0x72, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x15, 0x0a, 0x06, 0x6b, 0x65, 0x79, 0x5f, 0x69,
|
||||
0x64, 0x18, 0x32, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x42, 0x38,
|
||||
0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73,
|
||||
0x64, 0x18, 0x32, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x42, 0x36,
|
||||
0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73,
|
||||
0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73,
|
||||
0x3b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3b,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// Accepts the nodeenrollment option, WithCertificateLifetime(time.Duration) to specify the lifetime
|
||||
// of the generated cert(s)
|
||||
func RotateRoots(ctx context.Context, workerAuthRepo *WorkerAuthRepositoryStorage, opt ...nodeenrollment.Option) error {
|
||||
const op = "servers.RotateRoots"
|
||||
const op = "server.RotateRoots"
|
||||
if workerAuthRepo == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing workerAuthRepo")
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
// CertificateState defines the possible states for a workerauth certificate
|
||||
type CertificateState string
|
||||
@@ -135,11 +135,11 @@ var file_controller_storage_servers_store_v1_controller_proto_rawDesc = []byte{
|
||||
0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65,
|
||||
0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68,
|
||||
0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68,
|
||||
0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72,
|
||||
0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
File renamed without changes.
+3
-3
@@ -253,11 +253,11 @@ var file_controller_storage_servers_store_v1_root_certificate_proto_rawDesc = []
|
||||
0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x50, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
|
||||
0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x73, 0x75, 0x69, 0x6e, 0x67,
|
||||
0x5f, 0x63, 0x61, 0x18, 0x5a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x73, 0x73, 0x75, 0x69,
|
||||
0x6e, 0x67, 0x43, 0x61, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6e, 0x67, 0x43, 0x61, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75,
|
||||
0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f,
|
||||
0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72,
|
||||
0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -294,11 +294,11 @@ var file_controller_storage_servers_store_v1_worker_proto_rawDesc = []byte{
|
||||
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1e, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f,
|
||||
0x75, 0x72, 0x63, 0x65, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72,
|
||||
0x63, 0x65, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x63, 0x65, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x76, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -242,11 +242,11 @@ var file_controller_storage_servers_store_v1_worker_auth_proto_rawDesc = []byte{
|
||||
0x09, 0x52, 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x65, 0x6e,
|
||||
0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x62,
|
||||
0x75, 0x6e, 0x64, 0x6c, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x63, 0x65, 0x72,
|
||||
0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f,
|
||||
0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61,
|
||||
0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b,
|
||||
0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73,
|
||||
0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/nodeenrollment"
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/fatih/structs"
|
||||
"github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
)
|
||||
@@ -40,7 +40,7 @@ type workerAuthWorkerId struct {
|
||||
// This is intended for use in worker authorization; AuthorizeNode in the lib accepts the option WithState
|
||||
// so that the workerId is passed through to storage and associated with a WorkerAuth record
|
||||
func AttachWorkerIdToState(ctx context.Context, workerId string) (*structpb.Struct, error) {
|
||||
const op = "servers.(Worker).AttachWorkerIdToState"
|
||||
const op = "server.(Worker).AttachWorkerIdToState"
|
||||
if workerId == "" {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing workerId")
|
||||
}
|
||||
@@ -187,7 +187,7 @@ type workerAggregate struct {
|
||||
}
|
||||
|
||||
func (a *workerAggregate) toWorker(ctx context.Context) (*Worker, error) {
|
||||
const op = "servers.(workerAggregate).toWorker"
|
||||
const op = "server.(workerAggregate).toWorker"
|
||||
worker := &Worker{
|
||||
Worker: &store.Worker{
|
||||
PublicId: a.PublicId,
|
||||
@@ -227,7 +227,7 @@ func tagsFromAggregatedTagString(ctx context.Context, s string) ([]*Tag, error)
|
||||
if s == "" {
|
||||
return nil, nil
|
||||
}
|
||||
const op = "servers.tagsFromAggregatedTagString"
|
||||
const op = "server.tagsFromAggregatedTagString"
|
||||
const aggregateDelimiter = "Z"
|
||||
const pairDelimiter = "Y"
|
||||
var tags []*Tag
|
||||
@@ -1,10 +1,10 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ type WorkerKeys struct {
|
||||
}
|
||||
|
||||
func newWorkerAuth(ctx context.Context, workerKeyIdentifier, workerId string, opt ...Option) (*WorkerAuth, error) {
|
||||
const op = "servers.newWorkerAuth"
|
||||
const op = "server.newWorkerAuth"
|
||||
opts := getOpts(opt...)
|
||||
|
||||
if workerKeyIdentifier == "" {
|
||||
@@ -71,7 +71,7 @@ func (w *WorkerAuth) clone() *WorkerAuth {
|
||||
|
||||
// Validate is called before storing a WorkerAuth in the db
|
||||
func (w *WorkerAuth) ValidateNewWorkerAuth(ctx context.Context) error {
|
||||
const op = "servers.(WorkerAuth).validateNewWorkerAuth"
|
||||
const op = "server.(WorkerAuth).validateNewWorkerAuth"
|
||||
if w.WorkerKeyIdentifier == "" {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing WorkerKeyIdentifier")
|
||||
}
|
||||
@@ -118,7 +118,7 @@ type WorkerCertBundle struct {
|
||||
}
|
||||
|
||||
func newWorkerCertBundle(ctx context.Context, certificatePublicKey []byte, workerKeyIdentifier string, certBundle []byte) (*WorkerCertBundle, error) {
|
||||
const op = "servers.newWorkerCertBundle"
|
||||
const op = "server.newWorkerCertBundle"
|
||||
|
||||
if certificatePublicKey == nil {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "no certificatePublicKey")
|
||||
@@ -155,7 +155,7 @@ func (w *WorkerCertBundle) clone() *WorkerCertBundle {
|
||||
|
||||
// Validate is called before storing a WorkerCertBundle in the db
|
||||
func (w *WorkerCertBundle) ValidateNewWorkerCertBundle(ctx context.Context) error {
|
||||
const op = "servers.(WorkerAuth).validateNewWorkerCertBundle"
|
||||
const op = "server.(WorkerAuth).validateNewWorkerCertBundle"
|
||||
if w.RootCertificatePublicKey == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing CertificatePublicKey")
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
// A Tag is a custom key/value pair which can be attached to a Worker.
|
||||
// Multiple Tags may contain the same key and different values in which
|
||||
@@ -1,11 +1,11 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package servers
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
@@ -11,13 +11,13 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
)
|
||||
|
||||
// deadWorkerConnCloseMinGrace is the minimum allowable setting for
|
||||
// the closeConnectionsForDeadWorkers method. This is synced with
|
||||
// the default server liveness setting.
|
||||
const deadWorkerConnCloseMinGrace = servers.DefaultLiveness
|
||||
const deadWorkerConnCloseMinGrace = server.DefaultLiveness
|
||||
|
||||
type closeConnectionsForDeadWorkersResult struct {
|
||||
WorkerId string
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -35,7 +35,7 @@ func TestSessionConnectionCleanupJob(t *testing.T) {
|
||||
wrapper := db.TestWrapper(t)
|
||||
iamRepo := iam.TestRepo(t, conn, wrapper)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kms)
|
||||
serversRepo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
sessionRepo, err := NewRepository(rw, rw, kms)
|
||||
connectionRepo, err := NewConnectionRepository(ctx, rw, rw, kms)
|
||||
@@ -45,8 +45,8 @@ func TestSessionConnectionCleanupJob(t *testing.T) {
|
||||
|
||||
// Create two "workers". One will remain untouched while the other "goes
|
||||
// away and comes back" (worker 2).
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
// Create a few sessions on each, activate, and authorize a connection
|
||||
var connIds []string
|
||||
@@ -109,10 +109,10 @@ func TestSessionConnectionCleanupJob(t *testing.T) {
|
||||
|
||||
// Push an upsert to the first worker so that its status has been
|
||||
// updated.
|
||||
_, err = serversRepo.UpsertWorkerStatus(ctx, servers.NewWorker(scope.Global.String(),
|
||||
servers.WithName(worker1.GetName()),
|
||||
servers.WithAddress(worker1.GetAddress())),
|
||||
servers.WithPublicId(worker1.GetPublicId()))
|
||||
_, err = serversRepo.UpsertWorkerStatus(ctx, server.NewWorker(scope.Global.String(),
|
||||
server.WithName(worker1.GetName()),
|
||||
server.WithAddress(worker1.GetAddress())),
|
||||
server.WithPublicId(worker1.GetPublicId()))
|
||||
require.NoError(err)
|
||||
|
||||
// Run the job.
|
||||
@@ -185,7 +185,7 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
gracePeriod := 1 * time.Second
|
||||
connRepo, err := NewConnectionRepository(ctx, rw, rw, kms)
|
||||
require.NoError(err)
|
||||
serversRepo, err := servers.NewRepository(rw, rw, kms)
|
||||
serversRepo, err := server.NewRepository(rw, rw, kms)
|
||||
require.NoError(err)
|
||||
|
||||
job, err := newSessionConnectionCleanupJob(rw, deadWorkerConnCloseMinGrace)
|
||||
@@ -199,10 +199,10 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
// firstly, the last worker will have no connections at all, and we will be
|
||||
// closing the others in stages to test multiple servers being closed at
|
||||
// once.
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker3 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker4 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := server.TestKmsWorker(t, conn, wrapper)
|
||||
worker3 := server.TestKmsWorker(t, conn, wrapper)
|
||||
worker4 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
// Create sessions on the first three, activate, and authorize connections
|
||||
var worker1ConnIds, worker2ConnIds, worker3ConnIds []string
|
||||
@@ -291,11 +291,11 @@ func TestCloseConnectionsForDeadWorkers(t *testing.T) {
|
||||
// updateServer is a helper for updating the update time for our
|
||||
// servers. The controller is read back so that we can reference
|
||||
// the most up-to-date fields.
|
||||
updateServer := func(t *testing.T, w *servers.Worker) *servers.Worker {
|
||||
updateServer := func(t *testing.T, w *server.Worker) *server.Worker {
|
||||
t.Helper()
|
||||
pubId := w.GetPublicId()
|
||||
w.PublicId = ""
|
||||
wkr, err := serversRepo.UpsertWorkerStatus(ctx, w, servers.WithPublicId(pubId))
|
||||
wkr, err := serversRepo.UpsertWorkerStatus(ctx, w, server.WithPublicId(pubId))
|
||||
require.NoError(err)
|
||||
return wkr
|
||||
}
|
||||
@@ -464,7 +464,7 @@ func TestCloseWorkerlessConnections(t *testing.T) {
|
||||
}
|
||||
|
||||
// Setup deleted worker connections
|
||||
deletedWorker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
deletedWorker := server.TestKmsWorker(t, conn, wrapper)
|
||||
dActiveConn := createConnection(deletedWorker.GetPublicId())
|
||||
dClosedConn := createConnection(deletedWorker.GetPublicId())
|
||||
connRepo.closeConnections(ctx, []CloseWith{{
|
||||
@@ -477,7 +477,7 @@ func TestCloseWorkerlessConnections(t *testing.T) {
|
||||
require.NoError(err)
|
||||
|
||||
// Non deleted worker case
|
||||
activeWorker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
activeWorker := server.TestKmsWorker(t, conn, wrapper)
|
||||
activeConn := createConnection(activeWorker.GetPublicId())
|
||||
closedConn := createConnection(activeWorker.GetPublicId())
|
||||
connRepo.closeConnections(ctx, []CloseWith{{
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/oplog"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -359,8 +359,8 @@ func TestRepository_orphanedConnections(t *testing.T) {
|
||||
|
||||
// Create two "workers". One will remain untouched while the other "goes
|
||||
// away and comes back" (worker 2).
|
||||
worker1 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker1 := server.TestKmsWorker(t, conn, wrapper)
|
||||
worker2 := server.TestKmsWorker(t, conn, wrapper)
|
||||
|
||||
// Create a few sessions on each, activate, and authorize a connection
|
||||
var connIds []string
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
@@ -36,7 +36,7 @@ func TestService_AuthorizeConnection(t *testing.T) {
|
||||
composedOf.ExpirationTime = exp
|
||||
}
|
||||
s := TestSession(t, conn, wrapper, composedOf)
|
||||
srv := servers.TestKmsWorker(t, conn, wrapper)
|
||||
srv := server.TestKmsWorker(t, conn, wrapper)
|
||||
testServer = srv.PublicId
|
||||
tofu := TestTofu(t)
|
||||
_, _, err := repo.ActivateSession(context.Background(), s.PublicId, s.Version, tofu)
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/servers/store"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
@@ -26,7 +26,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
org, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
||||
|
||||
serverRepo, _ := servers.NewRepository(rw, rw, kms)
|
||||
serverRepo, _ := server.NewRepository(rw, rw, kms)
|
||||
_, err := serverRepo.UpsertController(ctx, &store.Controller{
|
||||
PrivateId: "test_controller1",
|
||||
Address: "127.0.0.1",
|
||||
@@ -52,7 +52,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
)
|
||||
|
||||
type testCase struct {
|
||||
worker *servers.Worker
|
||||
worker *server.Worker
|
||||
req []session.StateReport
|
||||
want []session.StateReport
|
||||
orphanedConnections []string
|
||||
@@ -64,7 +64,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
{
|
||||
name: "No Sessions",
|
||||
caseFn: func(t *testing.T) testCase {
|
||||
worker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker := server.TestKmsWorker(t, conn, wrapper)
|
||||
return testCase{
|
||||
worker: worker,
|
||||
req: []session.StateReport{},
|
||||
@@ -75,7 +75,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
{
|
||||
name: "No Sessions already canceled",
|
||||
caseFn: func(t *testing.T) testCase {
|
||||
worker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker := server.TestKmsWorker(t, conn, wrapper)
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
HostId: h.GetPublicId(),
|
||||
@@ -107,7 +107,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
{
|
||||
name: "Still Active",
|
||||
caseFn: func(t *testing.T) testCase {
|
||||
worker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker := server.TestKmsWorker(t, conn, wrapper)
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
HostId: h.GetPublicId(),
|
||||
@@ -141,7 +141,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
{
|
||||
name: "SessionClosed",
|
||||
caseFn: func(t *testing.T) testCase {
|
||||
worker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker := server.TestKmsWorker(t, conn, wrapper)
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
HostId: h.GetPublicId(),
|
||||
@@ -181,7 +181,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
{
|
||||
name: "MultipleSessionsClosed",
|
||||
caseFn: func(t *testing.T) testCase {
|
||||
worker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker := server.TestKmsWorker(t, conn, wrapper)
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
HostId: h.GetPublicId(),
|
||||
@@ -248,7 +248,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
{
|
||||
name: "OrphanedConnection",
|
||||
caseFn: func(t *testing.T) testCase {
|
||||
worker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker := server.TestKmsWorker(t, conn, wrapper)
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
HostId: h.GetPublicId(),
|
||||
@@ -299,7 +299,7 @@ func TestWorkerStatusReport(t *testing.T) {
|
||||
{
|
||||
name: "MultipleSessionsAndOrphanedConnections",
|
||||
caseFn: func(t *testing.T) testCase {
|
||||
worker := servers.TestKmsWorker(t, conn, wrapper)
|
||||
worker := server.TestKmsWorker(t, conn, wrapper)
|
||||
sess := session.TestSession(t, conn, wrapper, session.ComposedOf{
|
||||
UserId: uId,
|
||||
HostId: h.GetPublicId(),
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -74,7 +74,7 @@ func Test_TestWorker(t *testing.T) {
|
||||
require := require.New(t)
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
wrapper := db.TestWrapper(t)
|
||||
w := servers.TestKmsWorker(t, conn, wrapper)
|
||||
w := server.TestKmsWorker(t, conn, wrapper)
|
||||
require.NotNil(w)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller"
|
||||
"github.com/hashicorp/boundary/internal/daemon/worker"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -54,10 +54,10 @@ func TestWorkerReplay(t *testing.T) {
|
||||
require.Equal(t, 1, strings.Count(string(logBuf), "worker successfully authed"))
|
||||
|
||||
// Assert we have the expected nonce in the DB
|
||||
nonces, err := c1.ServersRepo().ListNonces(c1.Context(), servers.NoncePurposeWorkerAuth)
|
||||
nonces, err := c1.ServersRepo().ListNonces(c1.Context(), server.NoncePurposeWorkerAuth)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, nonces, 1)
|
||||
require.Equal(t, &servers.Nonce{Nonce: "test_noncetest_nonce", Purpose: servers.NoncePurposeWorkerAuth}, nonces[0])
|
||||
require.Equal(t, &server.Nonce{Nonce: "test_noncetest_nonce", Purpose: server.NoncePurposeWorkerAuth}, nonces[0])
|
||||
|
||||
require.NoError(t, w1.Worker().Shutdown())
|
||||
|
||||
@@ -81,8 +81,8 @@ func TestWorkerReplay(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, strings.Count(string(logBuf), "worker successfully authed"))
|
||||
|
||||
nonces, err = c1.ServersRepo().ListNonces(c1.Context(), servers.NoncePurposeWorkerAuth)
|
||||
nonces, err = c1.ServersRepo().ListNonces(c1.Context(), server.NoncePurposeWorkerAuth)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, nonces, 1)
|
||||
require.Equal(t, &servers.Nonce{Nonce: "test_noncetest_nonce", Purpose: servers.NoncePurposeWorkerAuth}, nonces[0])
|
||||
require.Equal(t, &server.Nonce{Nonce: "test_noncetest_nonce", Purpose: server.NoncePurposeWorkerAuth}, nonces[0])
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/servers"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/target/tcp"
|
||||
@@ -129,7 +129,7 @@ func TestGenerateSessionBenchmarkTemplateDumps(t *testing.T) {
|
||||
require.NoError(err)
|
||||
connRepo, err := session.NewConnectionRepository(ctx, rw, rw, kms)
|
||||
require.NoError(err)
|
||||
_ = servers.TestKmsWorker(t, conn, wrap)
|
||||
_ = server.TestKmsWorker(t, conn, wrap)
|
||||
|
||||
usersStart := time.Now()
|
||||
t.Logf("Populating %d users", scenario.users)
|
||||
|
||||
Reference in new issue
Block a user