From b7d7fc57c4c9ad852c0af275510f531815ab6550 Mon Sep 17 00:00:00 2001 From: Juan Font Date: Wed, 21 Dec 2022 22:29:52 +0000 Subject: [PATCH] Add logout method to tsic --- integration/auth_web_flow_test.go | 2 +- integration/tailscale.go | 1 + integration/tsic/tsic.go | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/integration/auth_web_flow_test.go b/integration/auth_web_flow_test.go index df7c0d0..3682ed1 100644 --- a/integration/auth_web_flow_test.go +++ b/integration/auth_web_flow_test.go @@ -141,7 +141,7 @@ func TestAuthWebFlowLogoutAndRelogin(t *testing.T) { } for _, client := range allClients { - _, _, err = client.Execute([]string{"tailscale", "logout"}) + err := client.Logout() if err != nil { t.Errorf("failed to logout client %s: %s", client.Hostname(), err) } diff --git a/integration/tailscale.go b/integration/tailscale.go index 935fcf7..77a6b31 100644 --- a/integration/tailscale.go +++ b/integration/tailscale.go @@ -15,6 +15,7 @@ type TailscaleClient interface { Execute(command []string) (string, string, error) Up(loginServer, authKey string) error UpWithLoginURL(loginServer string) (*url.URL, error) + Logout() error IPs() ([]netip.Addr, error) FQDN() (string, error) Status() (*ipnstate.Status, error) diff --git a/integration/tsic/tsic.go b/integration/tsic/tsic.go index 971cf01..768a0a9 100644 --- a/integration/tsic/tsic.go +++ b/integration/tsic/tsic.go @@ -270,6 +270,15 @@ func (t *TailscaleInContainer) UpWithLoginURL( return loginURL, nil } +func (t *TailscaleInContainer) Logout() error { + _, _, err := t.Execute([]string{"tailscale", "logout"}) + if err != nil { + return err + } + + return nil +} + func (t *TailscaleInContainer) IPs() ([]netip.Addr, error) { if t.ips != nil && len(t.ips) != 0 { return t.ips, nil