Use the correct collection actions response when updating host catalogs. (#1718)
This commit is contained in:
2 files changed
+14
-5
No files matched your search
@@ -354,13 +354,21 @@ func (s Service) UpdateHostCatalog(ctx context.Context, req *pbs.UpdateHostCatal
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hc.GetPublicId(), IdActions).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[static.Subtype], authResults.Scope.Id, hc.GetPublicId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var subtype subtypes.Subtype
|
||||
switch hc.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = static.Subtype
|
||||
case *plugin.HostCatalog:
|
||||
subtype = plugin.Subtype
|
||||
}
|
||||
if subtype != "" {
|
||||
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, hc.GetPublicId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedCollectionActions(collectionActions))
|
||||
}
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedCollectionActions(collectionActions))
|
||||
}
|
||||
|
||||
item, err := toProto(ctx, hc, outputOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -1448,6 +1448,7 @@ func TestUpdate_Plugin(t *testing.T) {
|
||||
check: func(t *testing.T, in *pb.HostCatalog) {
|
||||
assert.Equal(t, "new", in.Name.GetValue())
|
||||
assert.Equal(t, "desc", in.Description.GetValue())
|
||||
assert.Equal(t, authorizedCollectionActions[plugin.Subtype], in.GetAuthorizedCollectionActions())
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user