Other: Ensure logout works when offline
This commit is contained in:
@ -491,10 +491,11 @@ func TestBridge_LoginLogoutRepeated(t *testing.T) {
|
|||||||
|
|
||||||
func TestBridge_LogoutOffline(t *testing.T) {
|
func TestBridge_LogoutOffline(t *testing.T) {
|
||||||
withEnv(t, func(ctx context.Context, s *server.Server, netCtl *liteapi.NetCtl, locator bridge.Locator, storeKey []byte) {
|
withEnv(t, func(ctx context.Context, s *server.Server, netCtl *liteapi.NetCtl, locator bridge.Locator, storeKey []byte) {
|
||||||
|
var userID string
|
||||||
|
|
||||||
withBridge(ctx, t, s.GetHostURL(), netCtl, locator, storeKey, func(bridge *bridge.Bridge, mocks *bridge.Mocks) {
|
withBridge(ctx, t, s.GetHostURL(), netCtl, locator, storeKey, func(bridge *bridge.Bridge, mocks *bridge.Mocks) {
|
||||||
// Login the user.
|
// Login the user.
|
||||||
userID, err := bridge.LoginFull(ctx, username, password, nil, nil)
|
userID = must(bridge.LoginFull(ctx, username, password, nil, nil))
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// The user is now connected.
|
// The user is now connected.
|
||||||
require.Equal(t, []string{userID}, bridge.GetUserIDs())
|
require.Equal(t, []string{userID}, bridge.GetUserIDs())
|
||||||
@ -510,6 +511,15 @@ func TestBridge_LogoutOffline(t *testing.T) {
|
|||||||
require.Equal(t, []string{userID}, bridge.GetUserIDs())
|
require.Equal(t, []string{userID}, bridge.GetUserIDs())
|
||||||
require.Empty(t, getConnectedUserIDs(t, bridge))
|
require.Empty(t, getConnectedUserIDs(t, bridge))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Go back online.
|
||||||
|
netCtl.Enable()
|
||||||
|
|
||||||
|
withBridge(ctx, t, s.GetHostURL(), netCtl, locator, storeKey, func(bridge *bridge.Bridge, mocks *bridge.Mocks) {
|
||||||
|
// The user is still disconnected.
|
||||||
|
require.Equal(t, []string{userID}, bridge.GetUserIDs())
|
||||||
|
require.Empty(t, getConnectedUserIDs(t, bridge))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -562,7 +562,7 @@ func (user *User) Logout(ctx context.Context, withAPI bool) error {
|
|||||||
|
|
||||||
if withAPI {
|
if withAPI {
|
||||||
if err := user.client.AuthDelete(ctx); err != nil {
|
if err := user.client.AuthDelete(ctx); err != nil {
|
||||||
return fmt.Errorf("failed to delete auth: %w", err)
|
user.log.WithError(err).Warn("Failed to delete auth")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user