Persist remote binding after setup push
This commit is contained in:
@@ -5974,6 +5974,72 @@ func TestUISyncDialogUsesAdvancedCopy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoteSyncSetupPersistsBindingAfterSuccessfulPush(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: "entry-current",
|
||||
Title: "Vault Console",
|
||||
Username: "dannyocean",
|
||||
Password: "token-current",
|
||||
URL: "https://vault.crew.example.invalid",
|
||||
Path: []string{"Root", "Internet"},
|
||||
}},
|
||||
}, key)
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
case http.MethodPut:
|
||||
w.Header().Set("ETag", "\"v1\"")
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
default:
|
||||
t.Fatalf("unexpected method %s", r.Method)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
u.masterPassword.SetText(key.Password)
|
||||
u.vaultPath.SetText(currentPath)
|
||||
if err := u.openVaultAction(); err != nil {
|
||||
t.Fatalf("openVaultAction() error = %v", err)
|
||||
}
|
||||
|
||||
u.openRemoteSyncSetupDialog()
|
||||
u.syncRemoteBaseURL.SetText(server.URL)
|
||||
u.syncRemotePath.SetText("vaults/other.kdbx")
|
||||
u.syncRemoteUsername.SetText("tjulian")
|
||||
u.syncRemotePassword.SetText("token-1")
|
||||
|
||||
if err := u.advancedSyncAction(); err != nil {
|
||||
t.Fatalf("advancedSyncAction() error = %v", err)
|
||||
}
|
||||
|
||||
if got := u.selectedVaultRemoteProfileID; got == "" {
|
||||
t.Fatal("selectedVaultRemoteProfileID = empty, want saved binding")
|
||||
}
|
||||
if got := u.selectedVaultRemoteCredentialEntryID; got == "" {
|
||||
t.Fatal("selectedVaultRemoteCredentialEntryID = empty, want saved credential binding")
|
||||
}
|
||||
if got := u.remoteBaseURL.Text(); got != server.URL {
|
||||
t.Fatalf("remoteBaseURL = %q, want %q", got, server.URL)
|
||||
}
|
||||
if got := u.remotePath.Text(); got != "vaults/other.kdbx" {
|
||||
t.Fatalf("remotePath = %q, want vaults/other.kdbx", got)
|
||||
}
|
||||
if got := len(u.recentRemotes); got != 1 {
|
||||
t.Fatalf("len(recentRemotes) = %d, want 1", got)
|
||||
}
|
||||
if got := u.recentRemotes[0].LocalVaultPath; got != currentPath {
|
||||
t.Fatalf("recentRemotes[0].LocalVaultPath = %q, want %q", got, currentPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUISaveCurrentRemoteBindingActionPersistsBindingIntoVault(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user