Match remote sync credentials by host

This commit is contained in:
Joe Julian
2026-04-06 22:22:18 -07:00
parent cb6fbd05a3
commit 43ef58936b
2 changed files with 80 additions and 2 deletions
+49
View File
@@ -6732,6 +6732,55 @@ func TestUIAdvancedSyncMatchingRemoteCredentialEntriesUsesBaseURL(t *testing.T)
}
}
func TestUIAdvancedSyncMatchingRemoteCredentialEntriesUsesMatchingHost(t *testing.T) {
t.Parallel()
u := newUIWithModel("desktop", vault.Model{
Entries: []vault.Entry{
{ID: "entry-1", Title: "Mint WebDAV", Username: "charliecroker", URL: "https://dav.example.invalid", Path: []string{"Crew", "Signals"}},
{ID: "entry-2", Title: "Bellagio WebDAV Sign-In", Username: "linuscaldwell", URL: "https://dav.example.invalid/remote.php/dav", Path: []string{"Crew", "Signals"}},
{ID: "entry-3", Title: "Bank Console", Username: "stevefrezelli", URL: "https://insidejob.example.invalid", Path: []string{"Crew", "Signals"}},
},
})
u.syncSourceMode = syncSourceRemote
u.syncRemoteBaseURL.SetText("https://dav.example.invalid/remote.php/dav")
got := u.matchingAdvancedSyncRemoteCredentialEntries()
if len(got) != 2 {
t.Fatalf("len(matchingAdvancedSyncRemoteCredentialEntries()) = %d, want 2", len(got))
}
gotIDs := []string{got[0].ID, got[1].ID}
slices.Sort(gotIDs)
if !slices.Equal(gotIDs, []string{"entry-1", "entry-2"}) {
t.Fatalf("matchingAdvancedSyncRemoteCredentialEntries() ids = %v, want [entry-1 entry-2]", gotIDs)
}
}
func TestUIRemoteSyncSetupMatchingCredentialsUsesMatchingHost(t *testing.T) {
t.Parallel()
u := newUIWithModel("desktop", vault.Model{
Entries: []vault.Entry{
{ID: "entry-1", Title: "Mint WebDAV", Username: "charliecroker", URL: "https://dav.example.invalid", Path: []string{"Crew", "Signals"}},
{ID: "entry-2", Title: "Bellagio WebDAV Sign-In", Username: "linuscaldwell", URL: "https://dav.example.invalid/remote.php/dav", Path: []string{"Crew", "Signals"}},
},
})
u.syncDialogPurpose = syncDialogPurposeRemoteSetup
u.syncSourceMode = syncSourceRemote
u.syncDirection = syncDirectionPush
u.syncRemoteBaseURL.SetText("https://dav.example.invalid/remote.php/dav")
got := u.matchingAdvancedSyncRemoteCredentialEntries()
if len(got) != 2 {
t.Fatalf("len(matchingAdvancedSyncRemoteCredentialEntries()) = %d, want 2 in remote setup flow", len(got))
}
gotIDs := []string{got[0].ID, got[1].ID}
slices.Sort(gotIDs)
if !slices.Equal(gotIDs, []string{"entry-1", "entry-2"}) {
t.Fatalf("matchingAdvancedSyncRemoteCredentialEntries() ids = %v, want [entry-1 entry-2] in remote setup flow", gotIDs)
}
}
func TestUIAdvancedSyncMatchingRemoteCredentialEntriesUsesSavedBindingForCurrentVault(t *testing.T) {
t.Parallel()