Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions SURFACE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ARG fizzy signup help 00 [command]
ARG fizzy skill help 00 [command]
ARG fizzy step help 00 [command]
ARG fizzy tag help 00 [command]
ARG fizzy token help 00 [command]
ARG fizzy upload help 00 [command]
ARG fizzy user help 00 [command]
ARG fizzy webhook help 00 [command]
Expand Down Expand Up @@ -194,6 +195,13 @@ CMD fizzy tag
CMD fizzy tag help
CMD fizzy tag list
CMD fizzy tag ls
CMD fizzy token
CMD fizzy token create
CMD fizzy token delete
CMD fizzy token help
CMD fizzy token list
CMD fizzy token ls
CMD fizzy token rm
CMD fizzy upload
CMD fizzy upload file
CMD fizzy upload help
Expand Down Expand Up @@ -2737,6 +2745,106 @@ FLAG fizzy tag ls --quiet type=bool
FLAG fizzy tag ls --styled type=bool
FLAG fizzy tag ls --token type=string
FLAG fizzy tag ls --verbose type=bool
FLAG fizzy token --agent type=bool
FLAG fizzy token --api-url type=string
FLAG fizzy token --count type=bool
FLAG fizzy token --help type=bool
FLAG fizzy token --ids-only type=bool
FLAG fizzy token --jq type=string
FLAG fizzy token --json type=bool
FLAG fizzy token --limit type=int
FLAG fizzy token --markdown type=bool
FLAG fizzy token --profile type=string
FLAG fizzy token --quiet type=bool
FLAG fizzy token --styled type=bool
FLAG fizzy token --token type=string
FLAG fizzy token --verbose type=bool
FLAG fizzy token create --agent type=bool
FLAG fizzy token create --api-url type=string
FLAG fizzy token create --count type=bool
FLAG fizzy token create --description type=string
FLAG fizzy token create --help type=bool
FLAG fizzy token create --ids-only type=bool
FLAG fizzy token create --jq type=string
FLAG fizzy token create --json type=bool
FLAG fizzy token create --limit type=int
FLAG fizzy token create --markdown type=bool
FLAG fizzy token create --permission type=string
FLAG fizzy token create --profile type=string
FLAG fizzy token create --quiet type=bool
FLAG fizzy token create --styled type=bool
FLAG fizzy token create --token type=string
FLAG fizzy token create --verbose type=bool
FLAG fizzy token delete --agent type=bool
FLAG fizzy token delete --api-url type=string
FLAG fizzy token delete --count type=bool
FLAG fizzy token delete --help type=bool
FLAG fizzy token delete --ids-only type=bool
FLAG fizzy token delete --jq type=string
FLAG fizzy token delete --json type=bool
FLAG fizzy token delete --limit type=int
FLAG fizzy token delete --markdown type=bool
FLAG fizzy token delete --profile type=string
FLAG fizzy token delete --quiet type=bool
FLAG fizzy token delete --styled type=bool
FLAG fizzy token delete --token type=string
FLAG fizzy token delete --verbose type=bool
FLAG fizzy token help --agent type=bool
FLAG fizzy token help --api-url type=string
FLAG fizzy token help --count type=bool
FLAG fizzy token help --help type=bool
FLAG fizzy token help --ids-only type=bool
FLAG fizzy token help --jq type=string
FLAG fizzy token help --json type=bool
FLAG fizzy token help --limit type=int
FLAG fizzy token help --markdown type=bool
FLAG fizzy token help --profile type=string
FLAG fizzy token help --quiet type=bool
FLAG fizzy token help --styled type=bool
FLAG fizzy token help --token type=string
FLAG fizzy token help --verbose type=bool
FLAG fizzy token list --agent type=bool
FLAG fizzy token list --api-url type=string
FLAG fizzy token list --count type=bool
FLAG fizzy token list --help type=bool
FLAG fizzy token list --ids-only type=bool
FLAG fizzy token list --jq type=string
FLAG fizzy token list --json type=bool
FLAG fizzy token list --limit type=int
FLAG fizzy token list --markdown type=bool
FLAG fizzy token list --profile type=string
FLAG fizzy token list --quiet type=bool
FLAG fizzy token list --styled type=bool
FLAG fizzy token list --token type=string
FLAG fizzy token list --verbose type=bool
FLAG fizzy token ls --agent type=bool
FLAG fizzy token ls --api-url type=string
FLAG fizzy token ls --count type=bool
FLAG fizzy token ls --help type=bool
FLAG fizzy token ls --ids-only type=bool
FLAG fizzy token ls --jq type=string
FLAG fizzy token ls --json type=bool
FLAG fizzy token ls --limit type=int
FLAG fizzy token ls --markdown type=bool
FLAG fizzy token ls --profile type=string
FLAG fizzy token ls --quiet type=bool
FLAG fizzy token ls --styled type=bool
FLAG fizzy token ls --token type=string
FLAG fizzy token ls --verbose type=bool
FLAG fizzy token rm --agent type=bool
FLAG fizzy token rm --api-url type=string
FLAG fizzy token rm --count type=bool
FLAG fizzy token rm --help type=bool
FLAG fizzy token rm --ids-only type=bool
FLAG fizzy token rm --jq type=string
FLAG fizzy token rm --json type=bool
FLAG fizzy token rm --limit type=int
FLAG fizzy token rm --markdown type=bool
FLAG fizzy token rm --profile type=string
FLAG fizzy token rm --quiet type=bool
FLAG fizzy token rm --styled type=bool
FLAG fizzy token rm --token type=string
FLAG fizzy token rm --verbose type=bool
FLAG fizzy upload --agent type=bool
FLAG fizzy upload --api-url type=string
FLAG fizzy upload --count type=bool
Expand Down Expand Up @@ -3385,6 +3493,13 @@ SUB fizzy tag
SUB fizzy tag help
SUB fizzy tag list
SUB fizzy tag ls
SUB fizzy token
SUB fizzy token create
SUB fizzy token delete
SUB fizzy token help
SUB fizzy token list
SUB fizzy token ls
SUB fizzy token rm
SUB fizzy upload
SUB fizzy upload file
SUB fizzy upload help
Expand Down
58 changes: 58 additions & 0 deletions e2e/cli_tests/token_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package clitests

