Save remote bindings from the sync menu
This commit is contained in:
@@ -4743,6 +4743,67 @@ func TestUISelectVaultRemoteCredentialEntryUpdatesSelection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{})
|
||||
u.currentPath = []string{"Crew", "Internet"}
|
||||
u.vaultPath.SetText("/tmp/family.kdbx")
|
||||
u.remoteBaseURL.SetText("https://dav.example.invalid/remote.php/dav")
|
||||
u.remotePath.SetText("files/family/keepass.kdbx")
|
||||
u.remoteUsername.SetText("tjulian")
|
||||
u.remotePassword.SetText("token-1")
|
||||
|
||||
if err := u.saveCurrentRemoteBindingAction(); err != nil {
|
||||
t.Fatalf("saveCurrentRemoteBindingAction() error = %v", err)
|
||||
}
|
||||
|
||||
profiles := u.availableRemoteProfiles()
|
||||
if len(profiles) != 1 {
|
||||
t.Fatalf("len(availableRemoteProfiles()) = %d, want 1", len(profiles))
|
||||
}
|
||||
if profiles[0].BaseURL != "https://dav.example.invalid/remote.php/dav" {
|
||||
t.Fatalf("saved profile = %#v, want persisted base URL", profiles[0])
|
||||
}
|
||||
|
||||
entries := u.availableRemoteCredentialEntries()
|
||||
var found bool
|
||||
for _, entry := range entries {
|
||||
if entry.Username == "tjulian" && entry.Password == "token-1" {
|
||||
found = true
|
||||
if !slices.Equal(entry.Path, []string{"Crew", "Internet"}) {
|
||||
t.Fatalf("credential path = %v, want [Crew Internet]", entry.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("availableRemoteCredentialEntries() = %#v, want persisted tjulian/token-1 entry", entries)
|
||||
}
|
||||
|
||||
if got := u.selectedVaultRemoteProfileID; got == "" {
|
||||
t.Fatal("selectedVaultRemoteProfileID = empty, want selected saved profile")
|
||||
}
|
||||
if got := u.selectedVaultRemoteCredentialEntryID; got == "" {
|
||||
t.Fatal("selectedVaultRemoteCredentialEntryID = empty, want selected saved credential entry")
|
||||
}
|
||||
if !u.state.Dirty {
|
||||
t.Fatal("state.Dirty = false, want true after saving binding into vault")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionRequiresCompleteRemoteSignIn(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{})
|
||||
u.vaultPath.SetText("/tmp/family.kdbx")
|
||||
u.remoteBaseURL.SetText("https://dav.example.invalid/remote.php/dav")
|
||||
u.remotePath.SetText("files/family/keepass.kdbx")
|
||||
|
||||
if err := u.saveCurrentRemoteBindingAction(); err == nil {
|
||||
t.Fatal("saveCurrentRemoteBindingAction() error = nil, want validation error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwitchToLifecycleSelectionResetsLockedLocalSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user