Move prefixes for many packages into the globals package (#3069)

This is a prerequisite for some enhancements to grant validation
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2023-03-10 15:06:39 -05:00
1 parent 6adc0c86b5
commit b76b24a4ad
115 files changed
+796 -729

No files matched your search

+4 -5
View File
@@ -11,10 +11,9 @@ import (
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/accounts"
"github.com/hashicorp/boundary/api/authmethods"
"github.com/hashicorp/boundary/internal/auth/oidc"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/intglobals"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -310,13 +309,13 @@ func TestErrors(t *testing.T) {
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
_, err = accountClient.Read(tc.Context(), intglobals.OldPasswordAccountPrefix+"_doesntexis")
_, err = accountClient.Read(tc.Context(), globals.PasswordAccountPreviousPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
assert.EqualValues(http.StatusNotFound, apiErr.Response().StatusCode())
_, err = accountClient.Read(tc.Context(), intglobals.NewPasswordAccountPrefix+"_doesntexis")
_, err = accountClient.Read(tc.Context(), globals.PasswordAccountPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
@@ -376,7 +375,7 @@ func TestErrorsOidc(t *testing.T) {
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
_, err = accountClient.Read(tc.Context(), oidc.AccountPrefix+"_doesntexis")
_, err = accountClient.Read(tc.Context(), globals.OidcAccountPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
@@ -14,7 +14,7 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/authmethods"
"github.com/hashicorp/boundary/internal/auth/password"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/cmd/config"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/observability/event"
@@ -348,7 +348,7 @@ func TestErrors(t *testing.T) {
// TODO: Confirm that we can't create an oidc auth method with the same name.
_, err = amClient.Read(tc.Context(), password.AuthMethodPrefix+"_doesntexis")
_, err = amClient.Read(tc.Context(), globals.PasswordAuthMethodPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
@@ -17,7 +17,6 @@ import (
"github.com/hashicorp/boundary/api/roles"
"github.com/hashicorp/boundary/api/scopes"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/authtoken"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
@@ -157,7 +156,7 @@ func TestErrors(t *testing.T) {
client.SetToken(token.Token)
tokens := authtokens.NewClient(client)
_, err := tokens.Read(tc.Context(), authtoken.AuthTokenPrefix+"_doesntexis")
_, err := tokens.Read(tc.Context(), globals.AuthTokenPrefix+"_doesntexis")
require.Error(err)
apiErr := api.AsServerError(err)
require.NotNil(apiErr)
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/credentiallibraries"
"github.com/hashicorp/boundary/api/credentialstores"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/credential/vault"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
@@ -188,7 +189,7 @@ func TestErrors(t *testing.T) {
assert.NotNil(apiErr)
assert.Nil(l)
_, err = lClient.Read(tc.Context(), vault.CredentialLibraryPrefix+"_doesntexis")
_, err = lClient.Read(tc.Context(), globals.VaultCredentialLibraryPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
@@ -17,6 +17,7 @@ import (
"github.com/hashicorp/boundary/api/hostsets"
"github.com/hashicorp/boundary/api/scopes"
"github.com/hashicorp/boundary/api/targets"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/credential"
"github.com/hashicorp/boundary/internal/daemon/controller"
tg "github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets"
@@ -386,7 +387,7 @@ func TestErrors(t *testing.T) {
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
_, err = c.Read(tc.Context(), credential.UsernamePasswordCredentialPrefix+"_doesntexis")
_, err = c.Read(tc.Context(), globals.UsernamePasswordCredentialPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
@@ -10,6 +10,7 @@ import (
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/credentialstores"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/credential/vault"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/db"
@@ -210,7 +211,7 @@ func TestErrors(t *testing.T) {
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
_, err = c.Read(tc.Context(), vault.CredentialStorePrefix+"_doesntexis")
_, err = c.Read(tc.Context(), globals.VaultCredentialStorePrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
+2 -1
View File
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/groups"
"github.com/hashicorp/boundary/api/users"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
@@ -218,7 +219,7 @@ func TestErrors(t *testing.T) {
_, err = groupClient.Create(tc.Context(), tt.scopeId, groups.WithName("first"))
require.Error(err)
_, err = groupClient.Read(tc.Context(), iam.GroupPrefix+"_doesntexis")
_, err = groupClient.Read(tc.Context(), globals.GroupPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
@@ -10,8 +10,8 @@ import (
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/hostcatalogs"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -242,7 +242,7 @@ func TestErrors(t *testing.T) {
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
_, err = pc.Read(tc.Context(), static.HostCatalogPrefix+"_doesntexis")
_, err = pc.Read(tc.Context(), globals.StaticHostCatalogPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
+2 -2
View File
@@ -13,8 +13,8 @@ import (
"github.com/hashicorp/boundary/api/hostcatalogs"
"github.com/hashicorp/boundary/api/hosts"
"github.com/hashicorp/boundary/api/hostsets"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -223,7 +223,7 @@ func TestErrors(t *testing.T) {
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
_, err = hClient.Read(tc.Context(), static.HostPrefix+"_doesntexis")
_, err = hClient.Read(tc.Context(), globals.StaticHostPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
+2 -2
View File
@@ -15,8 +15,8 @@ import (
"github.com/hashicorp/boundary/api/hostcatalogs"
"github.com/hashicorp/boundary/api/hosts"
"github.com/hashicorp/boundary/api/hostsets"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -332,7 +332,7 @@ func TestErrors(t *testing.T) {
assert.NotNil(apiErr)
assert.Nil(h)
_, err = hClient.Read(tc.Context(), static.HostSetPrefix+"_doesntexis")
_, err = hClient.Read(tc.Context(), globals.StaticHostSetPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
@@ -11,9 +11,9 @@ import (
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/authmethods"
"github.com/hashicorp/boundary/api/managedgroups"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/intglobals"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -214,7 +214,7 @@ func TestErrorsOidc(t *testing.T) {
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
_, err = managedgroupClient.Read(tc.Context(), intglobals.OidcManagedGroupPrefix+"_doesntexis")
_, err = managedgroupClient.Read(tc.Context(), globals.OidcManagedGroupPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
require.NotNil(apiErr)
+2 -1
View File
@@ -12,6 +12,7 @@ import (
"github.com/hashicorp/boundary/api/groups"
"github.com/hashicorp/boundary/api/roles"
"github.com/hashicorp/boundary/api/users"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
@@ -310,7 +311,7 @@ func TestErrors(t *testing.T) {
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
_, err = roleClient.Read(tc.Context(), iam.RolePrefix+"_doesntexis")
_, err = roleClient.Read(tc.Context(), globals.RolePrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
+2 -2
View File
@@ -18,10 +18,10 @@ import (
"github.com/hashicorp/boundary/api/hostsets"
"github.com/hashicorp/boundary/api/roles"
"github.com/hashicorp/boundary/api/targets"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/credential/vault"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/target/tcp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -684,7 +684,7 @@ func TestSet_Errors(t *testing.T) {
assert.NotNil(apiErr)
assert.Nil(tar)
_, err = tarClient.Read(tc.Context(), tcp.TargetPrefix+"_doesntexis")
_, err = tarClient.Read(tc.Context(), globals.TcpTargetPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
+2 -1
View File
@@ -12,6 +12,7 @@ import (
"github.com/hashicorp/boundary/api/accounts"
"github.com/hashicorp/boundary/api/authmethods"
"github.com/hashicorp/boundary/api/users"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/daemon/controller"
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
@@ -206,7 +207,7 @@ func TestErrors(t *testing.T) {
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)
_, err = userClient.Read(tc.Context(), iam.UserPrefix+"_doesntexis")
_, err = userClient.Read(tc.Context(), globals.UserPrefix+"_doesntexis")
require.Error(err)
apiErr = api.AsServerError(err)
assert.NotNil(apiErr)