import (
"strconv"
"testing"
"time"

"github.com/basecamp/fizzy-cli/e2e/harness"
)

func TestAccessTokenCRUD(t *testing.T) {
h := newHarness(t)
description := "CLI Test Token " + strconv.FormatInt(time.Now().UnixNano(), 10)

create := h.Run("token", "create", "--description", description, "--permission", "read")
assertOK(t, create)
tokenID := create.GetDataString("id")
if tokenID == "" {
t.Fatal("no token ID in create response")
}
deleted := false
t.Cleanup(func() {
if deleted {
return
}
cleanupDelete := newHarness(t).Run("token", "delete", tokenID)
if cleanupDelete.ExitCode != harness.ExitSuccess {
t.Errorf("cleanup failed deleting token %q: exit=%d stdout=%s stderr=%s", tokenID, cleanupDelete.ExitCode, cleanupDelete.Stdout, cleanupDelete.Stderr)
return
}
if !cleanupDelete.GetDataBool("deleted") {
t.Errorf("cleanup delete for token %q did not report deleted=true", tokenID)
}
})
if create.GetDataString("token") == "" {
t.Fatal("expected raw token value in create response")
}

list := h.Run("token", "list")
assertOK(t, list)
found := false
for _, item := range list.GetDataArray() {
if mapValueString(asMap(item), "id") == tokenID {
found = true
break
}
}
if !found {
t.Fatalf("expected token list to include %q", tokenID)
}

deleteResult := h.Run("token", "delete", tokenID)
assertOK(t, deleteResult)
deleted = true
if !deleteResult.GetDataBool("deleted") {
t.Fatal("expected deleted=true")
}
}
7 changes: 7 additions & 0 deletions internal/commands/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,11 @@ var (
{Header: "Created", Field: "created_at"},
{Header: "Updated", Field: "updated_at"},
}

tokenColumns = render.Columns{
{Header: "ID", Field: "id"},
{Header: "Description", Field: "description"},
{Header: "Permission", Field: "permission"},
{Header: "Created", Field: "created_at"},
}
)
2 changes: 1 addition & 1 deletion internal/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var commandCatalogTitles = map[string]string{
var commandCatalogGroups = map[string][]string{
"core": {"activity", "board", "card", "column", "comment", "search", "step"},
"collaboration": {"notification", "pin", "reaction", "tag", "user"},
"admin": {"auth", "account", "identity", "webhook", "upload", "migrate"},
"admin": {"auth", "account", "identity", "token", "webhook", "upload", "migrate"},
"utilities": {"setup", "signup", "completion", "doctor", "config", "skill", "commands", "version"},
}

Expand Down
19 changes: 19 additions & 0 deletions internal/commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ func TestCommandsFilterFindsActivity(t *testing.T) {
}
}

func TestCommandsFilterFindsToken(t *testing.T) {
mock := NewMockClient()
SetTestModeWithSDK(mock)
SetTestFormat(output.FormatStyled)
defer resetTest()

if err := commandsCmd.RunE(commandsCmd, []string{"token"}); err != nil {
t.Fatalf("unexpected error: %v", err)
}

raw := TestOutput()
if !strings.Contains(raw, "token") || !strings.Contains(raw, "create, delete, list") {
t.Fatalf("expected filtered catalog to include token actions, got:\n%s", raw)
}
if strings.Contains(raw, "No commands match") {
t.Fatalf("expected token to be discoverable, got:\n%s", raw)
}
}

func TestCommandsJSONOutputReturnsStructuredCatalog(t *testing.T) {
mock := NewMockClient()
result := SetTestModeWithSDK(mock)
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ var rootCommandGroupTitles = map[string]string{
}

var rootCommandGroups = map[string][]string{
"core": {"auth", "activity", "board", "card", "search"},
"core": {"auth", "token", "activity", "board", "card", "search"},
"collaboration": {"comment", "notification"},
"getting-started": {"setup", "signup"},
"discover": {"doctor", "config", "commands", "version"},
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestRenderRootHelp(t *testing.T) {
renderHelp(rootCmd, &buf)
out := buf.String()

for _, want := range []string{"CORE COMMANDS", "activity", "GETTING STARTED", "DISCOVER", "FLAGS", "--profile", "LEARN MORE", "Use `fizzy commands` to see the full command catalog.", "implies --json"} {
for _, want := range []string{"CORE COMMANDS", "activity", "token", "GETTING STARTED", "DISCOVER", "FLAGS", "--profile", "LEARN MORE", "Use `fizzy commands` to see the full command catalog.", "implies --json"} {
if !strings.Contains(out, want) {
t.Fatalf("expected root help to contain %q, got:\n%s", want, out)
}
Expand Down
Loading
Loading