Persist vault binding refs in recent remotes

This commit is contained in:
Joe Julian
2026-04-06 16:05:12 -07:00
parent adf91445c3
commit b27e2f168c
2 changed files with 105 additions and 29 deletions
+58
View File
@@ -4018,6 +4018,40 @@ func TestUIRecentRemoteConnectionsPersistAndReload(t *testing.T) {
}
}
func TestUIRecentRemoteConnectionsPersistVaultBindingMetadata(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.currentPath = []string{"Root", "Internet"}
first.vaultPath.SetText("/vaults/family.kdbx")
first.selectedVaultRemoteProfileID = "remote-profile-1"
first.selectedVaultRemoteCredentialEntryID = "remote-creds-1"
first.noteRecentRemote("https://dav.example.com", "vaults/home.kdbx")
second := newUIWithSession("desktop", &session.Manager{})
second.recentRemotesPath = configPath
second.recentRemotes = nil
second.loadRecentRemotes()
if got := len(second.recentRemotes); got != 1 {
t.Fatalf("len(recentRemotes) = %d, want 1", got)
}
record := second.recentRemotes[0]
if record.LocalVaultPath != "/vaults/family.kdbx" {
t.Fatalf("recentRemotes[0].LocalVaultPath = %q, want /vaults/family.kdbx", record.LocalVaultPath)
}
if record.RemoteProfileID != "remote-profile-1" {
t.Fatalf("recentRemotes[0].RemoteProfileID = %q, want remote-profile-1", record.RemoteProfileID)
}
if record.CredentialEntryID != "remote-creds-1" {
t.Fatalf("recentRemotes[0].CredentialEntryID = %q, want remote-creds-1", record.CredentialEntryID)
}
}
func TestUILoadRecentRemotesIgnoresLegacySavedCredentials(t *testing.T) {
t.Parallel()
@@ -4048,6 +4082,30 @@ func TestUILoadRecentRemotesIgnoresLegacySavedCredentials(t *testing.T) {
}
}
func TestUIApplyRecentRemoteRecordRestoresVaultBindingSelection(t *testing.T) {
t.Parallel()
u := newUIWithSession("desktop", &session.Manager{})
u.applyRecentRemoteRecord(recentRemoteRecord{
BaseURL: "https://dav.example.com",
Path: "vaults/home.kdbx",
LocalVaultPath: "/vaults/family.kdbx",
RemoteProfileID: "remote-profile-1",
CredentialEntryID: "remote-creds-1",
})
if got := u.vaultPath.Text(); got != "/vaults/family.kdbx" {
t.Fatalf("vaultPath = %q, want /vaults/family.kdbx", got)
}
if got := u.selectedVaultRemoteProfileID; got != "remote-profile-1" {
t.Fatalf("selectedVaultRemoteProfileID = %q, want remote-profile-1", got)
}
if got := u.selectedVaultRemoteCredentialEntryID; got != "remote-creds-1" {
t.Fatalf("selectedVaultRemoteCredentialEntryID = %q, want remote-creds-1", got)
}
}
func TestUIStartupPreselectsNewestTargetAcrossLocalAndRemote(t *testing.T) {
t.Parallel()