diff --git a/entry_role.go b/entry_role.go index c9feaa3..d89bba6 100644 --- a/entry_role.go +++ b/entry_role.go @@ -3,6 +3,7 @@ package gitlab import ( "context" "fmt" + "strings" "time" "github.com/hashicorp/vault/sdk/logical" @@ -35,7 +36,7 @@ func (e EntryRole) LogicalResponseData() map[string]any { "role_name": e.RoleName, "path": e.Path, "name": e.Name, - "scopes": e.Scopes, + "scopes": strings.Join(e.Scopes, ", "), "access_level": e.AccessLevel.String(), "ttl": int64(e.TTL / time.Second), "token_type": e.TokenType.String(), @@ -54,5 +55,4 @@ func getRole(ctx context.Context, name string, s logical.Storage) (role *EntryRo _ = entry.DecodeJSON(role) } return role, err - } diff --git a/path_role_test.go b/path_role_test.go index 269ea8d..7eba239 100644 --- a/path_role_test.go +++ b/path_role_test.go @@ -6,6 +6,7 @@ import ( "cmp" "fmt" "os" + "strings" "testing" "time" @@ -325,9 +326,9 @@ func TestPathRoles(t *testing.T) { "path": "user", "name": "Example user personal token", "token_type": token.TypePersonal.String(), - "scopes": []string{ + "scopes": strings.Join([]string{ "invalid_scope", - }, + }, ", "), }, }) require.Error(t, err) @@ -423,10 +424,10 @@ func TestPathRoles(t *testing.T) { "token_type": token.TypePersonal.String(), "ttl": int64((5 * 24 * time.Hour).Seconds()), "gitlab_revokes_token": false, - "scopes": []string{ + "scopes": strings.Join([]string{ token.ScopeApi.String(), token.ScopeReadRegistry.String(), - }, + }, ", "), } // create a role