Remember recent remote vault connections
This commit is contained in:
@@ -1964,6 +1964,34 @@ func TestUIOpenVaultRestoresLastOpenedGroupForThatVault(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRecentRemoteConnectionsPersistAndReload(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
configPath := filepath.Join(t.TempDir(), "recent-remotes.json")
|
||||
|
||||
first := newUIWithSession("desktop", &session.Manager{})
|
||||
first.recentRemotesPath = configPath
|
||||
first.recentRemotes = nil
|
||||
first.noteRecentRemote("https://dav.example.com", "vaults/home.kdbx", "alice", "secret-1", true)
|
||||
first.noteRecentRemote("https://dav.example.com", "vaults/team.kdbx", "bob", "secret-2", false)
|
||||
first.noteRecentRemote("https://dav.example.com", "vaults/home.kdbx", "alice", "secret-3", true)
|
||||
|
||||
second := newUIWithSession("desktop", &session.Manager{})
|
||||
second.recentRemotesPath = configPath
|
||||
second.recentRemotes = nil
|
||||
second.loadRecentRemotes()
|
||||
|
||||
if got := len(second.recentRemotes); got != 2 {
|
||||
t.Fatalf("len(recentRemotes) = %d, want 2", got)
|
||||
}
|
||||
if got := second.recentRemotes[0]; got.BaseURL != "https://dav.example.com" || got.Path != "vaults/home.kdbx" || got.Username != "alice" || got.Password != "secret-3" {
|
||||
t.Fatalf("recentRemotes[0] = %#v, want updated remembered credentials", got)
|
||||
}
|
||||
if got := second.recentRemotes[1]; got.Username != "" || got.Password != "" {
|
||||
t.Fatalf("recentRemotes[1] = %#v, want credentials omitted when remember disabled", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultStatePathsUsesProvidedStateDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1976,6 +2004,9 @@ func TestDefaultStatePathsUsesProvidedStateDir(t *testing.T) {
|
||||
if got := paths.RecentVaultsPath; got != filepath.Join(base, "recent-vaults.json") {
|
||||
t.Fatalf("RecentVaultsPath = %q, want %q", got, filepath.Join(base, "recent-vaults.json"))
|
||||
}
|
||||
if got := paths.RecentRemotesPath; got != filepath.Join(base, "recent-remotes.json") {
|
||||
t.Fatalf("RecentRemotesPath = %q, want %q", got, filepath.Join(base, "recent-remotes.json"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultStatePathsUsesEnvironmentStateDirWhenFlagUnset(t *testing.T) {
|
||||
@@ -1990,6 +2021,9 @@ func TestDefaultStatePathsUsesEnvironmentStateDirWhenFlagUnset(t *testing.T) {
|
||||
if got := paths.RecentVaultsPath; got != filepath.Join(base, "recent-vaults.json") {
|
||||
t.Fatalf("RecentVaultsPath = %q, want %q", got, filepath.Join(base, "recent-vaults.json"))
|
||||
}
|
||||
if got := paths.RecentRemotesPath; got != filepath.Join(base, "recent-remotes.json") {
|
||||
t.Fatalf("RecentRemotesPath = %q, want %q", got, filepath.Join(base, "recent-remotes.json"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveFlagOrEnvPrefersFlagThenEnvThenFallback(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user