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:
1 parent
6adc0c86b5
commit
b76b24a4ad
115 files changed
+796
-729
No files matched your search
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
@@ -947,7 +946,7 @@ func validateGetRequest(req *pbs.GetAccountRequest) error {
|
||||
if req == nil {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, intglobals.OldPasswordAccountPrefix, intglobals.NewPasswordAccountPrefix, oidc.AccountPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.PasswordAccountPreviousPrefix, globals.PasswordAccountPrefix, globals.OidcAccountPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateAccountRequest) error {
|
||||
@@ -1039,7 +1038,7 @@ func validateUpdateRequest(req *pbs.UpdateAccountRequest) error {
|
||||
}
|
||||
}
|
||||
return badFields
|
||||
}, intglobals.OldPasswordAccountPrefix, intglobals.NewPasswordAccountPrefix, oidc.AccountPrefix)
|
||||
}, globals.PasswordAccountPreviousPrefix, globals.PasswordAccountPrefix, globals.OidcAccountPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteAccountRequest) error {
|
||||
@@ -1047,7 +1046,7 @@ func validateDeleteRequest(req *pbs.DeleteAccountRequest) error {
|
||||
if req == nil {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, intglobals.OldPasswordAccountPrefix, intglobals.NewPasswordAccountPrefix, oidc.AccountPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.PasswordAccountPreviousPrefix, globals.PasswordAccountPrefix, globals.OidcAccountPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListAccountsRequest) error {
|
||||
@@ -1056,7 +1055,7 @@ func validateListRequest(req *pbs.ListAccountsRequest) error {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetAuthMethodId()), password.AuthMethodPrefix, oidc.AuthMethodPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetAuthMethodId()), globals.PasswordAuthMethodPrefix, globals.OidcAuthMethodPrefix) {
|
||||
badFields[authMethodIdField] = "Invalid formatted identifier."
|
||||
}
|
||||
if _, err := handlers.NewFilter(req.GetFilter()); err != nil {
|
||||
@@ -1074,7 +1073,7 @@ func validateChangePasswordRequest(req *pbs.ChangePasswordRequest) error {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), intglobals.OldPasswordAccountPrefix, intglobals.NewPasswordAccountPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.PasswordAccountPreviousPrefix, globals.PasswordAccountPrefix) {
|
||||
badFields[idField] = "Improperly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1098,7 +1097,7 @@ func validateSetPasswordRequest(req *pbs.SetPasswordRequest) error {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), intglobals.OldPasswordAccountPrefix, intglobals.NewPasswordAccountPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.PasswordAccountPreviousPrefix, globals.PasswordAccountPrefix) {
|
||||
badFields[idField] = "Improperly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
requestauth "github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
@@ -23,7 +22,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
@@ -196,19 +194,19 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing old password account",
|
||||
req: &pbs.GetAccountRequest{Id: intglobals.OldPasswordAccountPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetAccountRequest{Id: globals.PasswordAccountPreviousPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
{
|
||||
name: "Get a non existing new password account",
|
||||
req: &pbs.GetAccountRequest{Id: intglobals.NewPasswordAccountPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetAccountRequest{Id: globals.PasswordAccountPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
{
|
||||
name: "Get a non existing oidc account",
|
||||
req: &pbs.GetAccountRequest{Id: oidc.AccountPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetAccountRequest{Id: globals.OidcAccountPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -220,7 +218,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetAccountRequest{Id: authtoken.AuthTokenPrefix + "_1 23456789"},
|
||||
req: &pbs.GetAccountRequest{Id: globals.AuthTokenPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -330,7 +328,7 @@ func TestListPassword(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Unfound Auth Method",
|
||||
req: &pbs.ListAccountsRequest{AuthMethodId: password.AuthMethodPrefix + "_DoesntExis"},
|
||||
req: &pbs.ListAccountsRequest{AuthMethodId: globals.PasswordAuthMethodPrefix + "_DoesntExis"},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
{
|
||||
@@ -484,7 +482,7 @@ func TestListOidc(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Unfound Auth Method",
|
||||
req: &pbs.ListAccountsRequest{AuthMethodId: oidc.AuthMethodPrefix + "_DoesntExis"},
|
||||
req: &pbs.ListAccountsRequest{AuthMethodId: globals.OidcAuthMethodPrefix + "_DoesntExis"},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
{
|
||||
@@ -603,21 +601,21 @@ func TestDelete(t *testing.T) {
|
||||
{
|
||||
name: "Delete bad old pw account id",
|
||||
req: &pbs.DeleteAccountRequest{
|
||||
Id: intglobals.OldPasswordAccountPrefix + "_doesntexis",
|
||||
Id: globals.PasswordAccountPreviousPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
{
|
||||
name: "Delete bad new pw account id",
|
||||
req: &pbs.DeleteAccountRequest{
|
||||
Id: intglobals.NewPasswordAccountPrefix + "_doesntexis",
|
||||
Id: globals.PasswordAccountPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
{
|
||||
name: "Delete bad oidc account id",
|
||||
req: &pbs.DeleteAccountRequest{
|
||||
Id: oidc.AccountPrefix + "_doesntexis",
|
||||
Id: globals.OidcAccountPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -723,7 +721,7 @@ func TestCreatePassword(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateAccountResponse{
|
||||
Uri: fmt.Sprintf("accounts/%s_", intglobals.NewPasswordAccountPrefix),
|
||||
Uri: fmt.Sprintf("accounts/%s_", globals.PasswordAccountPrefix),
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: defaultAccount.GetAuthMethodId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
@@ -755,7 +753,7 @@ func TestCreatePassword(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateAccountResponse{
|
||||
Uri: fmt.Sprintf("accounts/%s_", intglobals.NewPasswordAccountPrefix),
|
||||
Uri: fmt.Sprintf("accounts/%s_", globals.PasswordAccountPrefix),
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: defaultAccount.GetAuthMethodId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
@@ -787,7 +785,7 @@ func TestCreatePassword(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateAccountResponse{
|
||||
Uri: fmt.Sprintf("accounts/%s_", intglobals.NewPasswordAccountPrefix),
|
||||
Uri: fmt.Sprintf("accounts/%s_", globals.PasswordAccountPrefix),
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: defaultAccount.GetAuthMethodId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name_with_password"},
|
||||
@@ -827,7 +825,7 @@ func TestCreatePassword(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: defaultAccount.GetAuthMethodId(),
|
||||
Id: intglobals.NewPasswordAccountPrefix + "_notallowed",
|
||||
Id: globals.PasswordAccountPrefix + "_notallowed",
|
||||
Type: "password",
|
||||
Attrs: &pb.Account_PasswordAccountAttributes{
|
||||
&pb.PasswordAccountAttributes{
|
||||
@@ -900,7 +898,7 @@ func TestCreatePassword(t *testing.T) {
|
||||
}
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.Uri)
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), intglobals.NewPasswordAccountPrefix+"_"))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.PasswordAccountPrefix+"_"))
|
||||
gotCreateTime := got.GetItem().GetCreatedTime()
|
||||
require.NoError(err, "Error converting proto to timestamp.")
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime()
|
||||
@@ -971,7 +969,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateAccountResponse{
|
||||
Uri: fmt.Sprintf("accounts/%s_", oidc.AccountPrefix),
|
||||
Uri: fmt.Sprintf("accounts/%s_", globals.OidcAccountPrefix),
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
@@ -1002,7 +1000,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateAccountResponse{
|
||||
Uri: fmt.Sprintf("accounts/%s_", oidc.AccountPrefix),
|
||||
Uri: fmt.Sprintf("accounts/%s_", globals.OidcAccountPrefix),
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
@@ -1034,7 +1032,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateAccountResponse{
|
||||
Uri: fmt.Sprintf("accounts/%s_", oidc.AccountPrefix),
|
||||
Uri: fmt.Sprintf("accounts/%s_", globals.OidcAccountPrefix),
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "overwritten issuer"},
|
||||
@@ -1072,7 +1070,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
req: &pbs.CreateAccountRequest{
|
||||
Item: &pb.Account{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Id: oidc.AccountPrefix + "_notallowed",
|
||||
Id: globals.OidcAccountPrefix + "_notallowed",
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
&pb.OidcAccountAttributes{
|
||||
@@ -1142,7 +1140,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
require.NoError(gErr)
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.Uri)
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), oidc.AccountPrefix+"_"))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.OidcAccountPrefix+"_"))
|
||||
// Clear all values which are hard to compare against.
|
||||
got.Uri, tc.res.Uri = "", ""
|
||||
got.Item.Id, tc.res.Item.Id = "", ""
|
||||
@@ -1409,7 +1407,7 @@ func TestUpdatePassword(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Old ID Account",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: intglobals.OldPasswordAccountPrefix + "_DoesntExis",
|
||||
Id: globals.PasswordAccountPreviousPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{globals.DescriptionField},
|
||||
},
|
||||
@@ -1423,7 +1421,7 @@ func TestUpdatePassword(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing New ID Account",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: intglobals.NewPasswordAccountPrefix + "_DoesntExis",
|
||||
Id: globals.PasswordAccountPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{globals.DescriptionField},
|
||||
},
|
||||
@@ -1441,7 +1439,7 @@ func TestUpdatePassword(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.Account{
|
||||
Id: intglobals.NewPasswordAccountPrefix + "_somethinge",
|
||||
Id: globals.PasswordAccountPrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
@@ -1786,7 +1784,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Account",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: intglobals.NewPasswordAccountPrefix + "_DoesntExis",
|
||||
Id: globals.PasswordAccountPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{globals.DescriptionField},
|
||||
},
|
||||
@@ -1804,7 +1802,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.Account{
|
||||
Id: intglobals.NewPasswordAccountPrefix + "_somethinge",
|
||||
Id: globals.PasswordAccountPrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
@@ -2033,13 +2031,13 @@ func TestSetPassword(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "notfound old account id",
|
||||
accountId: intglobals.OldPasswordAccountPrefix + "_DoesntExis",
|
||||
accountId: globals.PasswordAccountPreviousPrefix + "_DoesntExis",
|
||||
version: defaultAcct.GetVersion(),
|
||||
password: "anewpassword",
|
||||
},
|
||||
{
|
||||
name: "notfound new account id",
|
||||
accountId: intglobals.NewPasswordAccountPrefix + "_DoesntExis",
|
||||
accountId: globals.PasswordAccountPrefix + "_DoesntExis",
|
||||
version: defaultAcct.GetVersion(),
|
||||
password: "anewpassword",
|
||||
},
|
||||
@@ -2200,7 +2198,7 @@ func TestChangePassword(t *testing.T) {
|
||||
{
|
||||
name: "notfound old account id",
|
||||
authMethodId: defaultAcct.GetAuthMethodId(),
|
||||
accountId: intglobals.OldPasswordAccountPrefix + "_DoesntExis",
|
||||
accountId: globals.PasswordAccountPreviousPrefix + "_DoesntExis",
|
||||
version: defaultAcct.GetVersion(),
|
||||
oldPW: "somepassword",
|
||||
newPW: "anewpassword",
|
||||
@@ -2208,7 +2206,7 @@ func TestChangePassword(t *testing.T) {
|
||||
{
|
||||
name: "notfound new account id",
|
||||
authMethodId: defaultAcct.GetAuthMethodId(),
|
||||
accountId: intglobals.NewPasswordAccountPrefix + "_DoesntExis",
|
||||
accountId: globals.PasswordAccountPrefix + "_DoesntExis",
|
||||
version: defaultAcct.GetVersion(),
|
||||
oldPW: "somepassword",
|
||||
newPW: "anewpassword",
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/accounts"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -40,7 +40,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "mismatched pw authmethod oidc type",
|
||||
item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: password.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(typeField, "Doesn't match the parent resource's type."),
|
||||
},
|
||||
@@ -48,7 +48,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "mismatched oidc authmethod pw type",
|
||||
item: &pb.Account{
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(typeField, "Doesn't match the parent resource's type."),
|
||||
},
|
||||
@@ -56,7 +56,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "missing oidc attributes",
|
||||
item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(attributesField, "This is a required field."),
|
||||
},
|
||||
@@ -64,7 +64,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "missing oidc subject",
|
||||
item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{},
|
||||
},
|
||||
@@ -75,7 +75,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "read only name claim field",
|
||||
item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{FullName: "something"},
|
||||
},
|
||||
@@ -86,7 +86,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "read only email claim field",
|
||||
item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{Email: "something"},
|
||||
},
|
||||
@@ -97,7 +97,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "missing password attributes",
|
||||
item: &pb.Account{
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: password.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(attributesField, "This is a required field."),
|
||||
},
|
||||
@@ -105,7 +105,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "missing login name for password type",
|
||||
item: &pb.Account{
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: password.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_PasswordAccountAttributes{
|
||||
PasswordAccountAttributes: &pb.PasswordAccountAttributes{},
|
||||
},
|
||||
@@ -116,7 +116,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "no error",
|
||||
item: &pb.Account{
|
||||
Type: password.Subtype.String(),
|
||||
AuthMethodId: password.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.PasswordAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_PasswordAccountAttributes{
|
||||
PasswordAccountAttributes: &pb.PasswordAccountAttributes{
|
||||
LoginName: "something",
|
||||
@@ -128,7 +128,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "no oidc errors",
|
||||
item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.Account_OidcAccountAttributes{
|
||||
OidcAccountAttributes: &pb.OidcAccountAttributes{Subject: "no oidc errors"},
|
||||
},
|
||||
@@ -161,7 +161,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
{
|
||||
name: "password to oidc change type, old prefix",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: intglobals.OldPasswordAccountPrefix + "_1234567890",
|
||||
Id: globals.PasswordAccountPreviousPrefix + "_1234567890",
|
||||
Item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
@@ -171,7 +171,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
{
|
||||
name: "password to oidc change type, new prefix",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: intglobals.NewPasswordAccountPrefix + "_1234567890",
|
||||
Id: globals.PasswordAccountPrefix + "_1234567890",
|
||||
Item: &pb.Account{
|
||||
Type: oidc.Subtype.String(),
|
||||
},
|
||||
@@ -181,7 +181,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
{
|
||||
name: "oidc to password change type",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: oidc.AccountPrefix + "_1234567890",
|
||||
Id: globals.OidcAccountPrefix + "_1234567890",
|
||||
Item: &pb.Account{
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
@@ -191,7 +191,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
{
|
||||
name: "no error",
|
||||
req: &pbs.UpdateAccountRequest{
|
||||
Id: oidc.AccountPrefix + "_1234567890",
|
||||
Id: globals.OidcAccountPrefix + "_1234567890",
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{}},
|
||||
Item: &pb.Account{
|
||||
Version: 1,
|
||||
@@ -220,7 +220,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
nameClaimField,
|
||||
}
|
||||
err := validateUpdateRequest(&pbs.UpdateAccountRequest{
|
||||
Id: oidc.AccountPrefix + "_1234567890",
|
||||
Id: globals.OidcAccountPrefix + "_1234567890",
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: readOnlyFields},
|
||||
})
|
||||
|
||||
@@ -238,7 +238,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
subjectField,
|
||||
}
|
||||
err := validateUpdateRequest(&pbs.UpdateAccountRequest{
|
||||
Id: oidc.AccountPrefix + "_1234567890",
|
||||
Id: globals.OidcAccountPrefix + "_1234567890",
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: readOnlyFields},
|
||||
})
|
||||
|
||||
|
||||
@@ -829,7 +829,7 @@ func validateGetRequest(req *pbs.GetAuthMethodRequest) error {
|
||||
if req == nil {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "Missing request")
|
||||
}
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, password.AuthMethodPrefix, oidc.AuthMethodPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.PasswordAuthMethodPrefix, globals.OidcAuthMethodPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(ctx context.Context, req *pbs.CreateAuthMethodRequest) error {
|
||||
@@ -1055,7 +1055,7 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAuthMethodRequest
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
return badFields
|
||||
}, password.AuthMethodPrefix, oidc.AuthMethodPrefix)
|
||||
}, globals.PasswordAuthMethodPrefix, globals.OidcAuthMethodPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteAuthMethodRequest) error {
|
||||
@@ -1063,7 +1063,7 @@ func validateDeleteRequest(req *pbs.DeleteAuthMethodRequest) error {
|
||||
if req == nil {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "Missing request")
|
||||
}
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, password.AuthMethodPrefix, oidc.AuthMethodPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.PasswordAuthMethodPrefix, globals.OidcAuthMethodPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListAuthMethodsRequest) error {
|
||||
|
||||
@@ -175,7 +175,7 @@ func TestGet(t *testing.T) {
|
||||
{
|
||||
name: "Get a non existant AuthMethod",
|
||||
scopeId: o.GetPublicId(),
|
||||
req: &pbs.GetAuthMethodRequest{Id: password.AuthMethodPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetAuthMethodRequest{Id: globals.PasswordAuthMethodPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -189,7 +189,7 @@ func TestGet(t *testing.T) {
|
||||
{
|
||||
name: "space in id",
|
||||
scopeId: o.GetPublicId(),
|
||||
req: &pbs.GetAuthMethodRequest{Id: password.AuthMethodPrefix + "_1 23456789"},
|
||||
req: &pbs.GetAuthMethodRequest{Id: globals.PasswordAuthMethodPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -456,7 +456,7 @@ func TestDelete(t *testing.T) {
|
||||
{
|
||||
name: "Delete bad auth_method id",
|
||||
req: &pbs.DeleteAuthMethodRequest{
|
||||
Id: password.AuthMethodPrefix + "_doesntexis",
|
||||
Id: globals.PasswordAuthMethodPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -557,9 +557,9 @@ func TestCreate(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: "password",
|
||||
}},
|
||||
idPrefix: password.AuthMethodPrefix + "_",
|
||||
idPrefix: globals.PasswordAuthMethodPrefix + "_",
|
||||
res: &pbs.CreateAuthMethodResponse{
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", password.AuthMethodPrefix),
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", globals.PasswordAuthMethodPrefix),
|
||||
Item: &pb.AuthMethod{
|
||||
Id: defaultAm.GetPublicId(),
|
||||
ScopeId: o.GetPublicId(),
|
||||
@@ -598,9 +598,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: oidc.AuthMethodPrefix + "_",
|
||||
idPrefix: globals.OidcAuthMethodPrefix + "_",
|
||||
res: &pbs.CreateAuthMethodResponse{
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", oidc.AuthMethodPrefix),
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", globals.OidcAuthMethodPrefix),
|
||||
Item: &pb.AuthMethod{
|
||||
Id: defaultAm.GetPublicId(),
|
||||
ScopeId: o.GetPublicId(),
|
||||
@@ -635,9 +635,9 @@ func TestCreate(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: "password",
|
||||
}},
|
||||
idPrefix: password.AuthMethodPrefix + "_",
|
||||
idPrefix: globals.PasswordAuthMethodPrefix + "_",
|
||||
res: &pbs.CreateAuthMethodResponse{
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", password.AuthMethodPrefix),
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", globals.PasswordAuthMethodPrefix),
|
||||
Item: &pb.AuthMethod{
|
||||
Id: defaultAm.GetPublicId(),
|
||||
ScopeId: scope.Global.String(),
|
||||
@@ -673,9 +673,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: oidc.AuthMethodPrefix + "_",
|
||||
idPrefix: globals.OidcAuthMethodPrefix + "_",
|
||||
res: &pbs.CreateAuthMethodResponse{
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", oidc.AuthMethodPrefix),
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", globals.OidcAuthMethodPrefix),
|
||||
Item: &pb.AuthMethod{
|
||||
Id: defaultAm.GetPublicId(),
|
||||
ScopeId: scope.Global.String(),
|
||||
@@ -702,7 +702,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateAuthMethodRequest{Item: &pb.AuthMethod{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Id: password.AuthMethodPrefix + "_notallowed",
|
||||
Id: globals.PasswordAuthMethodPrefix + "_notallowed",
|
||||
Type: "password",
|
||||
}},
|
||||
res: nil,
|
||||
@@ -772,7 +772,7 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
}},
|
||||
res: &pbs.CreateAuthMethodResponse{
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", oidc.AuthMethodPrefix),
|
||||
Uri: fmt.Sprintf("auth-methods/%s_", globals.OidcAuthMethodPrefix),
|
||||
Item: &pb.AuthMethod{
|
||||
Id: defaultAm.GetPublicId(),
|
||||
ScopeId: o.GetPublicId(),
|
||||
|
||||
@@ -580,7 +580,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing AuthMethod",
|
||||
req: &pbs.UpdateAuthMethodRequest{
|
||||
Id: password.AuthMethodPrefix + "_DoesntExis",
|
||||
Id: globals.PasswordAuthMethodPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
@@ -598,7 +598,7 @@ func TestUpdate_OIDC(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.AuthMethod{
|
||||
Id: password.AuthMethodPrefix + "_somethinge",
|
||||
Id: globals.PasswordAuthMethodPrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
@@ -284,7 +285,7 @@ func TestUpdate_Password(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing AuthMethod",
|
||||
req: &pbs.UpdateAuthMethodRequest{
|
||||
Id: password.AuthMethodPrefix + "_DoesntExis",
|
||||
Id: globals.PasswordAuthMethodPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
@@ -302,7 +303,7 @@ func TestUpdate_Password(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.AuthMethod{
|
||||
Id: password.AuthMethodPrefix + "_somethinge",
|
||||
Id: globals.PasswordAuthMethodPrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
|
||||
@@ -369,11 +369,11 @@ func toProto(ctx context.Context, in *authtoken.AuthToken, opt ...handlers.Optio
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetAuthTokenRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, authtoken.AuthTokenPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.AuthTokenPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteAuthTokenRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, authtoken.AuthTokenPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.AuthTokenPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListAuthTokensRequest) error {
|
||||
|
||||
@@ -162,7 +162,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing auth token",
|
||||
req: &pbs.GetAuthTokenRequest{Id: authtoken.AuthTokenPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetAuthTokenRequest{Id: globals.AuthTokenPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -174,7 +174,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetAuthTokenRequest{Id: authtoken.AuthTokenPrefix + "_1 23456789"},
|
||||
req: &pbs.GetAuthTokenRequest{Id: globals.AuthTokenPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -544,7 +544,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Delete bad token id",
|
||||
scope: org.GetPublicId(),
|
||||
req: &pbs.DeleteAuthTokenRequest{
|
||||
Id: authtoken.AuthTokenPrefix + "_doesntexis",
|
||||
Id: globals.AuthTokenPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
|
||||
+6
-6
@@ -861,9 +861,9 @@ func validateGetRequest(req *pbs.GetCredentialLibraryRequest) error {
|
||||
prefix := ""
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
prefix = vault.SSHCertificateCredentialLibraryPrefix
|
||||
prefix = globals.VaultSshCertificateCredentialLibraryPrefix
|
||||
default:
|
||||
prefix = vault.CredentialLibraryPrefix
|
||||
prefix = globals.VaultCredentialLibraryPrefix
|
||||
}
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, prefix)
|
||||
}
|
||||
@@ -984,9 +984,9 @@ func validateUpdateRequest(req *pbs.UpdateCredentialLibraryRequest, currentCrede
|
||||
st := subtypes.SubtypeFromId(domain, req.GetId())
|
||||
switch st {
|
||||
case vault.GenericLibrarySubtype:
|
||||
prefix = vault.CredentialLibraryPrefix
|
||||
prefix = globals.VaultCredentialLibraryPrefix
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
prefix = vault.SSHCertificateCredentialLibraryPrefix
|
||||
prefix = globals.VaultSshCertificateCredentialLibraryPrefix
|
||||
}
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
@@ -1041,12 +1041,12 @@ func validateUpdateRequest(req *pbs.UpdateCredentialLibraryRequest, currentCrede
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteCredentialLibraryRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, vault.CredentialLibraryPrefix, vault.SSHCertificateCredentialLibraryPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.VaultCredentialLibraryPrefix, globals.VaultSshCertificateCredentialLibraryPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListCredentialLibrariesRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetCredentialStoreId()), vault.CredentialStorePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetCredentialStoreId()), globals.VaultCredentialStorePrefix) {
|
||||
badFields[globals.CredentialStoreIdField] = "This field must be a valid credential store id."
|
||||
}
|
||||
if _, err := handlers.NewFilter(req.GetFilter()); err != nil {
|
||||
|
||||
+31
-32
@@ -20,7 +20,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
@@ -321,7 +320,7 @@ func TestCreate(t *testing.T) {
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
@@ -329,7 +328,7 @@ func TestCreate(t *testing.T) {
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: vault.GenericLibrarySubtype.String(),
|
||||
Id: vault.CredentialLibraryPrefix + "_notallowed",
|
||||
Id: globals.VaultCredentialLibraryPrefix + "_notallowed",
|
||||
Attrs: &pb.CredentialLibrary_VaultGenericCredentialLibraryAttributes{
|
||||
VaultGenericCredentialLibraryAttributes: &pb.VaultCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -493,9 +492,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -528,9 +527,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -563,9 +562,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
CredentialType: string(credential.UsernamePasswordType),
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -605,9 +604,9 @@ func TestCreate(t *testing.T) {
|
||||
}(),
|
||||
CredentialType: string(credential.UsernamePasswordType),
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -656,9 +655,9 @@ func TestCreate(t *testing.T) {
|
||||
}(),
|
||||
CredentialType: string(credential.UsernamePasswordType),
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -699,9 +698,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
CredentialType: string(credential.SshPrivateKeyType),
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -743,9 +742,9 @@ func TestCreate(t *testing.T) {
|
||||
}(),
|
||||
CredentialType: string(credential.SshPrivateKeyType),
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -786,9 +785,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -822,9 +821,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
idPrefix: vault.CredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.CredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -1055,12 +1054,12 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", vault.CredentialLibraryPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.VaultCredentialLibraryPrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "bad prefix",
|
||||
id: fmt.Sprintf("%s_1234567890", static.HostPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticHostPrefix),
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
}
|
||||
@@ -1126,12 +1125,12 @@ func TestDelete(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", vault.CredentialLibraryPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.VaultCredentialLibraryPrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "bad prefix",
|
||||
id: fmt.Sprintf("%s_1234567890", static.HostPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticHostPrefix),
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
}
|
||||
@@ -1961,7 +1960,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.SSHCertificateCredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultSshCertificateCredentialLibraryPrefix + "_",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
@@ -1975,7 +1974,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.SSHCertificateCredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultSshCertificateCredentialLibraryPrefix + "_",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
@@ -1983,7 +1982,7 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
req: &pbs.CreateCredentialLibraryRequest{Item: &pb.CredentialLibrary{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Type: vault.SSHCertificateLibrarySubtype.String(),
|
||||
Id: vault.SSHCertificateCredentialLibraryPrefix + "_notallowed",
|
||||
Id: globals.VaultSshCertificateCredentialLibraryPrefix + "_notallowed",
|
||||
Attrs: &pb.CredentialLibrary_VaultSshCertificateCredentialLibraryAttributes{
|
||||
VaultSshCertificateCredentialLibraryAttributes: &pb.VaultSSHCertificateCredentialLibraryAttributes{
|
||||
Path: wrapperspb.String("something"),
|
||||
@@ -2102,9 +2101,9 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.SSHCertificateCredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultSshCertificateCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.SSHCertificateCredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultSshCertificateCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -2141,9 +2140,9 @@ func TestCreate_SSHCertificateCredentialLibrary(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.SSHCertificateCredentialLibraryPrefix + "_",
|
||||
idPrefix: globals.VaultSshCertificateCredentialLibraryPrefix + "_",
|
||||
res: &pbs.CreateCredentialLibraryResponse{
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", vault.SSHCertificateCredentialLibraryPrefix),
|
||||
Uri: fmt.Sprintf("credential-libraries/%s_", globals.VaultSshCertificateCredentialLibraryPrefix),
|
||||
Item: &pb.CredentialLibrary{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
|
||||
@@ -728,17 +728,17 @@ func validateGetRequest(req *pbs.GetCredentialRequest) error {
|
||||
return handlers.ValidateGetRequest(
|
||||
handlers.NoopValidatorFn,
|
||||
req,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix,
|
||||
)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateCredentialRequest) error {
|
||||
return handlers.ValidateCreateRequest(req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.Item.GetCredentialStoreId()), static.CredentialStorePrefix, static.PreviousCredentialStorePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.Item.GetCredentialStoreId()), globals.StaticCredentialStorePrefix, globals.StaticCredentialStorePreviousPrefix) {
|
||||
badFields[globals.CredentialStoreIdField] = "This field must be a valid credential store id."
|
||||
}
|
||||
|
||||
@@ -869,10 +869,10 @@ func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
|
||||
|
||||
return badFields
|
||||
},
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -880,16 +880,16 @@ func validateDeleteRequest(req *pbs.DeleteCredentialRequest) error {
|
||||
return handlers.ValidateDeleteRequest(
|
||||
handlers.NoopValidatorFn,
|
||||
req,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix,
|
||||
)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListCredentialsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetCredentialStoreId()), static.CredentialStorePrefix, static.PreviousCredentialStorePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetCredentialStoreId()), globals.StaticCredentialStorePrefix, globals.StaticCredentialStorePreviousPrefix) {
|
||||
badFields[globals.CredentialStoreIdField] = "This field must be a valid credential store id."
|
||||
}
|
||||
if _, err := handlers.NewFilter(req.GetFilter()); err != nil {
|
||||
|
||||
@@ -226,7 +226,7 @@ func TestGet(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
upCred := static.TestUsernamePasswordCredential(t, conn, wrapper, "user", "pass", store.GetPublicId(), prj.GetPublicId())
|
||||
upCredPrev := static.TestUsernamePasswordCredential(t, conn, wrapper, "user", "pass", store.GetPublicId(), prj.GetPublicId(), static.WithPublicId(fmt.Sprintf("%s_1234567890", credential.PreviousUsernamePasswordCredentialPrefix)))
|
||||
upCredPrev := static.TestUsernamePasswordCredential(t, conn, wrapper, "user", "pass", store.GetPublicId(), prj.GetPublicId(), static.WithPublicId(fmt.Sprintf("%s_1234567890", globals.UsernamePasswordCredentialPreviousPrefix)))
|
||||
upHm, err := crypto.HmacSha256(context.Background(), []byte("pass"), databaseWrapper, []byte(store.GetPublicId()), nil, crypto.WithEd25519())
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -367,12 +367,12 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", credential.UsernamePasswordCredentialPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.UsernamePasswordCredentialPrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "bad prefix",
|
||||
id: fmt.Sprintf("%s_1234567890", static.CredentialStorePrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticCredentialStorePrefix),
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
}
|
||||
@@ -450,12 +450,12 @@ func TestDelete(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", credential.UsernamePasswordCredentialPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.UsernamePasswordCredentialPrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "bad prefix",
|
||||
id: fmt.Sprintf("%s_1234567890", static.CredentialStorePrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticCredentialStorePrefix),
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
}
|
||||
@@ -508,7 +508,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateCredentialRequest{Item: &pb.Credential{
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
Id: credential.UsernamePasswordCredentialPrefix + "_notallowed",
|
||||
Id: globals.UsernamePasswordCredentialPrefix + "_notallowed",
|
||||
Type: credential.UsernamePasswordSubtype.String(),
|
||||
Attrs: &pb.Credential_UsernamePasswordAttributes{
|
||||
UsernamePasswordAttributes: &pb.UsernamePasswordAttributes{
|
||||
@@ -646,9 +646,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: credential.UsernamePasswordCredentialPrefix + "_",
|
||||
idPrefix: globals.UsernamePasswordCredentialPrefix + "_",
|
||||
res: &pbs.CreateCredentialResponse{
|
||||
Uri: fmt.Sprintf("credentials/%s_", credential.UsernamePasswordCredentialPrefix),
|
||||
Uri: fmt.Sprintf("credentials/%s_", globals.UsernamePasswordCredentialPrefix),
|
||||
Item: &pb.Credential{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -673,9 +673,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: credential.SshPrivateKeyCredentialPrefix + "_",
|
||||
idPrefix: globals.SshPrivateKeyCredentialPrefix + "_",
|
||||
res: &pbs.CreateCredentialResponse{
|
||||
Uri: fmt.Sprintf("credentials/%s_", credential.SshPrivateKeyCredentialPrefix),
|
||||
Uri: fmt.Sprintf("credentials/%s_", globals.SshPrivateKeyCredentialPrefix),
|
||||
Item: &pb.Credential{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -701,9 +701,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: credential.SshPrivateKeyCredentialPrefix + "_",
|
||||
idPrefix: globals.SshPrivateKeyCredentialPrefix + "_",
|
||||
res: &pbs.CreateCredentialResponse{
|
||||
Uri: fmt.Sprintf("credentials/%s_", credential.SshPrivateKeyCredentialPrefix),
|
||||
Uri: fmt.Sprintf("credentials/%s_", globals.SshPrivateKeyCredentialPrefix),
|
||||
Item: &pb.Credential{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
@@ -727,9 +727,9 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: credential.JsonCredentialPrefix + "_",
|
||||
idPrefix: globals.JsonCredentialPrefix + "_",
|
||||
res: &pbs.CreateCredentialResponse{
|
||||
Uri: fmt.Sprintf("credentials/%s_", credential.JsonCredentialPrefix),
|
||||
Uri: fmt.Sprintf("credentials/%s_", globals.JsonCredentialPrefix),
|
||||
Item: &pb.Credential{
|
||||
Id: store.GetPublicId(),
|
||||
CredentialStoreId: store.GetPublicId(),
|
||||
|
||||
@@ -778,7 +778,7 @@ func toStorageVaultStore(ctx context.Context, scopeId string, in *pb.CredentialS
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetCredentialStoreRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, vault.CredentialStorePrefix, static.CredentialStorePrefix, static.PreviousCredentialStorePrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.VaultCredentialStorePrefix, globals.StaticCredentialStorePrefix, globals.StaticCredentialStorePreviousPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(ctx context.Context, req *pbs.CreateCredentialStoreRequest) error {
|
||||
@@ -875,11 +875,11 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateCredentialStoreRe
|
||||
}
|
||||
}
|
||||
return badFields
|
||||
}, vault.CredentialStorePrefix, static.CredentialStorePrefix, static.PreviousCredentialStorePrefix)
|
||||
}, globals.VaultCredentialStorePrefix, globals.StaticCredentialStorePrefix, globals.StaticCredentialStorePreviousPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteCredentialStoreRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, vault.CredentialStorePrefix, static.CredentialStorePrefix, static.PreviousCredentialStorePrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.VaultCredentialStorePrefix, globals.StaticCredentialStorePrefix, globals.StaticCredentialStorePreviousPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListCredentialStoresRequest) error {
|
||||
|
||||
+22
-23
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
@@ -268,7 +267,7 @@ func TestCreateVault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.VaultCredentialStorePrefix + "_",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
@@ -286,7 +285,7 @@ func TestCreateVault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.VaultCredentialStorePrefix + "_",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
@@ -303,7 +302,7 @@ func TestCreateVault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.VaultCredentialStorePrefix + "_",
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
@@ -320,7 +319,7 @@ func TestCreateVault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.VaultCredentialStorePrefix + "_",
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
@@ -338,14 +337,14 @@ func TestCreateVault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.VaultCredentialStorePrefix + "_",
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
{
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Id: vault.CredentialStorePrefix + "_notallowed",
|
||||
Id: globals.VaultCredentialStorePrefix + "_notallowed",
|
||||
Type: vault.Subtype.String(),
|
||||
Attrs: &pb.CredentialStore_VaultCredentialStoreAttributes{
|
||||
VaultCredentialStoreAttributes: &pb.VaultCredentialStoreAttributes{
|
||||
@@ -463,9 +462,9 @@ func TestCreateVault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.VaultCredentialStorePrefix + "_",
|
||||
res: &pbs.CreateCredentialStoreResponse{
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", vault.CredentialStorePrefix),
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", globals.VaultCredentialStorePrefix),
|
||||
Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
@@ -503,9 +502,9 @@ func TestCreateVault(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}},
|
||||
idPrefix: vault.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.VaultCredentialStorePrefix + "_",
|
||||
res: &pbs.CreateCredentialStoreResponse{
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", vault.CredentialStorePrefix),
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", globals.VaultCredentialStorePrefix),
|
||||
Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
@@ -629,7 +628,7 @@ func TestCreateStatic(t *testing.T) {
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateCredentialStoreRequest{Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Id: credstatic.CredentialStorePrefix + "_notallowed",
|
||||
Id: globals.StaticCredentialStorePrefix + "_notallowed",
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
res: nil,
|
||||
@@ -669,9 +668,9 @@ func TestCreateStatic(t *testing.T) {
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
idPrefix: credstatic.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.StaticCredentialStorePrefix + "_",
|
||||
res: &pbs.CreateCredentialStoreResponse{
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", credstatic.CredentialStorePrefix),
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", globals.StaticCredentialStorePrefix),
|
||||
Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
@@ -690,9 +689,9 @@ func TestCreateStatic(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
Type: credstatic.Subtype.String(),
|
||||
}},
|
||||
idPrefix: credstatic.CredentialStorePrefix + "_",
|
||||
idPrefix: globals.StaticCredentialStorePrefix + "_",
|
||||
res: &pbs.CreateCredentialStoreResponse{
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", credstatic.CredentialStorePrefix),
|
||||
Uri: fmt.Sprintf("credential-stores/%s_", globals.StaticCredentialStorePrefix),
|
||||
Item: &pb.CredentialStore{
|
||||
ScopeId: prj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: prj.GetPublicId(), Type: prj.GetType(), ParentScopeId: prj.GetParentId()},
|
||||
@@ -774,7 +773,7 @@ func TestGet(t *testing.T) {
|
||||
|
||||
vaultStore := vault.TestCredentialStores(t, conn, wrapper, prj.GetPublicId(), 1)[0]
|
||||
staticStore := credstatic.TestCredentialStore(t, conn, wrapper, prj.GetPublicId())
|
||||
staticStorePrev := credstatic.TestCredentialStore(t, conn, wrapper, prj.GetPublicId(), credstatic.WithPublicId(fmt.Sprintf("%s_1234567890", credstatic.PreviousCredentialStorePrefix)))
|
||||
staticStorePrev := credstatic.TestCredentialStore(t, conn, wrapper, prj.GetPublicId(), credstatic.WithPublicId(fmt.Sprintf("%s_1234567890", globals.StaticCredentialStorePreviousPrefix)))
|
||||
s, err := NewService(ctx, vaultRepoFn, staticRepoFn, iamRepoFn)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -846,17 +845,17 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "vault not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", vault.CredentialStorePrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.VaultCredentialStorePrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "static not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", credstatic.CredentialStorePrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticCredentialStorePrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "bad prefix",
|
||||
id: fmt.Sprintf("%s_1234567890", static.HostPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticHostPrefix),
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
}
|
||||
@@ -927,17 +926,17 @@ func TestDelete(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "vault not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", vault.CredentialStorePrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.VaultCredentialStorePrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "static not found error",
|
||||
id: fmt.Sprintf("%s_1234567890", credstatic.CredentialStorePrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticCredentialStorePrefix),
|
||||
err: handlers.NotFoundError(),
|
||||
},
|
||||
{
|
||||
name: "bad prefix",
|
||||
id: fmt.Sprintf("%s_1234567890", static.HostPrefix),
|
||||
id: fmt.Sprintf("%s_1234567890", globals.StaticHostPrefix),
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ func toProto(ctx context.Context, in *iam.Group, members []*iam.GroupMember, opt
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetGroupRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, iam.GroupPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.GroupPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateGroupRequest) error {
|
||||
@@ -674,11 +674,11 @@ func validateCreateRequest(req *pbs.CreateGroupRequest) error {
|
||||
}
|
||||
|
||||
func validateUpdateRequest(req *pbs.UpdateGroupRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), handlers.NoopValidatorFn, iam.GroupPrefix)
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), handlers.NoopValidatorFn, globals.GroupPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteGroupRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, iam.GroupPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.GroupPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListGroupsRequest) error {
|
||||
@@ -699,7 +699,7 @@ func validateListRequest(req *pbs.ListGroupsRequest) error {
|
||||
|
||||
func validateAddGroupMembersRequest(req *pbs.AddGroupMembersRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.GroupPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.GroupPrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -709,7 +709,7 @@ func validateAddGroupMembersRequest(req *pbs.AddGroupMembersRequest) error {
|
||||
badFields["member_ids"] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetMemberIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), iam.UserPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.UserPrefix) {
|
||||
badFields["member_ids"] = fmt.Sprintf("Must only contain valid user ids but found %q.", id)
|
||||
break
|
||||
}
|
||||
@@ -726,14 +726,14 @@ func validateAddGroupMembersRequest(req *pbs.AddGroupMembersRequest) error {
|
||||
|
||||
func validateSetGroupMembersRequest(req *pbs.SetGroupMembersRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.GroupPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.GroupPrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
badFields["version"] = "Required field."
|
||||
}
|
||||
for _, id := range req.GetMemberIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), iam.UserPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.UserPrefix) {
|
||||
badFields["member_ids"] = fmt.Sprintf("Must only contain valid user ids but found %q.", id)
|
||||
break
|
||||
}
|
||||
@@ -750,7 +750,7 @@ func validateSetGroupMembersRequest(req *pbs.SetGroupMembersRequest) error {
|
||||
|
||||
func validateRemoveGroupMembersRequest(req *pbs.RemoveGroupMembersRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.GroupPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.GroupPrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -760,7 +760,7 @@ func validateRemoveGroupMembersRequest(req *pbs.RemoveGroupMembersRequest) error
|
||||
badFields["member_ids"] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetMemberIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), iam.UserPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.UserPrefix) {
|
||||
badFields["member_ids"] = fmt.Sprintf("Must only contain valid user ids but found %q.", id)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existant Group",
|
||||
req: &pbs.GetGroupRequest{Id: iam.GroupPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetGroupRequest{Id: globals.GroupPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -161,7 +161,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetGroupRequest{Id: iam.GroupPrefix + "_1 23456789"},
|
||||
req: &pbs.GetGroupRequest{Id: globals.GroupPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -174,7 +174,7 @@ func TestGet(t *testing.T) {
|
||||
{
|
||||
name: "Project Scoped Get a non existant Group",
|
||||
scopeId: pg.GetScopeId(),
|
||||
req: &pbs.GetGroupRequest{Id: iam.GroupPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetGroupRequest{Id: globals.GroupPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -188,7 +188,7 @@ func TestGet(t *testing.T) {
|
||||
{
|
||||
name: "Project Scoped space in id",
|
||||
scopeId: pg.GetScopeId(),
|
||||
req: &pbs.GetGroupRequest{Id: iam.GroupPrefix + "_1 23456789"},
|
||||
req: &pbs.GetGroupRequest{Id: globals.GroupPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -371,7 +371,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Delete bad group id",
|
||||
scopeId: og.GetScopeId(),
|
||||
req: &pbs.DeleteGroupRequest{
|
||||
Id: iam.GroupPrefix + "_doesntexis",
|
||||
Id: globals.GroupPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -394,7 +394,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Project Scoped Delete bad group id",
|
||||
scopeId: pg.GetScopeId(),
|
||||
req: &pbs.DeleteGroupRequest{
|
||||
Id: iam.GroupPrefix + "_doesntexis",
|
||||
Id: globals.GroupPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -460,7 +460,7 @@ func TestCreate(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
}},
|
||||
res: &pbs.CreateGroupResponse{
|
||||
Uri: fmt.Sprintf("groups/%s_", iam.GroupPrefix),
|
||||
Uri: fmt.Sprintf("groups/%s_", globals.GroupPrefix),
|
||||
Item: &pb.Group{
|
||||
ScopeId: defaultOGroup.GetScopeId(),
|
||||
Scope: &scopes.ScopeInfo{Id: defaultOGroup.GetScopeId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
@@ -479,7 +479,7 @@ func TestCreate(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
}},
|
||||
res: &pbs.CreateGroupResponse{
|
||||
Uri: fmt.Sprintf("groups/%s_", iam.GroupPrefix),
|
||||
Uri: fmt.Sprintf("groups/%s_", globals.GroupPrefix),
|
||||
Item: &pb.Group{
|
||||
ScopeId: scope.Global.String(),
|
||||
Scope: &scopes.ScopeInfo{Id: scope.Global.String(), Type: scope.Global.String(), Name: scope.Global.String(), Description: "Global Scope"},
|
||||
@@ -500,7 +500,7 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateGroupResponse{
|
||||
Uri: fmt.Sprintf("groups/%s_", iam.GroupPrefix),
|
||||
Uri: fmt.Sprintf("groups/%s_", globals.GroupPrefix),
|
||||
Item: &pb.Group{
|
||||
ScopeId: defaultPGroup.GetScopeId(),
|
||||
Scope: &scopes.ScopeInfo{Id: defaultPGroup.GetScopeId(), Type: scope.Project.String(), ParentScopeId: defaultOGroup.GetScopeId()},
|
||||
@@ -514,7 +514,7 @@ func TestCreate(t *testing.T) {
|
||||
{
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateGroupRequest{Item: &pb.Group{
|
||||
Id: iam.GroupPrefix + "_notallowed",
|
||||
Id: globals.GroupPrefix + "_notallowed",
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -552,7 +552,7 @@ func TestCreate(t *testing.T) {
|
||||
}
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.Uri)
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), iam.GroupPrefix+"_"))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.GroupPrefix+"_"))
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
// Verify it is a group created after the test setup's default group
|
||||
@@ -873,7 +873,7 @@ func TestUpdate(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Group",
|
||||
req: &pbs.UpdateGroupRequest{
|
||||
Id: iam.GroupPrefix + "_DoesntExis",
|
||||
Id: globals.GroupPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
@@ -892,7 +892,7 @@ func TestUpdate(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.Group{
|
||||
Id: iam.GroupPrefix + "_somethinge",
|
||||
Id: globals.GroupPrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
|
||||
@@ -823,7 +823,7 @@ func toStoragePluginCatalog(ctx context.Context, projectId, plgId string, item *
|
||||
// - The type asserted by the ID and/or field is known
|
||||
// - If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
func validateGetRequest(req *pbs.GetHostCatalogRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, static.HostCatalogPrefix, plugin.HostCatalogPrefix, plugin.PreviousHostCatalogPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.StaticHostCatalogPrefix, globals.PluginHostCatalogPrefix, globals.PluginHostCatalogPreviousPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateHostCatalogRequest) error {
|
||||
@@ -879,11 +879,11 @@ func validateUpdateRequest(req *pbs.UpdateHostCatalogRequest) error {
|
||||
}
|
||||
}
|
||||
return badFields
|
||||
}, static.HostCatalogPrefix, plugin.HostCatalogPrefix, plugin.PreviousHostCatalogPrefix)
|
||||
}, globals.StaticHostCatalogPrefix, globals.PluginHostCatalogPrefix, globals.PluginHostCatalogPreviousPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteHostCatalogRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, static.HostCatalogPrefix, plugin.HostCatalogPrefix, plugin.PreviousHostCatalogPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.StaticHostCatalogPrefix, globals.PluginHostCatalogPrefix, globals.PluginHostCatalogPreviousPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListHostCatalogsRequest) error {
|
||||
|
||||
@@ -127,7 +127,7 @@ func TestGet_Static(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing Host Catalog",
|
||||
req: &pbs.GetHostCatalogRequest{Id: static.HostCatalogPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetHostCatalogRequest{Id: globals.StaticHostCatalogPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -139,7 +139,7 @@ func TestGet_Static(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetHostCatalogRequest{Id: static.HostCatalogPrefix + "_1 23456789"},
|
||||
req: &pbs.GetHostCatalogRequest{Id: globals.StaticHostCatalogPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -190,7 +190,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
name := "test"
|
||||
plg := host.TestPlugin(t, conn, name)
|
||||
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId(), plugin.WithSecretsHmac([]byte("foobar")))
|
||||
hcPrev := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId(), plugin.WithSecretsHmac([]byte("foobar")), plugin.WithPublicId(fmt.Sprintf("%s_1234567890", plugin.PreviousHostCatalogPrefix)))
|
||||
hcPrev := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId(), plugin.WithSecretsHmac([]byte("foobar")), plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostCatalogPreviousPrefix)))
|
||||
|
||||
toMerge := &pbs.GetHostCatalogRequest{
|
||||
Id: hc.GetPublicId(),
|
||||
@@ -242,7 +242,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing Host Catalog",
|
||||
req: &pbs.GetHostCatalogRequest{Id: plugin.HostCatalogPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetHostCatalogRequest{Id: globals.PluginHostCatalogPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -254,7 +254,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetHostCatalogRequest{Id: plugin.HostCatalogPrefix + "_1 23456789"},
|
||||
req: &pbs.GetHostCatalogRequest{Id: globals.PluginHostCatalogPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -529,7 +529,7 @@ func TestDelete_Static(t *testing.T) {
|
||||
name: "Delete bad id HostCatalog",
|
||||
scopeId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostCatalogRequest{
|
||||
Id: static.HostCatalogPrefix + "_doesntexis",
|
||||
Id: globals.StaticHostCatalogPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -537,7 +537,7 @@ func TestDelete_Static(t *testing.T) {
|
||||
name: "Bad HostCatalog Id formatting",
|
||||
scopeId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostCatalogRequest{
|
||||
Id: static.HostCatalogPrefix + "_bad_format",
|
||||
Id: globals.StaticHostCatalogPrefix + "_bad_format",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -600,7 +600,7 @@ func TestDelete_Plugin(t *testing.T) {
|
||||
name: "Delete bad id HostCatalog",
|
||||
scopeId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostCatalogRequest{
|
||||
Id: plugin.HostCatalogPrefix + "_doesntexis",
|
||||
Id: globals.PluginHostCatalogPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -608,7 +608,7 @@ func TestDelete_Plugin(t *testing.T) {
|
||||
name: "Bad HostCatalog Id formatting",
|
||||
scopeId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostCatalogRequest{
|
||||
Id: plugin.HostCatalogPrefix + "_bad_format",
|
||||
Id: globals.PluginHostCatalogPrefix + "_bad_format",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -703,7 +703,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
Type: "static",
|
||||
}},
|
||||
res: &pbs.CreateHostCatalogResponse{
|
||||
Uri: fmt.Sprintf("host-catalogs/%s_", static.HostCatalogPrefix),
|
||||
Uri: fmt.Sprintf("host-catalogs/%s_", globals.StaticHostCatalogPrefix),
|
||||
Item: &pb.HostCatalog{
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: proj.GetParentId()},
|
||||
@@ -793,7 +793,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
}
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.GetUri())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), static.HostCatalogPrefix))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.StaticHostCatalogPrefix))
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
require.NoError(err, "Error converting proto to timestamp.")
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
@@ -865,7 +865,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
PluginId: plg.GetPublicId(),
|
||||
}},
|
||||
res: &pbs.CreateHostCatalogResponse{
|
||||
Uri: fmt.Sprintf("host-catalogs/%s_", plugin.HostCatalogPrefix),
|
||||
Uri: fmt.Sprintf("host-catalogs/%s_", globals.PluginHostCatalogPrefix),
|
||||
Item: &pb.HostCatalog{
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: proj.GetParentId()},
|
||||
@@ -970,7 +970,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
require.NoError(gErr)
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.GetUri())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), fmt.Sprintf("%s_", plugin.HostCatalogPrefix)))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), fmt.Sprintf("%s_", globals.PluginHostCatalogPrefix)))
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
require.NoError(err, "Error converting proto to timestamp.")
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
@@ -1241,7 +1241,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing HostCatalog",
|
||||
req: &pbs.UpdateHostCatalogRequest{
|
||||
Id: static.HostCatalogPrefix + "_DoesntExis",
|
||||
Id: globals.StaticHostCatalogPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
|
||||
@@ -946,13 +946,13 @@ func toStoragePluginSet(ctx context.Context, catalogId string, item *pb.HostSet)
|
||||
// - The type asserted by the ID and/or field is known
|
||||
// - If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
func validateGetRequest(req *pbs.GetHostSetRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, static.HostSetPrefix, plugin.HostSetPrefix, plugin.PreviousHostSetPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.StaticHostSetPrefix, globals.PluginHostSetPrefix, globals.PluginHostSetPreviousPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(ctx context.Context, req *pbs.CreateHostSetRequest) error {
|
||||
return handlers.ValidateCreateRequest(req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetItem().GetHostCatalogId()), static.HostCatalogPrefix, plugin.HostCatalogPrefix, plugin.PreviousHostCatalogPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetItem().GetHostCatalogId()), globals.StaticHostCatalogPrefix, globals.PluginHostCatalogPrefix, globals.PluginHostCatalogPreviousPrefix) {
|
||||
badFields[globals.HostCatalogIdField] = "The field is incorrectly formatted."
|
||||
}
|
||||
if len(req.GetItem().GetPreferredEndpoints()) > 0 {
|
||||
@@ -1005,16 +1005,16 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateHostSetRequest) e
|
||||
}
|
||||
}
|
||||
return badFields
|
||||
}, static.HostSetPrefix, plugin.HostSetPrefix, plugin.PreviousHostSetPrefix)
|
||||
}, globals.StaticHostSetPrefix, globals.PluginHostSetPrefix, globals.PluginHostSetPreviousPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteHostSetRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, static.HostSetPrefix, plugin.HostSetPrefix, plugin.PreviousHostSetPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.StaticHostSetPrefix, globals.PluginHostSetPrefix, globals.PluginHostSetPreviousPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListHostSetsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetHostCatalogId()), static.HostCatalogPrefix, plugin.HostCatalogPrefix, plugin.PreviousHostCatalogPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetHostCatalogId()), globals.StaticHostCatalogPrefix, globals.PluginHostCatalogPrefix, globals.PluginHostCatalogPreviousPrefix) {
|
||||
badFields[globals.HostCatalogIdField] = "The field is incorrectly formatted."
|
||||
}
|
||||
if _, err := handlers.NewFilter(req.GetFilter()); err != nil {
|
||||
@@ -1028,7 +1028,7 @@ func validateListRequest(req *pbs.ListHostSetsRequest) error {
|
||||
|
||||
func validateAddRequest(req *pbs.AddHostSetHostsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), static.HostSetPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.StaticHostSetPrefix) {
|
||||
badFields[globals.IdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1038,7 +1038,7 @@ func validateAddRequest(req *pbs.AddHostSetHostsRequest) error {
|
||||
badFields[globals.HostIdsField] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetHostIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), static.HostPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.StaticHostPrefix) {
|
||||
badFields[globals.HostIdsField] = "Incorrectly formatted host identifier."
|
||||
break
|
||||
}
|
||||
@@ -1051,14 +1051,14 @@ func validateAddRequest(req *pbs.AddHostSetHostsRequest) error {
|
||||
|
||||
func validateSetRequest(req *pbs.SetHostSetHostsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), static.HostSetPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.StaticHostSetPrefix) {
|
||||
badFields[globals.IdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
badFields[globals.VersionField] = "Required field."
|
||||
}
|
||||
for _, id := range req.GetHostIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), static.HostPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.StaticHostPrefix) {
|
||||
badFields[globals.HostIdsField] = "Incorrectly formatted host identifier."
|
||||
break
|
||||
}
|
||||
@@ -1071,7 +1071,7 @@ func validateSetRequest(req *pbs.SetHostSetHostsRequest) error {
|
||||
|
||||
func validateRemoveRequest(req *pbs.RemoveHostSetHostsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), static.HostSetPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.StaticHostSetPrefix) {
|
||||
badFields[globals.IdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1081,7 +1081,7 @@ func validateRemoveRequest(req *pbs.RemoveHostSetHostsRequest) error {
|
||||
badFields[globals.HostIdsField] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetHostIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), static.HostPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.StaticHostPrefix) {
|
||||
badFields[globals.HostIdsField] = "Incorrectly formatted host identifier."
|
||||
break
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestGet_Static(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing Host Set",
|
||||
req: &pbs.GetHostSetRequest{Id: static.HostSetPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetHostSetRequest{Id: globals.StaticHostSetPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -115,7 +115,7 @@ func TestGet_Static(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetHostSetRequest{Id: static.HostPrefix + "_1 23456789"},
|
||||
req: &pbs.GetHostSetRequest{Id: globals.StaticHostPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -174,7 +174,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
|
||||
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
|
||||
hs := plugin.TestSet(t, conn, kms, sche, hc, plgm, plugin.WithPreferredEndpoints(prefEndpoints), plugin.WithSyncIntervalSeconds(-1))
|
||||
hsPrev := plugin.TestSet(t, conn, kms, sche, hc, plgm, plugin.WithPreferredEndpoints(prefEndpoints), plugin.WithSyncIntervalSeconds(-1), plugin.WithPublicId(fmt.Sprintf("%s_1234567890", plugin.PreviousHostSetPrefix)))
|
||||
hsPrev := plugin.TestSet(t, conn, kms, sche, hc, plgm, plugin.WithPreferredEndpoints(prefEndpoints), plugin.WithSyncIntervalSeconds(-1), plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostSetPreviousPrefix)))
|
||||
|
||||
toMerge := &pbs.GetHostSetRequest{}
|
||||
|
||||
@@ -219,7 +219,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing Host Set",
|
||||
req: &pbs.GetHostSetRequest{Id: plugin.HostSetPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetHostSetRequest{Id: globals.PluginHostSetPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -231,7 +231,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetHostSetRequest{Id: plugin.HostSetPrefix + "_1 23456789"},
|
||||
req: &pbs.GetHostSetRequest{Id: globals.PluginHostSetPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -518,7 +518,7 @@ func TestDelete_Static(t *testing.T) {
|
||||
name: "Delete bad id Host Set",
|
||||
projectId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostSetRequest{
|
||||
Id: static.HostSetPrefix + "_doesntexis",
|
||||
Id: globals.StaticHostSetPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -526,7 +526,7 @@ func TestDelete_Static(t *testing.T) {
|
||||
name: "Bad Host Id formatting",
|
||||
projectId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostSetRequest{
|
||||
Id: static.HostSetPrefix + "_bad_format",
|
||||
Id: globals.StaticHostSetPrefix + "_bad_format",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -595,7 +595,7 @@ func TestDelete_Plugin(t *testing.T) {
|
||||
name: "Delete bad id Host Set",
|
||||
projectId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostSetRequest{
|
||||
Id: plugin.HostSetPrefix + "_doesntexis",
|
||||
Id: globals.PluginHostSetPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -603,7 +603,7 @@ func TestDelete_Plugin(t *testing.T) {
|
||||
name: "Bad Host Id formatting",
|
||||
projectId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostSetRequest{
|
||||
Id: plugin.HostSetPrefix + "_bad_format",
|
||||
Id: globals.PluginHostSetPrefix + "_bad_format",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -700,7 +700,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
Type: "static",
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
Uri: fmt.Sprintf("host-sets/%s_", static.HostSetPrefix),
|
||||
Uri: fmt.Sprintf("host-sets/%s_", globals.StaticHostSetPrefix),
|
||||
Item: &pb.HostSet{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -740,7 +740,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
Description: &wrappers.StringValue{Value: "no type desc"},
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
Uri: fmt.Sprintf("host-sets/%s_", static.HostSetPrefix),
|
||||
Uri: fmt.Sprintf("host-sets/%s_", globals.StaticHostSetPrefix),
|
||||
Item: &pb.HostSet{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -793,7 +793,7 @@ func TestCreate_Static(t *testing.T) {
|
||||
}
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.GetUri())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), static.HostSetPrefix), got.GetItem().GetId())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.StaticHostSetPrefix), got.GetItem().GetId())
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
require.NoError(err, "Error converting proto to timestamp.")
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
@@ -894,7 +894,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: -1},
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
Uri: fmt.Sprintf("host-sets/%s_", plugin.HostSetPrefix),
|
||||
Uri: fmt.Sprintf("host-sets/%s_", globals.PluginHostSetPrefix),
|
||||
Item: &pb.HostSet{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -924,7 +924,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
},
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
Uri: fmt.Sprintf("host-sets/%s_", plugin.HostSetPrefix),
|
||||
Uri: fmt.Sprintf("host-sets/%s_", globals.PluginHostSetPrefix),
|
||||
Item: &pb.HostSet{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -954,7 +954,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
PreferredEndpoints: prefEndpoints,
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
Uri: fmt.Sprintf("host-sets/%s_", plugin.HostSetPrefix),
|
||||
Uri: fmt.Sprintf("host-sets/%s_", globals.PluginHostSetPrefix),
|
||||
Item: &pb.HostSet{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -1000,7 +1000,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
Description: &wrappers.StringValue{Value: "no type desc"},
|
||||
}},
|
||||
res: &pbs.CreateHostSetResponse{
|
||||
Uri: fmt.Sprintf("host-sets/%s_", plugin.HostSetPrefix),
|
||||
Uri: fmt.Sprintf("host-sets/%s_", globals.PluginHostSetPrefix),
|
||||
Item: &pb.HostSet{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -1060,7 +1060,7 @@ func TestCreate_Plugin(t *testing.T) {
|
||||
require.NoError(gErr)
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.GetUri())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), plugin.HostSetPrefix), got.GetItem().GetId())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.PluginHostSetPrefix), got.GetItem().GetId())
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
require.NoError(err, "Error converting proto to timestamp.")
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
@@ -1338,7 +1338,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Host Set",
|
||||
req: &pbs.UpdateHostSetRequest{
|
||||
Id: static.HostSetPrefix + "_DoesntExis",
|
||||
Id: globals.StaticHostSetPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
|
||||
@@ -617,13 +617,13 @@ func validateGetRequest(req *pbs.GetHostRequest) error {
|
||||
badFields["id"] = "Improperly formatted identifier used."
|
||||
}
|
||||
return badFields
|
||||
}, req, static.HostPrefix, plugin.HostPrefix, plugin.PreviousHostPrefix)
|
||||
}, req, globals.StaticHostPrefix, globals.PluginHostPrefix, globals.PluginHostPreviousPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateHostRequest) error {
|
||||
return handlers.ValidateCreateRequest(req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetItem().GetHostCatalogId()), static.HostCatalogPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetItem().GetHostCatalogId()), globals.StaticHostCatalogPrefix) {
|
||||
badFields["host_catalog_id"] = "The field is incorrectly formatted."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetHostCatalogId()) {
|
||||
@@ -702,7 +702,7 @@ func validateUpdateRequest(req *pbs.UpdateHostRequest) error {
|
||||
badFields["id"] = "Improperly formatted identifier used."
|
||||
}
|
||||
return badFields
|
||||
}, static.HostPrefix)
|
||||
}, globals.StaticHostPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteHostRequest) error {
|
||||
@@ -713,12 +713,12 @@ func validateDeleteRequest(req *pbs.DeleteHostRequest) error {
|
||||
badFields[globals.IdField] = "Cannot manually delete this type of host."
|
||||
}
|
||||
return badFields
|
||||
}, req, static.HostPrefix)
|
||||
}, req, globals.StaticHostPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListHostsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetHostCatalogId()), static.HostCatalogPrefix, plugin.HostCatalogPrefix, plugin.PreviousHostCatalogPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetHostCatalogId()), globals.StaticHostCatalogPrefix, globals.PluginHostCatalogPrefix, globals.PluginHostCatalogPreviousPrefix) {
|
||||
badFields["host_catalog_id"] = "The field is incorrectly formatted."
|
||||
}
|
||||
if _, err := handlers.NewFilter(req.GetFilter()); err != nil {
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestGet_Static(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing Host Set",
|
||||
req: &pbs.GetHostRequest{Id: static.HostPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetHostRequest{Id: globals.StaticHostPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -113,7 +113,7 @@ func TestGet_Static(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetHostRequest{Id: static.HostPrefix + "_1 23456789"},
|
||||
req: &pbs.GetHostRequest{Id: globals.StaticHostPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -166,7 +166,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
}
|
||||
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
|
||||
h := plugin.TestHost(t, conn, hc.GetPublicId(), "test")
|
||||
hPrev := plugin.TestHost(t, conn, hc.GetPublicId(), "test-prev", plugin.WithPublicId(fmt.Sprintf("%s_1234567890", plugin.PreviousHostPrefix)))
|
||||
hPrev := plugin.TestHost(t, conn, hc.GetPublicId(), "test-prev", plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostPreviousPrefix)))
|
||||
hs := plugin.TestSet(t, conn, kms, sche, hc, plgm)
|
||||
plugin.TestSetMembers(t, conn, hs.GetPublicId(), []*plugin.Host{h, hPrev})
|
||||
|
||||
@@ -212,7 +212,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "non existing",
|
||||
req: &pbs.GetHostRequest{Id: plugin.HostPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetHostRequest{Id: globals.PluginHostPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -224,7 +224,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetHostRequest{Id: plugin.HostPrefix + "_1 23456789"},
|
||||
req: &pbs.GetHostRequest{Id: globals.PluginHostPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -548,7 +548,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Delete bad id Host",
|
||||
projectId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostRequest{
|
||||
Id: static.HostPrefix + "_doesntexis",
|
||||
Id: globals.StaticHostPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -556,7 +556,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Bad Host Id formatting",
|
||||
projectId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteHostRequest{
|
||||
Id: static.HostPrefix + "_bad_format",
|
||||
Id: globals.StaticHostPrefix + "_bad_format",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -661,7 +661,7 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
}},
|
||||
res: &pbs.CreateHostResponse{
|
||||
Uri: fmt.Sprintf("hosts/%s_", static.HostPrefix),
|
||||
Uri: fmt.Sprintf("hosts/%s_", globals.StaticHostPrefix),
|
||||
Item: &pb.Host{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -749,7 +749,7 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
}},
|
||||
res: &pbs.CreateHostResponse{
|
||||
Uri: fmt.Sprintf("hosts/%s_", static.HostPrefix),
|
||||
Uri: fmt.Sprintf("hosts/%s_", globals.StaticHostPrefix),
|
||||
Item: &pb.Host{
|
||||
HostCatalogId: hc.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -828,7 +828,7 @@ func TestCreate(t *testing.T) {
|
||||
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.GetUri())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), static.HostPrefix))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.StaticHostPrefix))
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
// Verify it is a set created after the test setup's default set
|
||||
@@ -1142,7 +1142,7 @@ func TestUpdate_Static(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Host",
|
||||
req: &pbs.UpdateHostRequest{
|
||||
Id: static.HostPrefix + "_DoesntExis",
|
||||
Id: globals.StaticHostPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
@@ -583,7 +582,7 @@ func validateGetRequest(req *pbs.GetManagedGroupRequest) error {
|
||||
if req == nil {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, intglobals.OidcManagedGroupPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.OidcManagedGroupPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateManagedGroupRequest) error {
|
||||
@@ -651,7 +650,7 @@ func validateUpdateRequest(req *pbs.UpdateManagedGroupRequest) error {
|
||||
badFields[globals.IdField] = "Unrecognized resource type."
|
||||
}
|
||||
return badFields
|
||||
}, intglobals.OidcManagedGroupPrefix)
|
||||
}, globals.OidcManagedGroupPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteManagedGroupRequest) error {
|
||||
@@ -659,7 +658,7 @@ func validateDeleteRequest(req *pbs.DeleteManagedGroupRequest) error {
|
||||
if req == nil {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, intglobals.OidcManagedGroupPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.OidcManagedGroupPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListManagedGroupsRequest) error {
|
||||
@@ -668,7 +667,7 @@ func validateListRequest(req *pbs.ListManagedGroupsRequest) error {
|
||||
return errors.NewDeprecated(errors.InvalidParameter, op, "nil request")
|
||||
}
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetAuthMethodId()), oidc.AuthMethodPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetAuthMethodId()), globals.OidcAuthMethodPrefix) {
|
||||
badFields[globals.AuthMethodIdField] = "Invalid formatted identifier."
|
||||
}
|
||||
if _, err := handlers.NewFilter(req.GetFilter()); err != nil {
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
@@ -24,7 +23,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
@@ -155,7 +153,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing oidc managed group",
|
||||
req: &pbs.GetManagedGroupRequest{Id: intglobals.OidcManagedGroupPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetManagedGroupRequest{Id: globals.OidcManagedGroupPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -167,7 +165,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetManagedGroupRequest{Id: authtoken.AuthTokenPrefix + "_1 23456789"},
|
||||
req: &pbs.GetManagedGroupRequest{Id: globals.AuthTokenPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -276,7 +274,7 @@ func TestListOidc(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Unfound Auth Method",
|
||||
req: &pbs.ListManagedGroupsRequest{AuthMethodId: oidc.AuthMethodPrefix + "_DoesntExis"},
|
||||
req: &pbs.ListManagedGroupsRequest{AuthMethodId: globals.OidcAuthMethodPrefix + "_DoesntExis"},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
{
|
||||
@@ -384,7 +382,7 @@ func TestDelete(t *testing.T) {
|
||||
{
|
||||
name: "Delete bad oidc managed group id",
|
||||
req: &pbs.DeleteManagedGroupRequest{
|
||||
Id: intglobals.OidcManagedGroupPrefix + "_doesntexis",
|
||||
Id: globals.OidcManagedGroupPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -499,7 +497,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateManagedGroupResponse{
|
||||
Uri: fmt.Sprintf("managed-groups/%s_", intglobals.OidcManagedGroupPrefix),
|
||||
Uri: fmt.Sprintf("managed-groups/%s_", globals.OidcManagedGroupPrefix),
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Name: &wrapperspb.StringValue{Value: "name"},
|
||||
@@ -529,7 +527,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateManagedGroupResponse{
|
||||
Uri: fmt.Sprintf("managed-groups/%s_", intglobals.OidcManagedGroupPrefix),
|
||||
Uri: fmt.Sprintf("managed-groups/%s_", globals.OidcManagedGroupPrefix),
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
@@ -565,7 +563,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
req: &pbs.CreateManagedGroupRequest{
|
||||
Item: &pb.ManagedGroup{
|
||||
AuthMethodId: am.GetPublicId(),
|
||||
Id: intglobals.OidcManagedGroupPrefix + "_notallowed",
|
||||
Id: globals.OidcManagedGroupPrefix + "_notallowed",
|
||||
Type: oidc.Subtype.String(),
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
@@ -641,7 +639,7 @@ func TestCreateOidc(t *testing.T) {
|
||||
require.NoError(gErr)
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.Uri)
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), intglobals.OidcManagedGroupPrefix+"_"))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.OidcManagedGroupPrefix+"_"))
|
||||
// Clear all values which are hard to compare against.
|
||||
got.Uri, tc.res.Uri = "", ""
|
||||
got.Item.Id, tc.res.Item.Id = "", ""
|
||||
@@ -886,7 +884,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing ManagedGroup",
|
||||
req: &pbs.UpdateManagedGroupRequest{
|
||||
Id: intglobals.OidcManagedGroupPrefix + "_DoesntExis",
|
||||
Id: globals.OidcManagedGroupPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{globals.DescriptionField},
|
||||
},
|
||||
@@ -904,7 +902,7 @@ func TestUpdateOidc(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.ManagedGroup{
|
||||
Id: intglobals.OidcManagedGroupPrefix + "_somethinge",
|
||||
Id: globals.OidcManagedGroupPrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/managedgroups"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -41,7 +40,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "mismatched oidc authmethod pw type",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: "ldap",
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
},
|
||||
errContains: fieldError(globals.TypeField, "Doesn't match the parent resource's type."),
|
||||
},
|
||||
@@ -49,7 +48,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "missing oidc attributes",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: nil,
|
||||
},
|
||||
errContains: fieldError(globals.AttributesField, "Attribute fields is required."),
|
||||
@@ -58,7 +57,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "bad oidc attributes",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: "foobar",
|
||||
@@ -71,7 +70,7 @@ func TestValidateCreateRequest(t *testing.T) {
|
||||
name: "no oidc errors",
|
||||
item: &pb.ManagedGroup{
|
||||
Type: oidc.Subtype.String(),
|
||||
AuthMethodId: oidc.AuthMethodPrefix + "_1234567890",
|
||||
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
|
||||
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
|
||||
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
|
||||
Filter: `"/foo/bar" == "zipzap"`,
|
||||
@@ -106,7 +105,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
{
|
||||
name: "oidc to password change type",
|
||||
req: &pbs.UpdateManagedGroupRequest{
|
||||
Id: intglobals.OidcManagedGroupPrefix + "_1234567890",
|
||||
Id: globals.OidcManagedGroupPrefix + "_1234567890",
|
||||
Item: &pb.ManagedGroup{
|
||||
Type: password.Subtype.String(),
|
||||
},
|
||||
@@ -116,7 +115,7 @@ func TestValidateUpdateRequest(t *testing.T) {
|
||||
{
|
||||
name: "no error",
|
||||
req: &pbs.UpdateManagedGroupRequest{
|
||||
Id: intglobals.OidcManagedGroupPrefix + "_1234567890",
|
||||
Id: globals.OidcManagedGroupPrefix + "_1234567890",
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{}},
|
||||
Item: &pb.ManagedGroup{
|
||||
Version: 1,
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/iam/store"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
@@ -887,7 +886,7 @@ func toProto(ctx context.Context, in *iam.Role, principals []*iam.PrincipalRole,
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetRoleRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, iam.RolePrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.RolePrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateRoleRequest) error {
|
||||
@@ -935,13 +934,13 @@ func validateUpdateRequest(req *pbs.UpdateRoleRequest) error {
|
||||
}
|
||||
}
|
||||
return badFields
|
||||
}, iam.RolePrefix)
|
||||
}, globals.RolePrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteRoleRequest) error {
|
||||
return handlers.ValidateDeleteRequest(func() map[string]string {
|
||||
return nil
|
||||
}, req, iam.RolePrefix)
|
||||
}, req, globals.RolePrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListRolesRequest) error {
|
||||
@@ -962,7 +961,7 @@ func validateListRequest(req *pbs.ListRolesRequest) error {
|
||||
|
||||
func validateAddRolePrincipalsRequest(req *pbs.AddRolePrincipalsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.RolePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.RolePrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -972,9 +971,9 @@ func validateAddRolePrincipalsRequest(req *pbs.AddRolePrincipalsRequest) error {
|
||||
badFields["principal_ids"] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetPrincipalIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), iam.GroupPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), iam.UserPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), intglobals.OidcManagedGroupPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.GroupPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), globals.UserPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), globals.OidcManagedGroupPrefix) {
|
||||
badFields["principal_ids"] = "Must only have valid user, group, and/or managed group ids."
|
||||
break
|
||||
}
|
||||
@@ -991,16 +990,16 @@ func validateAddRolePrincipalsRequest(req *pbs.AddRolePrincipalsRequest) error {
|
||||
|
||||
func validateSetRolePrincipalsRequest(req *pbs.SetRolePrincipalsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.RolePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.RolePrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
badFields["version"] = "Required field."
|
||||
}
|
||||
for _, id := range req.GetPrincipalIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), iam.GroupPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), iam.UserPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), intglobals.OidcManagedGroupPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.GroupPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), globals.UserPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), globals.OidcManagedGroupPrefix) {
|
||||
badFields["principal_ids"] = "Must only have valid user, group, and/or managed group ids."
|
||||
break
|
||||
}
|
||||
@@ -1017,7 +1016,7 @@ func validateSetRolePrincipalsRequest(req *pbs.SetRolePrincipalsRequest) error {
|
||||
|
||||
func validateRemoveRolePrincipalsRequest(req *pbs.RemoveRolePrincipalsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.RolePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.RolePrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1027,9 +1026,9 @@ func validateRemoveRolePrincipalsRequest(req *pbs.RemoveRolePrincipalsRequest) e
|
||||
badFields["principal_ids"] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetPrincipalIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), iam.GroupPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), iam.UserPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), intglobals.OidcManagedGroupPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.GroupPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), globals.UserPrefix) &&
|
||||
!handlers.ValidId(handlers.Id(id), globals.OidcManagedGroupPrefix) {
|
||||
badFields["principal_ids"] = "Must only have valid user, group, and/or managed group ids."
|
||||
break
|
||||
}
|
||||
@@ -1042,7 +1041,7 @@ func validateRemoveRolePrincipalsRequest(req *pbs.RemoveRolePrincipalsRequest) e
|
||||
|
||||
func validateAddRoleGrantsRequest(req *pbs.AddRoleGrantsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.RolePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.RolePrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1076,7 +1075,7 @@ func validateAddRoleGrantsRequest(req *pbs.AddRoleGrantsRequest) error {
|
||||
|
||||
func validateSetRoleGrantsRequest(req *pbs.SetRoleGrantsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.RolePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.RolePrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1107,7 +1106,7 @@ func validateSetRoleGrantsRequest(req *pbs.SetRoleGrantsRequest) error {
|
||||
|
||||
func validateRemoveRoleGrantsRequest(req *pbs.RemoveRoleGrantsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.RolePrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.RolePrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
|
||||
@@ -126,7 +126,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existant Role",
|
||||
req: &pbs.GetRoleRequest{Id: iam.RolePrefix + "_DoesntExis"},
|
||||
req: &pbs.GetRoleRequest{Id: globals.RolePrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -138,7 +138,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetRoleRequest{Id: iam.RolePrefix + "_1 23456789"},
|
||||
req: &pbs.GetRoleRequest{Id: globals.RolePrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -151,7 +151,7 @@ func TestGet(t *testing.T) {
|
||||
{
|
||||
name: "Project Scoped Get a non existant Role",
|
||||
scopeId: pr.GetScopeId(),
|
||||
req: &pbs.GetRoleRequest{Id: iam.RolePrefix + "_DoesntExis"},
|
||||
req: &pbs.GetRoleRequest{Id: globals.RolePrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -165,7 +165,7 @@ func TestGet(t *testing.T) {
|
||||
{
|
||||
name: "Project Scoped space in id",
|
||||
scopeId: pr.GetScopeId(),
|
||||
req: &pbs.GetRoleRequest{Id: iam.RolePrefix + "_1 23456789"},
|
||||
req: &pbs.GetRoleRequest{Id: globals.RolePrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -352,7 +352,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Delete bad role id",
|
||||
scopeId: or.GetScopeId(),
|
||||
req: &pbs.DeleteRoleRequest{
|
||||
Id: iam.RolePrefix + "_doesntexis",
|
||||
Id: globals.RolePrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -375,7 +375,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Project Scoped Delete bad Role id",
|
||||
scopeId: pr.GetScopeId(),
|
||||
req: &pbs.DeleteRoleRequest{
|
||||
Id: iam.RolePrefix + "_doesntexis",
|
||||
Id: globals.RolePrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -440,7 +440,7 @@ func TestCreate(t *testing.T) {
|
||||
GrantScopeId: &wrapperspb.StringValue{Value: defaultProjRole.ScopeId},
|
||||
}},
|
||||
res: &pbs.CreateRoleResponse{
|
||||
Uri: fmt.Sprintf("roles/%s_", iam.RolePrefix),
|
||||
Uri: fmt.Sprintf("roles/%s_", globals.RolePrefix),
|
||||
Item: &pb.Role{
|
||||
ScopeId: defaultOrgRole.GetScopeId(),
|
||||
Scope: &scopes.ScopeInfo{Id: defaultOrgRole.GetScopeId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
@@ -461,7 +461,7 @@ func TestCreate(t *testing.T) {
|
||||
GrantScopeId: &wrapperspb.StringValue{Value: defaultProjRole.ScopeId},
|
||||
}},
|
||||
res: &pbs.CreateRoleResponse{
|
||||
Uri: fmt.Sprintf("roles/%s_", iam.RolePrefix),
|
||||
Uri: fmt.Sprintf("roles/%s_", globals.RolePrefix),
|
||||
Item: &pb.Role{
|
||||
ScopeId: scope.Global.String(),
|
||||
Scope: &scopes.ScopeInfo{Id: scope.Global.String(), Type: scope.Global.String(), Name: scope.Global.String(), Description: "Global Scope"},
|
||||
@@ -483,7 +483,7 @@ func TestCreate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
res: &pbs.CreateRoleResponse{
|
||||
Uri: fmt.Sprintf("roles/%s_", iam.RolePrefix),
|
||||
Uri: fmt.Sprintf("roles/%s_", globals.RolePrefix),
|
||||
Item: &pb.Role{
|
||||
ScopeId: defaultProjRole.GetScopeId(),
|
||||
Scope: &scopes.ScopeInfo{Id: defaultProjRole.GetScopeId(), Type: scope.Project.String(), ParentScopeId: defaultOrgRole.GetScopeId()},
|
||||
@@ -512,7 +512,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateRoleRequest{Item: &pb.Role{
|
||||
ScopeId: defaultProjRole.GetScopeId(),
|
||||
Id: iam.RolePrefix + "_notallowed",
|
||||
Id: globals.RolePrefix + "_notallowed",
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -552,7 +552,7 @@ func TestCreate(t *testing.T) {
|
||||
}
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.Uri)
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), iam.RolePrefix+"_"), "Expected %q to have the prefix %q", got.GetItem().GetId(), iam.RolePrefix+"_")
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.RolePrefix+"_"), "Expected %q to have the prefix %q", got.GetItem().GetId(), globals.RolePrefix+"_")
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
// Verify it is a role created after the test setup's default role
|
||||
@@ -882,7 +882,7 @@ func TestUpdate(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Role",
|
||||
req: &pbs.UpdateRoleRequest{
|
||||
Id: iam.RolePrefix + "_DoesntExis",
|
||||
Id: globals.RolePrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
@@ -900,7 +900,7 @@ func TestUpdate(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.Role{
|
||||
Id: iam.RolePrefix + "_somethinge",
|
||||
Id: globals.RolePrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
|
||||
@@ -10,8 +10,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/auth/password"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common/scopeids"
|
||||
@@ -574,7 +572,7 @@ func (s Service) updateInRepo(ctx context.Context, parentScope *pb.ScopeInfo, sc
|
||||
opts = append(opts, iam.WithName(scopeName))
|
||||
}
|
||||
if primaryAuthMethodId := item.GetPrimaryAuthMethodId(); primaryAuthMethodId != nil {
|
||||
if !handlers.ValidId(handlers.Id(primaryAuthMethodId.GetValue()), password.AuthMethodPrefix, oidc.AuthMethodPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(primaryAuthMethodId.GetValue()), globals.PasswordAuthMethodPrefix, globals.OidcAuthMethodPrefix) {
|
||||
return nil, handlers.InvalidArgumentErrorf("Error in provided request.", map[string]string{"primary_auth_method_id": "Improperly formatted identifier"})
|
||||
}
|
||||
scopePrimaryAuthMethodId = primaryAuthMethodId.GetValue()
|
||||
@@ -931,7 +929,7 @@ func validateUpdateRequest(req *pbs.UpdateScopeRequest) error {
|
||||
if item.GetUpdatedTime() != nil {
|
||||
badFields["updated_time"] = "This is a read only field and cannot be specified in an update request."
|
||||
}
|
||||
if item.GetPrimaryAuthMethodId().GetValue() != "" && !handlers.ValidId(handlers.Id(item.GetPrimaryAuthMethodId().GetValue()), password.AuthMethodPrefix, oidc.AuthMethodPrefix) {
|
||||
if item.GetPrimaryAuthMethodId().GetValue() != "" && !handlers.ValidId(handlers.Id(item.GetPrimaryAuthMethodId().GetValue()), globals.PasswordAuthMethodPrefix, globals.OidcAuthMethodPrefix) {
|
||||
badFields["primary_auth_method_id"] = "Improperly formatted identifier."
|
||||
}
|
||||
if len(badFields) > 0 {
|
||||
|
||||
@@ -467,7 +467,7 @@ func toProto(ctx context.Context, in *session.Session, opt ...handlers.Option) (
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetSessionRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, session.SessionPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.SessionPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListSessionsRequest) error {
|
||||
@@ -487,7 +487,7 @@ func validateListRequest(req *pbs.ListSessionsRequest) error {
|
||||
|
||||
func validateCancelRequest(req *pbs.CancelSessionRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), session.SessionPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.SessionPrefix) {
|
||||
badFields["id"] = "Improperly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
@@ -116,7 +117,7 @@ func TestGetSession(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existent Session",
|
||||
req: &pbs.GetSessionRequest{Id: session.SessionPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetSessionRequest{Id: globals.SessionPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -128,7 +129,7 @@ func TestGetSession(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetSessionRequest{Id: session.SessionPrefix + "_1 23456789"},
|
||||
req: &pbs.GetSessionRequest{Id: globals.SessionPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -690,7 +691,7 @@ func TestCancel(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Cancel a non existing Session",
|
||||
req: &pbs.CancelSessionRequest{Id: session.SessionPrefix + "_DoesntExis"},
|
||||
req: &pbs.CancelSessionRequest{Id: globals.SessionPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -702,7 +703,7 @@ func TestCancel(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.CancelSessionRequest{Id: session.SessionPrefix + "_1 23456789"},
|
||||
req: &pbs.CancelSessionRequest{Id: globals.SessionPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/credential"
|
||||
"github.com/hashicorp/boundary/internal/credential/vault"
|
||||
wl "github.com/hashicorp/boundary/internal/daemon/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
@@ -1719,7 +1718,7 @@ func validateAddHostSourcesRequest(req *pbs.AddTargetHostSourcesRequest) error {
|
||||
badFields[globals.HostSourceIdsField] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetHostSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), static.HostSetPrefix, plugin.HostSetPrefix, plugin.PreviousHostSetPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.StaticHostSetPrefix, globals.PluginHostSetPrefix, globals.PluginHostSetPreviousPrefix) {
|
||||
badFields[globals.HostSourceIdsField] = fmt.Sprintf("Incorrectly formatted host source identifier %q.", id)
|
||||
break
|
||||
}
|
||||
@@ -1739,7 +1738,7 @@ func validateSetHostSourcesRequest(req *pbs.SetTargetHostSourcesRequest) error {
|
||||
badFields[globals.VersionField] = "Required field."
|
||||
}
|
||||
for _, id := range req.GetHostSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), static.HostSetPrefix, plugin.HostSetPrefix, plugin.PreviousHostSetPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.StaticHostSetPrefix, globals.PluginHostSetPrefix, globals.PluginHostSetPreviousPrefix) {
|
||||
badFields[globals.HostSourceIdsField] = fmt.Sprintf("Incorrectly formatted host source identifier %q.", id)
|
||||
break
|
||||
}
|
||||
@@ -1762,7 +1761,7 @@ func validateRemoveHostSourcesRequest(req *pbs.RemoveTargetHostSourcesRequest) e
|
||||
badFields[globals.HostSourceIdsField] = "Must be non-empty."
|
||||
}
|
||||
for _, id := range req.GetHostSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(id), static.HostSetPrefix, plugin.HostSetPrefix, plugin.PreviousHostSetPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(id), globals.StaticHostSetPrefix, globals.PluginHostSetPrefix, globals.PluginHostSetPreviousPrefix) {
|
||||
badFields[globals.HostSourceIdsField] = fmt.Sprintf("Incorrectly formatted host source identifier %q.", id)
|
||||
break
|
||||
}
|
||||
@@ -1788,33 +1787,33 @@ func validateAddCredentialSourcesRequest(req *pbs.AddTargetCredentialSourcesRequ
|
||||
// TODO: Application Credentials are deprecated, remove when field removed.
|
||||
for _, cl := range req.GetApplicationCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.ApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, cl := range req.GetBrokeredCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, cl := range req.GetInjectedApplicationCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
vault.SSHCertificateCredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.VaultSshCertificateCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix) {
|
||||
badFields[globals.InjectedApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
@@ -1836,33 +1835,33 @@ func validateSetCredentialSourcesRequest(req *pbs.SetTargetCredentialSourcesRequ
|
||||
// TODO: Application Credentials are deprecated, remove when field removed.
|
||||
for _, cl := range req.GetApplicationCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.ApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, cl := range req.GetBrokeredCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, cl := range req.GetInjectedApplicationCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
vault.SSHCertificateCredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.VaultSshCertificateCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix) {
|
||||
badFields[globals.InjectedApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
@@ -1888,34 +1887,34 @@ func validateRemoveCredentialSourcesRequest(req *pbs.RemoveTargetCredentialSourc
|
||||
// TODO: Application Credentials are deprecated, remove when field removed.
|
||||
for _, cl := range req.GetApplicationCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.ApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, cl := range req.GetBrokeredCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.BrokeredCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, cl := range req.GetInjectedApplicationCredentialSourceIds() {
|
||||
if !handlers.ValidId(handlers.Id(cl),
|
||||
vault.CredentialLibraryPrefix,
|
||||
vault.SSHCertificateCredentialLibraryPrefix,
|
||||
credential.UsernamePasswordCredentialPrefix,
|
||||
credential.PreviousUsernamePasswordCredentialPrefix,
|
||||
credential.SshPrivateKeyCredentialPrefix,
|
||||
credential.JsonCredentialPrefix) {
|
||||
globals.VaultCredentialLibraryPrefix,
|
||||
globals.VaultSshCertificateCredentialLibraryPrefix,
|
||||
globals.UsernamePasswordCredentialPrefix,
|
||||
globals.UsernamePasswordCredentialPreviousPrefix,
|
||||
globals.SshPrivateKeyCredentialPrefix,
|
||||
globals.JsonCredentialPrefix) {
|
||||
badFields[globals.InjectedApplicationCredentialSourceIdsField] = fmt.Sprintf("Incorrectly formatted credential source identifier %q.", cl)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existing Target",
|
||||
req: &pbs.GetTargetRequest{Id: tcp.TargetPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetTargetRequest{Id: globals.TcpTargetPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -211,7 +211,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetTargetRequest{Id: tcp.TargetPrefix + "_1 23456789"},
|
||||
req: &pbs.GetTargetRequest{Id: globals.TcpTargetPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -459,7 +459,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Delete Not Existing Target",
|
||||
scopeId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteTargetRequest{
|
||||
Id: tcp.TargetPrefix + "_doesntexis",
|
||||
Id: globals.TcpTargetPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -467,7 +467,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Bad target id formatting",
|
||||
scopeId: proj.GetPublicId(),
|
||||
req: &pbs.DeleteTargetRequest{
|
||||
Id: tcp.TargetPrefix + "_bad_format",
|
||||
Id: globals.TcpTargetPrefix + "_bad_format",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -591,7 +591,7 @@ func TestCreate(t *testing.T) {
|
||||
EgressWorkerFilter: wrapperspb.String(`type == "bar"`),
|
||||
}},
|
||||
res: &pbs.CreateTargetResponse{
|
||||
Uri: fmt.Sprintf("targets/%s_", tcp.TargetPrefix),
|
||||
Uri: fmt.Sprintf("targets/%s_", globals.TcpTargetPrefix),
|
||||
Item: &pb.Target{
|
||||
ScopeId: proj.GetPublicId(),
|
||||
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
|
||||
@@ -755,7 +755,7 @@ func TestCreate(t *testing.T) {
|
||||
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.GetUri())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), tcp.TargetPrefix), got.GetItem().GetId())
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.TcpTargetPrefix), got.GetItem().GetId())
|
||||
|
||||
// Clear all values which are hard to compare against.
|
||||
got.Uri, tc.res.Uri = "", ""
|
||||
@@ -1093,7 +1093,7 @@ func TestUpdate(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Target",
|
||||
req: &pbs.UpdateTargetRequest{
|
||||
Id: tcp.TargetPrefix + "_DoesntExis",
|
||||
Id: globals.TcpTargetPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/auth/oidc"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/auth"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common/scopeids"
|
||||
@@ -17,7 +16,6 @@ import (
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/iam/store"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/perms"
|
||||
"github.com/hashicorp/boundary/internal/requests"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
@@ -668,7 +666,7 @@ func toProto(ctx context.Context, in *iam.User, accts []string, opt ...handlers.
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetUserRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, iam.UserPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.UserPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(req *pbs.CreateUserRequest) error {
|
||||
@@ -683,11 +681,11 @@ func validateCreateRequest(req *pbs.CreateUserRequest) error {
|
||||
}
|
||||
|
||||
func validateUpdateRequest(req *pbs.UpdateUserRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), handlers.NoopValidatorFn, iam.UserPrefix)
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), handlers.NoopValidatorFn, globals.UserPrefix)
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteUserRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, iam.UserPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.UserPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListUsersRequest) error {
|
||||
@@ -707,7 +705,7 @@ func validateListRequest(req *pbs.ListUsersRequest) error {
|
||||
|
||||
func validateAddUserAccountsRequest(req *pbs.AddUserAccountsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.UserPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.UserPrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -719,9 +717,9 @@ func validateAddUserAccountsRequest(req *pbs.AddUserAccountsRequest) error {
|
||||
for _, a := range req.GetAccountIds() {
|
||||
// TODO: Increase the type of auth accounts that can be added to a user.
|
||||
if !handlers.ValidId(handlers.Id(a),
|
||||
intglobals.OldPasswordAccountPrefix,
|
||||
intglobals.NewPasswordAccountPrefix,
|
||||
oidc.AccountPrefix,
|
||||
globals.PasswordAccountPreviousPrefix,
|
||||
globals.PasswordAccountPrefix,
|
||||
globals.OidcAccountPrefix,
|
||||
) {
|
||||
badFields["account_ids"] = "Values must be valid account ids."
|
||||
break
|
||||
@@ -735,7 +733,7 @@ func validateAddUserAccountsRequest(req *pbs.AddUserAccountsRequest) error {
|
||||
|
||||
func validateSetUserAccountsRequest(req *pbs.SetUserAccountsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.UserPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.UserPrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -744,9 +742,9 @@ func validateSetUserAccountsRequest(req *pbs.SetUserAccountsRequest) error {
|
||||
for _, a := range req.GetAccountIds() {
|
||||
// TODO: Increase the type of auth accounts that can be added to a user.
|
||||
if !handlers.ValidId(handlers.Id(a),
|
||||
intglobals.OldPasswordAccountPrefix,
|
||||
intglobals.NewPasswordAccountPrefix,
|
||||
oidc.AccountPrefix,
|
||||
globals.PasswordAccountPreviousPrefix,
|
||||
globals.PasswordAccountPrefix,
|
||||
globals.OidcAccountPrefix,
|
||||
) {
|
||||
badFields["account_ids"] = "Values must be valid account ids."
|
||||
break
|
||||
@@ -760,7 +758,7 @@ func validateSetUserAccountsRequest(req *pbs.SetUserAccountsRequest) error {
|
||||
|
||||
func validateRemoveUserAccountsRequest(req *pbs.RemoveUserAccountsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), iam.UserPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.UserPrefix) {
|
||||
badFields["id"] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -772,9 +770,9 @@ func validateRemoveUserAccountsRequest(req *pbs.RemoveUserAccountsRequest) error
|
||||
for _, a := range req.GetAccountIds() {
|
||||
// TODO: Increase the type of auth accounts that can be added to a user.
|
||||
if !handlers.ValidId(handlers.Id(a),
|
||||
intglobals.OldPasswordAccountPrefix,
|
||||
intglobals.NewPasswordAccountPrefix,
|
||||
oidc.AccountPrefix,
|
||||
globals.PasswordAccountPreviousPrefix,
|
||||
globals.PasswordAccountPrefix,
|
||||
globals.OidcAccountPrefix,
|
||||
) {
|
||||
badFields["account_ids"] = "Values must be valid account ids."
|
||||
break
|
||||
|
||||
@@ -120,7 +120,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non existant User",
|
||||
req: &pbs.GetUserRequest{Id: iam.UserPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetUserRequest{Id: globals.UserPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -132,7 +132,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "space in id",
|
||||
req: &pbs.GetUserRequest{Id: iam.UserPrefix + "_1 23456789"},
|
||||
req: &pbs.GetUserRequest{Id: globals.UserPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -349,7 +349,7 @@ func TestDelete(t *testing.T) {
|
||||
{
|
||||
name: "Delete bad user id",
|
||||
req: &pbs.DeleteUserRequest{
|
||||
Id: iam.UserPrefix + "_doesntexis",
|
||||
Id: globals.UserPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -409,7 +409,7 @@ func TestCreate(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
}},
|
||||
res: &pbs.CreateUserResponse{
|
||||
Uri: fmt.Sprintf("users/%s_", iam.UserPrefix),
|
||||
Uri: fmt.Sprintf("users/%s_", globals.UserPrefix),
|
||||
Item: &pb.User{
|
||||
ScopeId: defaultUser.GetScopeId(),
|
||||
Scope: &scopes.ScopeInfo{Id: defaultUser.GetScopeId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
|
||||
@@ -428,7 +428,7 @@ func TestCreate(t *testing.T) {
|
||||
Description: &wrapperspb.StringValue{Value: "desc"},
|
||||
}},
|
||||
res: &pbs.CreateUserResponse{
|
||||
Uri: fmt.Sprintf("users/%s_", iam.UserPrefix),
|
||||
Uri: fmt.Sprintf("users/%s_", globals.UserPrefix),
|
||||
Item: &pb.User{
|
||||
ScopeId: scope.Global.String(),
|
||||
Scope: &scopes.ScopeInfo{Id: scope.Global.String(), Type: scope.Global.String(), Name: scope.Global.String(), Description: "Global Scope"},
|
||||
@@ -443,7 +443,7 @@ func TestCreate(t *testing.T) {
|
||||
name: "Can't specify Id",
|
||||
req: &pbs.CreateUserRequest{Item: &pb.User{
|
||||
ScopeId: defaultUser.GetScopeId(),
|
||||
Id: iam.UserPrefix + "_notallowed",
|
||||
Id: globals.UserPrefix + "_notallowed",
|
||||
}},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
@@ -480,7 +480,7 @@ func TestCreate(t *testing.T) {
|
||||
}
|
||||
if got != nil {
|
||||
assert.Contains(got.GetUri(), tc.res.Uri)
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), iam.UserPrefix+"_"))
|
||||
assert.True(strings.HasPrefix(got.GetItem().GetId(), globals.UserPrefix+"_"))
|
||||
gotCreateTime := got.GetItem().GetCreatedTime().AsTime()
|
||||
gotUpdateTime := got.GetItem().GetUpdatedTime().AsTime()
|
||||
// Verify it is a user created after the test setup's default user
|
||||
@@ -672,7 +672,7 @@ func TestUpdate(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing User",
|
||||
req: &pbs.UpdateUserRequest{
|
||||
Id: iam.UserPrefix + "_DoesntExis",
|
||||
Id: globals.UserPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
@@ -691,7 +691,7 @@ func TestUpdate(t *testing.T) {
|
||||
Paths: []string{"id"},
|
||||
},
|
||||
Item: &pb.User{
|
||||
Id: iam.UserPrefix + "_somethinge",
|
||||
Id: globals.UserPrefix + "_somethinge",
|
||||
Name: &wrapperspb.StringValue{Value: "new"},
|
||||
Description: &wrapperspb.StringValue{Value: "new desc"},
|
||||
},
|
||||
|
||||
@@ -880,7 +880,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, server.WorkerPrefix)
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, globals.WorkerPrefix)
|
||||
}
|
||||
|
||||
func validateListRequest(req *pbs.ListWorkersRequest) error {
|
||||
@@ -898,7 +898,7 @@ func validateListRequest(req *pbs.ListWorkersRequest) error {
|
||||
}
|
||||
|
||||
func validateDeleteRequest(req *pbs.DeleteWorkerRequest) error {
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, server.WorkerPrefix)
|
||||
return handlers.ValidateDeleteRequest(handlers.NoopValidatorFn, req, globals.WorkerPrefix)
|
||||
}
|
||||
|
||||
func validateUpdateRequest(req *pbs.UpdateWorkerRequest) error {
|
||||
@@ -925,7 +925,7 @@ func validateUpdateRequest(req *pbs.UpdateWorkerRequest) error {
|
||||
badFields[globals.DescriptionField] = "Contains non-printable characters."
|
||||
}
|
||||
return badFields
|
||||
}, server.WorkerPrefix)
|
||||
}, globals.WorkerPrefix)
|
||||
}
|
||||
|
||||
func validateCreateRequest(item *pb.Worker, act action.Type) error {
|
||||
@@ -1001,7 +1001,7 @@ func validateStringForDb(str string) string {
|
||||
|
||||
func validateAddTagsRequest(req *pbs.AddWorkerTagsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), server.WorkerPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.WorkerPrefix) {
|
||||
badFields[globals.IdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1038,7 +1038,7 @@ func validateAddTagsRequest(req *pbs.AddWorkerTagsRequest) error {
|
||||
|
||||
func validateSetTagsRequest(req *pbs.SetWorkerTagsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), server.WorkerPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.WorkerPrefix) {
|
||||
badFields[globals.IdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
@@ -1072,7 +1072,7 @@ func validateSetTagsRequest(req *pbs.SetWorkerTagsRequest) error {
|
||||
|
||||
func validateRemoveTagsRequest(req *pbs.RemoveWorkerTagsRequest) error {
|
||||
badFields := map[string]string{}
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), server.WorkerPrefix) {
|
||||
if !handlers.ValidId(handlers.Id(req.GetId()), globals.WorkerPrefix) {
|
||||
badFields[globals.IdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
if req.GetVersion() == 0 {
|
||||
|
||||
@@ -202,7 +202,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Get a non-existent Worker",
|
||||
req: &pbs.GetWorkerRequest{Id: server.WorkerPrefix + "_DoesntExis"},
|
||||
req: &pbs.GetWorkerRequest{Id: globals.WorkerPrefix + "_DoesntExis"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -214,7 +214,7 @@ func TestGet(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Space in id",
|
||||
req: &pbs.GetWorkerRequest{Id: server.WorkerPrefix + "_1 23456789"},
|
||||
req: &pbs.GetWorkerRequest{Id: globals.WorkerPrefix + "_1 23456789"},
|
||||
res: nil,
|
||||
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
|
||||
},
|
||||
@@ -430,7 +430,7 @@ func TestDelete(t *testing.T) {
|
||||
name: "Delete bad worker id",
|
||||
scopeId: w.GetScopeId(),
|
||||
req: &pbs.DeleteWorkerRequest{
|
||||
Id: server.WorkerPrefix + "_doesntexis",
|
||||
Id: globals.WorkerPrefix + "_doesntexis",
|
||||
},
|
||||
err: handlers.ApiErrorWithCode(codes.NotFound),
|
||||
},
|
||||
@@ -719,7 +719,7 @@ func TestUpdate(t *testing.T) {
|
||||
{
|
||||
name: "Update a Non Existing Worker",
|
||||
req: &pbs.UpdateWorkerRequest{
|
||||
Id: server.WorkerPrefix + "_DoesntExis",
|
||||
Id: globals.WorkerPrefix + "_DoesntExis",
|
||||
UpdateMask: &field_mask.FieldMask{
|
||||
Paths: []string{"description"},
|
||||
},
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/hashicorp/boundary/api"
|
||||
"github.com/hashicorp/boundary/api/authmethods"
|
||||
"github.com/hashicorp/boundary/api/authtokens"
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/authtoken"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
@@ -29,7 +30,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/gen/testing/interceptor"
|
||||
"github.com/hashicorp/boundary/internal/host/plugin"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/intglobals"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
@@ -54,9 +54,9 @@ const (
|
||||
DefaultTestUnprivilegedLoginName = "user"
|
||||
DefaultTestPassword = "passpass"
|
||||
DefaultTestUserId = "u_1234567890"
|
||||
DefaultTestPasswordAccountId = intglobals.NewPasswordAccountPrefix + "_1234567890"
|
||||
DefaultTestPasswordAccountId = globals.PasswordAccountPrefix + "_1234567890"
|
||||
DefaultTestOidcAccountId = "acctoidc_1234567890"
|
||||
DefaultTestUnprivilegedPasswordAccountId = intglobals.NewPasswordAccountPrefix + "_0987654321"
|
||||
DefaultTestUnprivilegedPasswordAccountId = globals.PasswordAccountPrefix + "_0987654321"
|
||||
DefaultTestUnprivilegedOidcAccountId = "acctoidc_0987654321"
|
||||
DefaultTestPluginId = "pl_1234567890"
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user