cmd/tailscale: improve tailscale lock error message if no keys
Previously, running `add/remove/revoke-keys` without passing any keys would fail with an unhelpful error: ```console $ tailscale lock revoke-keys generation of recovery AUM failed: sending generate-recovery-aum: 500 Internal Server Error: no provided key is currently trusted ``` or ```console $ tailscale lock revoke-keys generation of recovery AUM failed: sending generate-recovery-aum: 500 Internal Server Error: network-lock is not active ``` Now they fail with a more useful error: ```console $ tailscale lock revoke-keys missing argument, expected one or more tailnet lock keys ``` Fixes #19130 Change-Id: I9d81fe2f5b92a335854e71cbc6928e7e77e537e3 Signed-off-by: Alex Chan <alexc@tailscale.com>
This commit is contained in:
@@ -2374,6 +2374,38 @@ func TestTailnetLock(t *testing.T) {
|
||||
t.Fatalf("ping node3 -> signing1: expected success, got err: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
// If you run `tailscale lock (add|remove|revoke-keys)` but don't pass any keys,
|
||||
// we print a helpful error message.
|
||||
//
|
||||
// Regression test for tailscale/tailscale#19130
|
||||
t.Run("no-keys-is-error", func(t *testing.T) {
|
||||
for _, verb := range []string{"add", "remove", "revoke-keys"} {
|
||||
t.Run(verb, func(t *testing.T) {
|
||||
tstest.Shard(t)
|
||||
t.Parallel()
|
||||
|
||||
env := NewTestEnv(t)
|
||||
n1 := NewTestNode(t, env)
|
||||
d1 := n1.StartDaemon()
|
||||
defer d1.MustCleanShutdown(t)
|
||||
|
||||
n1.MustUp()
|
||||
n1.AwaitRunning()
|
||||
|
||||
revokeCmd := n1.Tailscale("lock", verb)
|
||||
out, err := revokeCmd.CombinedOutput()
|
||||
if err == nil {
|
||||
t.Fatal("expected command to fail, but succeeded")
|
||||
}
|
||||
want := "missing argument"
|
||||
got := string(out)
|
||||
if !strings.Contains(string(out), want) {
|
||||
t.Fatalf("expected output to contain %q, got %q", want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestNodeWithBadStateFile(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user