Add logout method to tsic
This commit is contained in:
parent
b54c0e3d22
commit
b7d7fc57c4
3 changed files with 11 additions and 1 deletions
|
@ -141,7 +141,7 @@ func TestAuthWebFlowLogoutAndRelogin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, client := range allClients {
|
for _, client := range allClients {
|
||||||
_, _, err = client.Execute([]string{"tailscale", "logout"})
|
err := client.Logout()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to logout client %s: %s", client.Hostname(), err)
|
t.Errorf("failed to logout client %s: %s", client.Hostname(), err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ type TailscaleClient interface {
|
||||||
Execute(command []string) (string, string, error)
|
Execute(command []string) (string, string, error)
|
||||||
Up(loginServer, authKey string) error
|
Up(loginServer, authKey string) error
|
||||||
UpWithLoginURL(loginServer string) (*url.URL, error)
|
UpWithLoginURL(loginServer string) (*url.URL, error)
|
||||||
|
Logout() error
|
||||||
IPs() ([]netip.Addr, error)
|
IPs() ([]netip.Addr, error)
|
||||||
FQDN() (string, error)
|
FQDN() (string, error)
|
||||||
Status() (*ipnstate.Status, error)
|
Status() (*ipnstate.Status, error)
|
||||||
|
|
|
@ -270,6 +270,15 @@ func (t *TailscaleInContainer) UpWithLoginURL(
|
||||||
return loginURL, nil
|
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) {
|
func (t *TailscaleInContainer) IPs() ([]netip.Addr, error) {
|
||||||
if t.ips != nil && len(t.ips) != 0 {
|
if t.ips != nil && len(t.ips) != 0 {
|
||||||
return t.ips, nil
|
return t.ips, nil
|
||||||
|
|
Loading…
Reference in a new issue