Tighten mobile locked vault hierarchy
This commit is contained in:
@@ -55,6 +55,32 @@ func waitForBackgroundResult(t *testing.T, u *ui) backgroundActionResult {
|
||||
}
|
||||
}
|
||||
|
||||
type summarySession struct {
|
||||
model vault.Model
|
||||
hasVault bool
|
||||
locked bool
|
||||
remote bool
|
||||
}
|
||||
|
||||
func (s summarySession) Current() (vault.Model, error) {
|
||||
if s.locked {
|
||||
return vault.Model{}, session.ErrLocked
|
||||
}
|
||||
return s.model, nil
|
||||
}
|
||||
|
||||
func (s summarySession) Save(vault.Model) error { return nil }
|
||||
func (s summarySession) SaveAs(string, vault.MasterKey) error { return nil }
|
||||
func (s summarySession) Create(vault.MasterKey) error { return nil }
|
||||
func (s summarySession) Open(string, vault.MasterKey) error { return nil }
|
||||
func (s summarySession) OpenRemote(*webdav.Client, string, vault.MasterKey) error { return nil }
|
||||
func (s summarySession) ChangeMasterKey(vault.MasterKey) error { return nil }
|
||||
func (s summarySession) Lock() error { return nil }
|
||||
func (s summarySession) Unlock(vault.MasterKey) error { return nil }
|
||||
func (s summarySession) HasVault() bool { return s.hasVault }
|
||||
func (s summarySession) IsLocked() bool { return s.locked }
|
||||
func (s summarySession) IsRemote() bool { return s.remote }
|
||||
|
||||
func TestUIFiltersUsingVaultModelPathsAndSearch(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -135,6 +161,51 @@ func TestUISearchBehaviorIsConsistentAcrossDesktopAndPhoneLayouts(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUICurrentVaultSummary(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("local", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("phone", summarySession{hasVault: true})
|
||||
u.vaultPath.SetText("/vaults/family.kdbx")
|
||||
u.recentVaultGroups["/vaults/family.kdbx"] = []string{"Root", "Internet"}
|
||||
|
||||
got := u.currentVaultSummary()
|
||||
want := vaultSummary{
|
||||
Title: "family.kdbx",
|
||||
Detail: "/vaults/family.kdbx",
|
||||
Context: "Resume in: Root / Internet",
|
||||
}
|
||||
if got != want {
|
||||
t.Fatalf("currentVaultSummary() = %#v, want %#v", got, want)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("remote", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("phone", summarySession{hasVault: true, remote: true})
|
||||
u.remoteBaseURL.SetText("https://dav.example.com")
|
||||
u.remotePath.SetText("vaults/home.kdbx")
|
||||
u.recentRemotes = []recentRemoteRecord{{
|
||||
BaseURL: "https://dav.example.com",
|
||||
Path: "vaults/home.kdbx",
|
||||
LastGroup: []string{"Root", "Shared"},
|
||||
}}
|
||||
|
||||
got := u.currentVaultSummary()
|
||||
want := vaultSummary{
|
||||
Title: "home.kdbx · dav.example.com",
|
||||
Detail: "https://dav.example.com",
|
||||
Context: "Resume in: Root / Shared",
|
||||
}
|
||||
if got != want {
|
||||
t.Fatalf("currentVaultSummary() = %#v, want %#v", got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestUIClearingSearchResetsToCurrentSectionListing(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user