Match Advanced Sync credentials by URL
This commit is contained in:
@@ -5826,6 +5826,9 @@ func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T)
|
||||
if !slices.Equal(entry.Path, []string{"Crew", "Internet"}) {
|
||||
t.Fatalf("credential path = %v, want [Crew Internet]", entry.Path)
|
||||
}
|
||||
if entry.URL != "https://dav.example.invalid/remote.php/dav" {
|
||||
t.Fatalf("credential URL = %q, want remote.php/dav URL", entry.URL)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
@@ -5843,6 +5846,53 @@ func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIAdvancedSyncMatchingRemoteCredentialEntriesUsesBaseURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{ID: "entry-1", Title: "Bellagio", Username: "rustyryan", URL: "https://dav.example.invalid/remote.php/dav/", Path: []string{"Crew", "Internet"}},
|
||||
{ID: "entry-2", Title: "Vault Console", Username: "dannyocean", URL: "https://vault.crew.example.invalid", Path: []string{"Crew", "Internet"}},
|
||||
{ID: "entry-3", Title: "WebDAV Sign-In", Username: "tjulian", URL: "https://dav.example.invalid/remote.php/dav", Path: []string{"Crew", "Internet"}},
|
||||
},
|
||||
})
|
||||
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))
|
||||
}
|
||||
if got[0].ID != "entry-1" || got[1].ID != "entry-3" {
|
||||
t.Fatalf("matchingAdvancedSyncRemoteCredentialEntries() = %#v, want Bellagio and WebDAV Sign-In matches", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIApplyAdvancedSyncRemoteCredentialEntryFillsCredentials(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{})
|
||||
entry := vault.Entry{
|
||||
ID: "remote-creds-1",
|
||||
Title: "WebDAV Sign-In",
|
||||
Username: "tjulian",
|
||||
Password: "token-1",
|
||||
URL: "https://dav.example.invalid/remote.php/dav",
|
||||
}
|
||||
|
||||
u.applyAdvancedSyncRemoteCredentialEntry(entry)
|
||||
|
||||
if got := u.syncRemoteUsername.Text(); got != "tjulian" {
|
||||
t.Fatalf("syncRemoteUsername = %q, want tjulian", got)
|
||||
}
|
||||
if got := u.syncRemotePassword.Text(); got != "token-1" {
|
||||
t.Fatalf("syncRemotePassword = %q, want token-1", got)
|
||||
}
|
||||
if got := u.selectedSyncRemoteCredentialEntryID; got != "remote-creds-1" {
|
||||
t.Fatalf("selectedSyncRemoteCredentialEntryID = %q, want remote-creds-1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionRequiresCompleteRemoteSignIn(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user