mirror of
https://github.com/cloudflare/cloudflared
synced 2026-06-08 13:33:07 +00:00
TUN-10292: Add cloudflared management token command
Create new management token command to support different resource permissions (logs, admin, host_details). This fixes failing component tests that need admin-level tokens to access management endpoints. - Add ManagementResource enum values: Admin, HostDetails - Create cmd/cloudflared/management package with token command - Extract shared utilities to cliutil/management.go (GetManagementToken, CreateStderrLogger) - Refactor tail/cmd.go to use shared utilities - Update component tests to use new command with admin resource Closes TUN-10292
This commit is contained in:
@@ -19,12 +19,18 @@ type ManagementResource int
|
||||
|
||||
const (
|
||||
Logs ManagementResource = iota
|
||||
Admin
|
||||
HostDetails
|
||||
)
|
||||
|
||||
func (r ManagementResource) String() string {
|
||||
switch r {
|
||||
case Logs:
|
||||
return "logs"
|
||||
case Admin:
|
||||
return "admin"
|
||||
case HostDetails:
|
||||
return "host_details"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -89,6 +89,16 @@ func TestManagementResource_String(t *testing.T) {
|
||||
resource: Logs,
|
||||
want: "logs",
|
||||
},
|
||||
{
|
||||
name: "Admin",
|
||||
resource: Admin,
|
||||
want: "admin",
|
||||
},
|
||||
{
|
||||
name: "HostDetails",
|
||||
resource: HostDetails,
|
||||
want: "host_details",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
@@ -115,6 +125,16 @@ func TestManagementEndpointPath(t *testing.T) {
|
||||
resource: Logs,
|
||||
want: "b34cc7ce-925b-46ee-bc23-4cb5c18d8292/management/logs",
|
||||
},
|
||||
{
|
||||
name: "Admin resource",
|
||||
resource: Admin,
|
||||
want: "b34cc7ce-925b-46ee-bc23-4cb5c18d8292/management/admin",
|
||||
},
|
||||
{
|
||||
name: "HostDetails resource",
|
||||
resource: HostDetails,
|
||||
want: "b34cc7ce-925b-46ee-bc23-4cb5c18d8292/management/host_details",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user