Refine remote open lifecycle flow
This commit is contained in:
+104
-1
@@ -3017,12 +3017,115 @@ func TestUILoadingDetailMessageUsesSelectedRemote(t *testing.T) {
|
||||
u.loadingMessage = "Open remote vault..."
|
||||
|
||||
got := u.loadingDetailMessage()
|
||||
want := "Target: dav.example.com · vaults/home.kdbx (vaults/home.kdbx)"
|
||||
want := "Target: home.kdbx · dav.example.com (vaults/home.kdbx)"
|
||||
if got != want {
|
||||
t.Fatalf("loadingDetailMessage() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFriendlyRecentRemoteLabelUsesVaultNameBeforeHost(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
got := friendlyRecentRemoteLabel(recentRemoteRecord{
|
||||
BaseURL: "https://dav.example.com/remote.php/webdav/",
|
||||
Path: "vaults/family/home.kdbx",
|
||||
})
|
||||
want := "home.kdbx · dav.example.com"
|
||||
if got != want {
|
||||
t.Fatalf("friendlyRecentRemoteLabel() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecentRemoteStoredAuthSummaryDescribesSavedCredentialState(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
record recentRemoteRecord
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "location_only",
|
||||
record: recentRemoteRecord{},
|
||||
want: "location only",
|
||||
},
|
||||
{
|
||||
name: "username_only",
|
||||
record: recentRemoteRecord{Username: "alice"},
|
||||
want: "saved username",
|
||||
},
|
||||
{
|
||||
name: "password_only",
|
||||
record: recentRemoteRecord{Password: "token-1"},
|
||||
want: "saved password",
|
||||
},
|
||||
{
|
||||
name: "full_sign_in",
|
||||
record: recentRemoteRecord{Username: "alice", Password: "token-1"},
|
||||
want: "saved username and password",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if got := recentRemoteStoredAuthSummary(tt.record); got != tt.want {
|
||||
t.Fatalf("recentRemoteStoredAuthSummary(%+v) = %q, want %q", tt.record, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoteAuthStatusMessageExplainsWhatWillBeRemembered(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
u.remoteBaseURL.SetText("https://dav.example.com")
|
||||
u.remotePath.SetText("vaults/home.kdbx")
|
||||
|
||||
if got := u.remoteAuthStatusMessage(); got != "Only the location will be saved in Recent Connections." {
|
||||
t.Fatalf("remoteAuthStatusMessage() = %q, want location-only guidance", got)
|
||||
}
|
||||
|
||||
u.rememberRemoteAuth.Value = true
|
||||
if got := u.remoteAuthStatusMessage(); got != "Enter a username or password to save sign-in details for this connection." {
|
||||
t.Fatalf("remoteAuthStatusMessage() = %q, want empty-sign-in guidance", got)
|
||||
}
|
||||
|
||||
u.remoteUsername.SetText("alice")
|
||||
if got := u.remoteAuthStatusMessage(); got != "This sign-in will be saved in Recent Connections after a successful open." {
|
||||
t.Fatalf("remoteAuthStatusMessage() = %q, want pending-save guidance", got)
|
||||
}
|
||||
|
||||
u.recentRemotes = []recentRemoteRecord{{
|
||||
BaseURL: "https://dav.example.com",
|
||||
Path: "vaults/home.kdbx",
|
||||
Username: "alice",
|
||||
Password: "secret-1",
|
||||
}}
|
||||
if got := u.remoteAuthStatusMessage(); got != "Saved sign-in will be updated for this connection." {
|
||||
t.Fatalf("remoteAuthStatusMessage() = %q, want saved-sign-in guidance", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIRemoteOpenButtonLabelOffersRetryAfterFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", &session.Manager{})
|
||||
u.lifecycleMode = "remote"
|
||||
|
||||
if got := u.remoteOpenButtonLabel(); got != "Open Remote Vault" {
|
||||
t.Fatalf("remoteOpenButtonLabel() = %q, want %q", got, "Open Remote Vault")
|
||||
}
|
||||
|
||||
u.state.ErrorMessage = "open remote vault failed: dial tcp timeout"
|
||||
if got := u.remoteOpenButtonLabel(); got != "Retry Remote Vault" {
|
||||
t.Fatalf("remoteOpenButtonLabel() after error = %q, want %q", got, "Retry Remote Vault")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUIOpenRemoteVaultRestoresLastOpenedGroupForThatConnection(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user