Add remote sync removal flow
This commit is contained in:
+124
@@ -5904,6 +5904,41 @@ func TestUIRemoteSyncSettingsShortcutLabelUsesClearLanguage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIShouldShowRemoveRemoteSyncShortcutForSavedBinding(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithModel("desktop", vault.Model{
|
||||
Entries: []vault.Entry{{
|
||||
ID: "remote-creds-1",
|
||||
Title: "WebDAV Sign-In",
|
||||
Username: "tjulian",
|
||||
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",
|
||||
}},
|
||||
})
|
||||
u.state.Section = appstate.SectionEntries
|
||||
|
||||
if !u.shouldShowRemoveRemoteSyncShortcut() {
|
||||
t.Fatal("shouldShowRemoveRemoteSyncShortcut() = false, want true when a saved binding exists")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoveRemoteSyncShortcutLabelUsesClearLanguage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
|
||||
if got := u.removeRemoteSyncShortcutLabel(); got != "Stop Using Remote Sync" {
|
||||
t.Fatalf("removeRemoteSyncShortcutLabel() = %q, want Stop Using Remote Sync", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIOpenRemoteSyncSetupDialogPrefillsCurrentVaultSetupFlow(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -6280,6 +6315,95 @@ func TestUIRemoteSyncSetupCanPersistManualSyncMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoveSelectedRemoteBindingActionClearsVaultBindingAndRecentRefs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
key := vault.MasterKey{Password: "correct horse battery staple"}
|
||||
currentPath := filepath.Join(t.TempDir(), "current.kdbx")
|
||||
writeKDBXMainTestFile(t, currentPath, vault.Model{
|
||||
Entries: []vault.Entry{{
|
||||
ID: "remote-creds-1",
|
||||
Title: "WebDAV Sign-In",
|
||||
Username: "tjulian",
|
||||
Password: "token-1",
|
||||
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",
|
||||
}},
|
||||
}, key)
|
||||
|
||||
dir := t.TempDir()
|
||||
u := newUIWithSession("desktop", &session.Manager{}, statePaths{
|
||||
DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"),
|
||||
RecentVaultsPath: filepath.Join(dir, "recent-vaults.json"),
|
||||
RecentRemotesPath: filepath.Join(dir, "recent-remotes.json"),
|
||||
UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"),
|
||||
})
|
||||
u.masterPassword.SetText(key.Password)
|
||||
u.vaultPath.SetText(currentPath)
|
||||
u.recentRemotes = []recentRemoteRecord{{
|
||||
BaseURL: "https://dav.example.invalid/remote.php/dav",
|
||||
Path: "files/family/keepass.kdbx",
|
||||
LocalVaultPath: currentPath,
|
||||
RemoteProfileID: "family-webdav",
|
||||
CredentialEntryID: "remote-creds-1",
|
||||
SyncMode: string(appstate.SyncModeAutomaticOnOpenSave),
|
||||
}}
|
||||
if err := u.openVaultAction(); err != nil {
|
||||
t.Fatalf("openVaultAction() error = %v", err)
|
||||
}
|
||||
|
||||
if err := u.removeSelectedRemoteBindingAction(); err != nil {
|
||||
t.Fatalf("removeSelectedRemoteBindingAction() error = %v", err)
|
||||
}
|
||||
|
||||
if got := u.selectedVaultRemoteProfileID; got != "" {
|
||||
t.Fatalf("selectedVaultRemoteProfileID = %q, want empty", got)
|
||||
}
|
||||
if got := u.selectedVaultRemoteCredentialEntryID; got != "" {
|
||||
t.Fatalf("selectedVaultRemoteCredentialEntryID = %q, want empty", got)
|
||||
}
|
||||
if got := u.selectedVaultRemoteSyncMode; got != appstate.SyncModeManual {
|
||||
t.Fatalf("selectedVaultRemoteSyncMode = %q, want manual", got)
|
||||
}
|
||||
if got := u.recentRemotes[0].RemoteProfileID; got != "" {
|
||||
t.Fatalf("recentRemotes[0].RemoteProfileID = %q, want empty", got)
|
||||
}
|
||||
if got := u.recentRemotes[0].CredentialEntryID; got != "" {
|
||||
t.Fatalf("recentRemotes[0].CredentialEntryID = %q, want empty", got)
|
||||
}
|
||||
if got := u.recentRemotes[0].SyncMode; got != "" {
|
||||
t.Fatalf("recentRemotes[0].SyncMode = %q, want empty", got)
|
||||
}
|
||||
if got := u.state.StatusMessage; got != "Remote sync is no longer set up for this vault." {
|
||||
t.Fatalf("StatusMessage = %q, want removal status", got)
|
||||
}
|
||||
if u.shouldShowDirectRemoteSyncShortcut() {
|
||||
t.Fatal("shouldShowDirectRemoteSyncShortcut() = true, want false after removing binding")
|
||||
}
|
||||
if !u.shouldShowRemoteSyncSetupShortcut() {
|
||||
t.Fatal("shouldShowRemoteSyncSetupShortcut() = false, want true after removing binding")
|
||||
}
|
||||
|
||||
reopened := newUIWithSession("desktop", &session.Manager{})
|
||||
reopened.masterPassword.SetText(key.Password)
|
||||
reopened.vaultPath.SetText(currentPath)
|
||||
if err := reopened.openVaultAction(); err != nil {
|
||||
t.Fatalf("reopened.openVaultAction() error = %v", err)
|
||||
}
|
||||
if got := len(reopened.availableRemoteProfiles()); got != 0 {
|
||||
t.Fatalf("len(reopened.availableRemoteProfiles()) = %d, want 0", got)
|
||||
}
|
||||
if got := len(reopened.availableRemoteCredentialEntries()); got != 0 {
|
||||
t.Fatalf("len(reopened.availableRemoteCredentialEntries()) = %d, want 0", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user