diff --git a/internal/errors/code.go b/internal/errors/code.go index 8ff7681bb9..958b4c66de 100644 --- a/internal/errors/code.go +++ b/internal/errors/code.go @@ -40,6 +40,9 @@ const ( InvalidDynamicCredential Code = 116 // InvalidDynamicCredential represents that a dynamic credential for a session was in an invalid state JobAlreadyRunning Code = 117 // JobAlreadyRunning represents that a Job is already running when an attempt to run again was made SubtypeAlreadyRegistered Code = 118 // SubtypeAlreadyRegistered represents that a value has already been registered in the subtype registry system. + NoPathFound = 119 // NoPathFound represents an error when no path is found to a worker + WorkerNotFound = 120 // WorkerNotFound represents an error when a worker is not found in the graph of downstream workers + CycleFound = 121 // CycleFound represents an error when a cycle is found between a parent and child worker AuthAttemptExpired Code = 198 // AuthAttemptExpired represents an expired authentication attempt AuthMethodInactive Code = 199 // AuthMethodInactive represents an error that means the auth method is not active. diff --git a/internal/errors/code_test.go b/internal/errors/code_test.go index 8bc005f79a..631bd1d5f4 100644 --- a/internal/errors/code_test.go +++ b/internal/errors/code_test.go @@ -312,6 +312,21 @@ func TestCode_Both_String_Info(t *testing.T) { c: UnexpectedRowsAffected, want: UnexpectedRowsAffected, }, + { + name: "NoPathFound", + c: NoPathFound, + want: NoPathFound, + }, + { + name: "CycleFound", + c: CycleFound, + want: CycleFound, + }, + { + name: "WorkerNotFound", + c: WorkerNotFound, + want: WorkerNotFound, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/internal/errors/info.go b/internal/errors/info.go index 9038edc540..fdb8a63f16 100644 --- a/internal/errors/info.go +++ b/internal/errors/info.go @@ -252,4 +252,16 @@ var errorCodeInfo = map[Code]Info{ Message: "unexpected number of rows affected", Kind: Integrity, }, + NoPathFound: { + Message: "unexpected number of rows affected", + Kind: State, + }, + WorkerNotFound: { + Message: "worker not found", + Kind: State, + }, + CycleFound: { + Message: "cycle found", + Kind: State, + }, } diff --git a/internal/server/options.go b/internal/server/options.go index ac5bfede69..697673c6d6 100644 --- a/internal/server/options.go +++ b/internal/server/options.go @@ -39,6 +39,7 @@ type options struct { withTestPkiWorkerAuthorized bool withTestPkiWorkerKeyId *string withWorkerType WorkerType + withRoot string } func getDefaultOptions() options { @@ -172,3 +173,10 @@ func WithWorkerType(with WorkerType) Option { o.withWorkerType = with } } + +// WithRoot provides an optional root worker id. +func WithRoot(workerId string) Option { + return func(o *options) { + o.withRoot = workerId + } +} diff --git a/internal/server/options_test.go b/internal/server/options_test.go index 84033e9fa7..9eb071b241 100644 --- a/internal/server/options_test.go +++ b/internal/server/options_test.go @@ -164,4 +164,10 @@ func Test_GetOpts(t *testing.T) { opts = getOpts(WithWorkerType(KmsWorkerType)) assert.Equal(t, KmsWorkerType, opts.withWorkerType) }) + t.Run("WithRoot", func(t *testing.T) { + opts := getDefaultOptions() + assert.Empty(t, opts.withRoot) + opts = getOpts(WithRoot("a")) + assert.Equal(t, "a", opts.withRoot) + }) }