cmd/tailscale/cli: add a debug command to force a risky action

For testing risky action flows.

Updates #15445

Change-Id: Id81e54678a1fe5ccedb5dd9c6542ff48c162b349
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2025-09-02 08:21:47 -07:00 committed by Brad Fitzpatrick
parent 12ad630128
commit 61d3693e61

View File

@ -374,6 +374,17 @@ func debugCmd() *ffcli.Command {
ShortHelp: "Print the current set of candidate peer relay servers",
Exec: runPeerRelayServers,
},
{
Name: "test-risk",
ShortUsage: "tailscale debug test-risk",
ShortHelp: "Do a fake risky action",
Exec: runTestRisk,
FlagSet: (func() *flag.FlagSet {
fs := newFlagSet("test-risk")
fs.StringVar(&testRiskArgs.acceptedRisk, "accept-risk", "", "comma-separated list of accepted risks")
return fs
})(),
},
}...),
}
}
@ -1403,3 +1414,18 @@ func runPeerRelayServers(ctx context.Context, args []string) error {
e.Encode(v)
return nil
}
var testRiskArgs struct {
acceptedRisk string
}
func runTestRisk(ctx context.Context, args []string) error {
if len(args) > 0 {
return errors.New("unexpected arguments")
}
if err := presentRiskToUser("test-risk", "This is a test risky action.", testRiskArgs.acceptedRisk); err != nil {
return err
}
fmt.Println("did-test-risky-action")
return nil
}