Simplify desktop unlock flow
This commit is contained in:
+108
@@ -4377,6 +4377,114 @@ func TestShowLocalVaultChooser(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwitchToLifecycleSelectionResetsLockedLocalSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", summarySession{hasVault: true, locked: true})
|
||||
u.lifecycleMode = "local"
|
||||
u.vaultPath.SetText("/vaults/bellagio.kdbx")
|
||||
u.remoteBaseURL.SetText("https://dav.crew.example.invalid")
|
||||
u.remotePath.SetText("vaults/remote.kdbx")
|
||||
u.remoteUsername.SetText("dannyocean")
|
||||
u.remotePassword.SetText("topsecret")
|
||||
u.rememberRemoteAuth.Value = true
|
||||
u.masterPassword.SetText("correct horse battery staple")
|
||||
u.keyFilePath.SetText("/vaults/keyfile.keyx")
|
||||
u.search.SetText("crew")
|
||||
u.state.CurrentPath = []string{"Crew"}
|
||||
u.state.SelectedEntryID = "entry-1"
|
||||
u.state.Section = appstate.SectionTemplates
|
||||
u.state.Dirty = true
|
||||
|
||||
u.switchToLifecycleSelection("local")
|
||||
|
||||
if !u.shouldShowLifecycleSetup() {
|
||||
t.Fatal("shouldShowLifecycleSetup() = false, want true after switching away from locked local vault")
|
||||
}
|
||||
if got := u.lifecycleMode; got != "local" {
|
||||
t.Fatalf("lifecycleMode = %q, want local", got)
|
||||
}
|
||||
if got := u.vaultPath.Text(); got != "" {
|
||||
t.Fatalf("vaultPath = %q, want empty", got)
|
||||
}
|
||||
if got := u.remoteBaseURL.Text(); got != "" {
|
||||
t.Fatalf("remoteBaseURL = %q, want empty", got)
|
||||
}
|
||||
if got := u.remotePath.Text(); got != "" {
|
||||
t.Fatalf("remotePath = %q, want empty", got)
|
||||
}
|
||||
if got := u.remoteUsername.Text(); got != "" {
|
||||
t.Fatalf("remoteUsername = %q, want empty", got)
|
||||
}
|
||||
if got := u.remotePassword.Text(); got != "" {
|
||||
t.Fatalf("remotePassword = %q, want empty", got)
|
||||
}
|
||||
if u.rememberRemoteAuth.Value {
|
||||
t.Fatal("rememberRemoteAuth = true, want false")
|
||||
}
|
||||
if got := u.masterPassword.Text(); got != "" {
|
||||
t.Fatalf("masterPassword = %q, want empty", got)
|
||||
}
|
||||
if got := u.keyFilePath.Text(); got != "" {
|
||||
t.Fatalf("keyFilePath = %q, want empty", got)
|
||||
}
|
||||
if got := u.search.Text(); got != "" {
|
||||
t.Fatalf("search = %q, want empty", got)
|
||||
}
|
||||
if got := u.state.Section; got != appstate.SectionEntries {
|
||||
t.Fatalf("state.Section = %q, want %q", got, appstate.SectionEntries)
|
||||
}
|
||||
if len(u.state.CurrentPath) != 0 {
|
||||
t.Fatalf("state.CurrentPath = %v, want empty", u.state.CurrentPath)
|
||||
}
|
||||
if got := u.state.SelectedEntryID; got != "" {
|
||||
t.Fatalf("state.SelectedEntryID = %q, want empty", got)
|
||||
}
|
||||
if u.state.Dirty {
|
||||
t.Fatal("state.Dirty = true, want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwitchToLifecycleSelectionResetsLockedRemoteSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
u := newUIWithSession("desktop", summarySession{hasVault: true, locked: true, remote: true})
|
||||
u.lifecycleMode = "local"
|
||||
u.vaultPath.SetText("/vaults/bellagio.kdbx")
|
||||
u.remoteBaseURL.SetText("https://dav.crew.example.invalid")
|
||||
u.remotePath.SetText("vaults/remote.kdbx")
|
||||
u.remoteUsername.SetText("rustyryan")
|
||||
u.remotePassword.SetText("topsecret")
|
||||
u.rememberRemoteAuth.Value = true
|
||||
|
||||
u.switchToLifecycleSelection("remote")
|
||||
|
||||
if !u.shouldShowLifecycleSetup() {
|
||||
t.Fatal("shouldShowLifecycleSetup() = false, want true after switching away from locked remote vault")
|
||||
}
|
||||
if got := u.lifecycleMode; got != "remote" {
|
||||
t.Fatalf("lifecycleMode = %q, want remote", got)
|
||||
}
|
||||
if got := u.vaultPath.Text(); got != "" {
|
||||
t.Fatalf("vaultPath = %q, want empty", got)
|
||||
}
|
||||
if got := u.remoteBaseURL.Text(); got != "" {
|
||||
t.Fatalf("remoteBaseURL = %q, want empty", got)
|
||||
}
|
||||
if got := u.remotePath.Text(); got != "" {
|
||||
t.Fatalf("remotePath = %q, want empty", got)
|
||||
}
|
||||
if got := u.remoteUsername.Text(); got != "" {
|
||||
t.Fatalf("remoteUsername = %q, want empty", got)
|
||||
}
|
||||
if got := u.remotePassword.Text(); got != "" {
|
||||
t.Fatalf("remotePassword = %q, want empty", got)
|
||||
}
|
||||
if u.rememberRemoteAuth.Value {
|
||||
t.Fatal("rememberRemoteAuth = true, want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectingRecentRemoteSwitchesToRemoteMode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user