Post-merge some issues were discovered with the ways typing is used for
proto reflection. This will be reworked without moving the subtypes
around.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2023-11-02 16:03:47 -04:00
1 parent 4239f6d4a9
commit a9e372930d
84 files changed
+1900 -1557

No files matched your search

@@ -44,14 +44,14 @@ var (
// IdActions contains the set of actions that can be performed on
// individual resources
IdActions = map[globals.Subtype]action.ActionSet{
globals.OidcSubtype: {
IdActions = map[subtypes.Subtype]action.ActionSet{
oidc.Subtype: {
action.NoOp,
action.Read,
action.Update,
action.Delete,
},
globals.LdapSubtype: {
ldap.Subtype: {
action.NoOp,
action.Read,
action.Update,
@@ -310,7 +310,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.ManagedGroup,
var out auth.ManagedGroup
var memberIds []string
switch subtypes.SubtypeFromId(domain, id) {
case globals.OidcSubtype:
case oidc.Subtype:
repo, err := s.oidcRepoFn()
if err != nil {
return nil, nil, err
@@ -333,7 +333,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (auth.ManagedGroup,
}
}
out = mg
case globals.LdapSubtype:
case ldap.Subtype:
repo, err := s.ldapRepoFn()
if err != nil {
return nil, nil, err
@@ -433,7 +433,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
}
var out auth.ManagedGroup
switch subtypes.SubtypeFromId(domain, am.GetPublicId()) {
case globals.OidcSubtype:
case oidc.Subtype:
am, err := s.createOidcInRepo(ctx, am, item)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
@@ -442,7 +442,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create managed group but no error returned from repository.")
}
out = am
case globals.LdapSubtype:
case ldap.Subtype:
am, err := s.createLdapInRepo(ctx, am, item)
if err != nil {
return nil, errors.Wrap(ctx, err, op)
@@ -535,7 +535,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string,
const op = "managed_groups.(Service).updateInRepo"
var out auth.ManagedGroup
switch subtypes.SubtypeFromId(domain, req.GetId()) {
case globals.OidcSubtype:
case oidc.Subtype:
mg, err := s.updateOidcInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
if err != nil {
return nil, errors.Wrap(ctx, err, op)
@@ -544,7 +544,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string,
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to update managed group but no error returned from repository.")
}
out = mg
case globals.LdapSubtype:
case ldap.Subtype:
mg, err := s.updateLdapInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
if err != nil {
return nil, errors.Wrap(ctx, err, op)
@@ -562,13 +562,13 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
var rows int
var err error
switch subtypes.SubtypeFromId(domain, id) {
case globals.OidcSubtype:
case oidc.Subtype:
repo, iErr := s.oidcRepoFn()
if iErr != nil {
return false, iErr
}
rows, err = repo.DeleteManagedGroup(ctx, scopeId, id)
case globals.LdapSubtype:
case ldap.Subtype:
repo, iErr := s.ldapRepoFn()
if iErr != nil {
return false, iErr
@@ -589,7 +589,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
var outUl []auth.ManagedGroup
switch subtypes.SubtypeFromId(domain, authMethodId) {
case globals.OidcSubtype:
case oidc.Subtype:
oidcRepo, err := s.oidcRepoFn()
if err != nil {
return nil, errors.Wrap(ctx, err, op)
@@ -601,7 +601,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
for _, a := range oidcl {
outUl = append(outUl, a)
}
case globals.LdapSubtype:
case ldap.Subtype:
ldapRepo, err := s.ldapRepoFn()
if err != nil {
return nil, errors.Wrap(ctx, err, op)
@@ -638,7 +638,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
parentId = id
default:
switch subtypes.SubtypeFromId(domain, id) {
case globals.OidcSubtype:
case oidc.Subtype:
grp, err := oidcRepo.LookupManagedGroup(ctx, id)
if err != nil {
res.Error = err
@@ -649,7 +649,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
return nil, res
}
parentId = grp.GetAuthMethodId()
case globals.LdapSubtype:
case ldap.Subtype:
grp, err := ldapRepo.LookupManagedGroup(ctx, id)
if err != nil {
res.Error = err
@@ -669,7 +669,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
var authMeth auth.AuthMethod
switch subtypes.SubtypeFromId(domain, parentId) {
case globals.OidcSubtype:
case oidc.Subtype:
am, err := oidcRepo.LookupAuthMethod(ctx, parentId)
if err != nil {
res.Error = err
@@ -681,7 +681,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
}
authMeth = am
opts = append(opts, requestauth.WithScopeId(am.GetScopeId()))
case globals.LdapSubtype:
case ldap.Subtype:
am, err := ldapRepo.LookupAuthMethod(ctx, parentId)
if err != nil {
res.Error = err
@@ -742,7 +742,7 @@ func toProto(ctx context.Context, in auth.ManagedGroup, opt ...handlers.Option)
switch i := in.(type) {
case *oidc.ManagedGroup:
if outputFields.Has(globals.TypeField) {
out.Type = globals.OidcSubtype.String()
out.Type = oidc.Subtype.String()
}
if !outputFields.Has(globals.AttributesField) {
break
@@ -755,7 +755,7 @@ func toProto(ctx context.Context, in auth.ManagedGroup, opt ...handlers.Option)
}
case *ldap.ManagedGroup:
if outputFields.Has(globals.TypeField) {
out.Type = globals.LdapSubtype.String()
out.Type = ldap.Subtype.String()
}
if !outputFields.Has(globals.AttributesField) {
break
@@ -800,8 +800,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateManagedGroupReque
badFields[globals.AuthMethodIdField] = "This field is required."
}
switch subtypes.SubtypeFromId(domain, req.GetItem().GetAuthMethodId()) {
case globals.OidcSubtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.OidcSubtype.String() {
case oidc.Subtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
}
attrs := req.GetItem().GetOidcManagedGroupAttributes()
@@ -816,8 +816,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateManagedGroupReque
}
}
}
case globals.LdapSubtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.LdapSubtype.String() {
case ldap.Subtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != ldap.Subtype.String() {
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
}
attrs := req.GetItem().GetLdapManagedGroupAttributes()
@@ -843,8 +843,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateManagedGroupReque
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
badFields := map[string]string{}
switch subtypes.SubtypeFromId(domain, req.GetId()) {
case globals.OidcSubtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.OidcSubtype.String() {
case oidc.Subtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
badFields[globals.TypeField] = "Cannot modify the resource type."
}
attrs := req.GetItem().GetOidcManagedGroupAttributes()
@@ -862,8 +862,8 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateManagedGroupReque
}
}
}
case globals.LdapSubtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != globals.LdapSubtype.String() {
case ldap.Subtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != ldap.Subtype.String() {
badFields[globals.TypeField] = "Cannot modify the resource type."
}
attrs := req.GetItem().GetLdapManagedGroupAttributes()
@@ -16,6 +16,7 @@ import (
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/auth/ldap"
"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/handlers"
@@ -293,7 +294,7 @@ func TestListOidc(t *testing.T) {
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -314,7 +315,7 @@ func TestListOidc(t *testing.T) {
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -446,7 +447,7 @@ func TestListLdap(t *testing.T) {
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: testGroups,
@@ -467,7 +468,7 @@ func TestListLdap(t *testing.T) {
UpdatedTime: mg.GetUpdateTime().GetTimestamp(),
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: testGroups,
@@ -751,7 +752,7 @@ func TestCreateOidc(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "name"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -767,7 +768,7 @@ func TestCreateOidc(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "desc"},
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -795,7 +796,7 @@ func TestCreateOidc(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -810,7 +811,7 @@ func TestCreateOidc(t *testing.T) {
req: &pbs.CreateManagedGroupRequest{
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
Type: globals.PasswordSubtype.String(),
Type: password.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -827,7 +828,7 @@ func TestCreateOidc(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
Id: globals.OidcManagedGroupPrefix + "_notallowed",
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -844,7 +845,7 @@ func TestCreateOidc(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
CreatedTime: timestamppb.Now(),
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -861,7 +862,7 @@ func TestCreateOidc(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
UpdatedTime: timestamppb.Now(),
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: oidc.TestFakeManagedGroupFilter,
@@ -878,7 +879,7 @@ func TestCreateOidc(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
UpdatedTime: timestamppb.Now(),
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
Filter: "foobar",
@@ -951,7 +952,7 @@ func TestCreateLdap(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "name"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{"admin", "users"},
@@ -967,7 +968,7 @@ func TestCreateLdap(t *testing.T) {
Description: &wrapperspb.StringValue{Value: "desc"},
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{"admin", "users"},
@@ -995,7 +996,7 @@ func TestCreateLdap(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Scope: &scopepb.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String(), ParentScopeId: scope.Global.String()},
Version: 1,
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{"admin", "users"},
@@ -1010,7 +1011,7 @@ func TestCreateLdap(t *testing.T) {
req: &pbs.CreateManagedGroupRequest{
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
Type: globals.PasswordSubtype.String(),
Type: password.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{"admin", "users"},
@@ -1028,7 +1029,7 @@ func TestCreateLdap(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
Id: globals.LdapManagedGroupPrefix + "_notallowed",
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{"admin", "users"},
@@ -1046,7 +1047,7 @@ func TestCreateLdap(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
CreatedTime: timestamppb.Now(),
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{"admin", "users"},
@@ -1064,7 +1065,7 @@ func TestCreateLdap(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
UpdatedTime: timestamppb.Now(),
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{"admin", "users"},
@@ -1081,7 +1082,7 @@ func TestCreateLdap(t *testing.T) {
req: &pbs.CreateManagedGroupRequest{
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
GroupNames: []string{},
@@ -1196,7 +1197,7 @@ func TestUpdateOidc(t *testing.T) {
Item: &pb.ManagedGroup{
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
},
},
res: &pbs.UpdateManagedGroupResponse{
@@ -1204,7 +1205,7 @@ func TestUpdateOidc(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: oidcAuthorizedActions,
@@ -1220,7 +1221,7 @@ func TestUpdateOidc(t *testing.T) {
Item: &pb.ManagedGroup{
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
},
},
res: &pbs.UpdateManagedGroupResponse{
@@ -1228,7 +1229,7 @@ func TestUpdateOidc(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: oidcAuthorizedActions,
@@ -1298,7 +1299,7 @@ func TestUpdateOidc(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
Description: &wrapperspb.StringValue{Value: "default"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: oidcAuthorizedActions,
@@ -1322,7 +1323,7 @@ func TestUpdateOidc(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "updated"},
Description: &wrapperspb.StringValue{Value: "default"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: oidcAuthorizedActions,
@@ -1346,7 +1347,7 @@ func TestUpdateOidc(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "default"},
Description: &wrapperspb.StringValue{Value: "notignored"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: oidcAuthorizedActions,
@@ -1448,7 +1449,7 @@ func TestUpdateOidc(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "default"},
Description: &wrapperspb.StringValue{Value: "default"},
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
Attrs: modifiedAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: oidcAuthorizedActions,
@@ -1581,7 +1582,7 @@ func TestUpdateLdap(t *testing.T) {
Item: &pb.ManagedGroup{
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
},
},
res: &pbs.UpdateManagedGroupResponse{
@@ -1589,7 +1590,7 @@ func TestUpdateLdap(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: ldapAuthorizedActions,
@@ -1605,7 +1606,7 @@ func TestUpdateLdap(t *testing.T) {
Item: &pb.ManagedGroup{
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
},
},
res: &pbs.UpdateManagedGroupResponse{
@@ -1613,7 +1614,7 @@ func TestUpdateLdap(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "new"},
Description: &wrapperspb.StringValue{Value: "desc"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: ldapAuthorizedActions,
@@ -1684,7 +1685,7 @@ func TestUpdateLdap(t *testing.T) {
Item: &pb.ManagedGroup{
AuthMethodId: am.GetPublicId(),
Description: &wrapperspb.StringValue{Value: "default"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: ldapAuthorizedActions,
@@ -1708,7 +1709,7 @@ func TestUpdateLdap(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "updated"},
Description: &wrapperspb.StringValue{Value: "default"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: ldapAuthorizedActions,
@@ -1732,7 +1733,7 @@ func TestUpdateLdap(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "default"},
Description: &wrapperspb.StringValue{Value: "notignored"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: defaultAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: ldapAuthorizedActions,
@@ -1840,7 +1841,7 @@ func TestUpdateLdap(t *testing.T) {
AuthMethodId: am.GetPublicId(),
Name: &wrapperspb.StringValue{Value: "default"},
Description: &wrapperspb.StringValue{Value: "default"},
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
Attrs: modifiedAttributes,
Scope: defaultScopeInfo,
AuthorizedActions: ldapAuthorizedActions,
@@ -10,6 +10,9 @@ import (
"testing"
"github.com/hashicorp/boundary/globals"
"github.com/hashicorp/boundary/internal/auth/ldap"
"github.com/hashicorp/boundary/internal/auth/oidc"
"github.com/hashicorp/boundary/internal/auth/password"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/managedgroups"
"github.com/stretchr/testify/assert"
@@ -46,7 +49,7 @@ func TestValidateCreateRequest(t *testing.T) {
{
name: "missing oidc attributes",
item: &pb.ManagedGroup{
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
Attrs: nil,
},
@@ -55,7 +58,7 @@ func TestValidateCreateRequest(t *testing.T) {
{
name: "bad oidc attributes",
item: &pb.ManagedGroup{
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
@@ -68,7 +71,7 @@ func TestValidateCreateRequest(t *testing.T) {
{
name: "no oidc errors",
item: &pb.ManagedGroup{
Type: globals.OidcSubtype.String(),
Type: oidc.Subtype.String(),
AuthMethodId: globals.OidcAuthMethodPrefix + "_1234567890",
Attrs: &pb.ManagedGroup_OidcManagedGroupAttributes{
OidcManagedGroupAttributes: &pb.OidcManagedGroupAttributes{
@@ -88,7 +91,7 @@ func TestValidateCreateRequest(t *testing.T) {
{
name: "missing ldap attributes",
item: &pb.ManagedGroup{
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
Attrs: nil,
},
@@ -97,7 +100,7 @@ func TestValidateCreateRequest(t *testing.T) {
{
name: "bad ldap attributes",
item: &pb.ManagedGroup{
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
@@ -110,7 +113,7 @@ func TestValidateCreateRequest(t *testing.T) {
{
name: "no ldap errors",
item: &pb.ManagedGroup{
Type: globals.LdapSubtype.String(),
Type: ldap.Subtype.String(),
AuthMethodId: globals.LdapAuthMethodPrefix + "_1234567890",
Attrs: &pb.ManagedGroup_LdapManagedGroupAttributes{
LdapManagedGroupAttributes: &pb.LdapManagedGroupAttributes{
@@ -148,7 +151,7 @@ func TestValidateUpdateRequest(t *testing.T) {
req: &pbs.UpdateManagedGroupRequest{
Id: globals.OidcManagedGroupPrefix + "_1234567890",
Item: &pb.ManagedGroup{
Type: globals.PasswordSubtype.String(),
Type: password.Subtype.String(),
},
},
errContains: fieldError(globals.TypeField, "Cannot modify the resource type."),
@@ -173,7 +176,7 @@ func TestValidateUpdateRequest(t *testing.T) {
req: &pbs.UpdateManagedGroupRequest{
Id: globals.LdapManagedGroupPrefix + "_1234567890",
Item: &pb.ManagedGroup{
Type: globals.PasswordSubtype.String(),
Type: password.Subtype.String(),
},
},
errContains: fieldError(globals.TypeField, "Cannot modify the resource type."),