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

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

No files matched your search

@@ -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"},
},