From e3012afb4fb370eb47af5416ce91da81ac21c96a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 3 Aug 2021 14:16:02 -0400 Subject: [PATCH] Add primary auth method ID to default output fields, fix display bug (#1441) --- globals/fields.go | 2 +- internal/cmd/commands/scopescmd/funcs.go | 2 +- internal/perms/output_fields.go | 1 + internal/perms/output_fields_test.go | 1 + internal/servers/controller/handlers/scopes/scope_service.go | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/globals/fields.go b/globals/fields.go index 45a1224c4a..692c8ddb93 100644 --- a/globals/fields.go +++ b/globals/fields.go @@ -30,7 +30,7 @@ const ( GrantScopeIdField = "grant_scope_id" GrantsField = "grants" GrantStringsField = "grant_strings" - PrimaryAuthMethodId = "primary_auth_method_id" + PrimaryAuthMethodIdField = "primary_auth_method_id" TargetIdField = "target_id" HostIdField = "host_id" HostSetIdField = "host_set_id" diff --git a/internal/cmd/commands/scopescmd/funcs.go b/internal/cmd/commands/scopescmd/funcs.go index b26c8a28d8..3735dd332c 100644 --- a/internal/cmd/commands/scopescmd/funcs.go +++ b/internal/cmd/commands/scopescmd/funcs.go @@ -150,7 +150,7 @@ func printItemTable(result api.GenericResult) string { nonAttributeMap["Description"] = item.Description } if item.PrimaryAuthMethodId != "" { - nonAttributeMap[flagPrimaryAuthMethodIdName] = item.PrimaryAuthMethodId + nonAttributeMap["Primary Auth Method ID"] = item.PrimaryAuthMethodId } maxLength := base.MaxAttributesLength(nonAttributeMap, nil, nil) diff --git a/internal/perms/output_fields.go b/internal/perms/output_fields.go index 31871cb443..9f6a497e11 100644 --- a/internal/perms/output_fields.go +++ b/internal/perms/output_fields.go @@ -75,6 +75,7 @@ func (o OutputFieldsMap) SelfOrDefaults(userId string) OutputFieldsMap { globals.DescriptionField: true, globals.TypeField: true, globals.IsPrimaryField: true, + globals.PrimaryAuthMethodIdField: true, globals.AuthorizedActionsField: true, globals.AuthorizedCollectionActionsField: true, } diff --git a/internal/perms/output_fields_test.go b/internal/perms/output_fields_test.go index ed7d9297e5..0791fa4d69 100644 --- a/internal/perms/output_fields_test.go +++ b/internal/perms/output_fields_test.go @@ -248,6 +248,7 @@ func Test_ACLSelfOrDefault(t *testing.T) { globals.DescriptionField: true, globals.TypeField: true, globals.IsPrimaryField: true, + globals.PrimaryAuthMethodIdField: true, globals.AuthorizedActionsField: true, globals.AuthorizedCollectionActionsField: true, }, diff --git a/internal/servers/controller/handlers/scopes/scope_service.go b/internal/servers/controller/handlers/scopes/scope_service.go index d1fce77149..f225d01d74 100644 --- a/internal/servers/controller/handlers/scopes/scope_service.go +++ b/internal/servers/controller/handlers/scopes/scope_service.go @@ -578,7 +578,7 @@ func ToProto(ctx context.Context, in *iam.Scope, opt ...handlers.Option) (*pb.Sc if outputFields.Has(globals.AuthorizedCollectionActionsField) { out.AuthorizedCollectionActions = opts.WithAuthorizedCollectionActions } - if outputFields.Has(globals.PrimaryAuthMethodId) && in.GetPrimaryAuthMethodId() != "" { + if outputFields.Has(globals.PrimaryAuthMethodIdField) && in.GetPrimaryAuthMethodId() != "" { out.PrimaryAuthMethodId = &wrapperspb.StringValue{Value: in.GetPrimaryAuthMethodId()} }