Use saved bindings in Advanced Sync lookup
This commit is contained in:
@@ -5868,6 +5868,49 @@ func TestUIAdvancedSyncMatchingRemoteCredentialEntriesUsesBaseURL(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIAdvancedSyncMatchingRemoteCredentialEntriesUsesSavedBindingForCurrentVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
localVaultPath := filepath.Join(t.TempDir(), "family.kdbx")
|
||||
u := newUIWithState("desktop", &uiSession{model: vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{ID: "remote-creds-1", Title: "WebDAV Sign-In", Username: "tjulian", Path: []string{"Crew", "Internet"}},
|
||||
{ID: "entry-2", Title: "Vault Console", Username: "dannyocean", URL: "https://vault.crew.example.invalid", Path: []string{"Crew", "Internet"}},
|
||||
},
|
||||
RemoteProfiles: []vault.RemoteProfile{{
|
||||
ID: "family-webdav",
|
||||
Name: "Family Vault",
|
||||
Backend: vault.RemoteBackendWebDAV,
|
||||
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||
Path: "files/family/keepass.kdbx",
|
||||
}},
|
||||
}}, statePaths{
|
||||
DefaultSaveAsPath: filepath.Join(t.TempDir(), "default.kdbx"),
|
||||
RecentVaultsPath: filepath.Join(t.TempDir(), "recent-vaults.json"),
|
||||
RecentRemotesPath: filepath.Join(t.TempDir(), "recent-remotes.json"),
|
||||
UIPreferencesPath: filepath.Join(t.TempDir(), "ui-prefs.json"),
|
||||
})
|
||||
u.vaultPath.SetText(localVaultPath)
|
||||
u.syncSourceMode = syncSourceRemote
|
||||
u.syncRemoteBaseURL.SetText("https://dav.example.invalid/remote.php/dav")
|
||||
u.syncRemotePath.SetText("files/family/keepass.kdbx")
|
||||
u.recentRemotes = []recentRemoteRecord{{
|
||||
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||
Path: "files/family/keepass.kdbx",
|
||||
LocalVaultPath: localVaultPath,
|
||||
RemoteProfileID: "family-webdav",
|
||||
CredentialEntryID: "remote-creds-1",
|
||||
}}
|
||||
|
||||
got := u.matchingAdvancedSyncRemoteCredentialEntries()
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("len(matchingAdvancedSyncRemoteCredentialEntries()) = %d, want 1 from saved binding", len(got))
|
||||
}
|
||||
if got[0].ID != "remote-creds-1" {
|
||||
t.Fatalf("matchingAdvancedSyncRemoteCredentialEntries() = %#v, want remote-creds-1 from saved binding", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIApplyAdvancedSyncRemoteCredentialEntryFillsCredentials(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user