Add UI master key setup and change flows
This commit is contained in:
@@ -696,6 +696,25 @@ func TestUnlockRestoresVaultVisibility(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestChangeMasterKeyMarksStateDirty(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
sess := &lifecycleStubSession{}
|
||||
state := State{Session: sess}
|
||||
|
||||
key := vault.MasterKey{Password: "correct horse battery staple"}
|
||||
if err := state.ChangeMasterKey(key); err != nil {
|
||||
t.Fatalf("ChangeMasterKey() error = %v", err)
|
||||
}
|
||||
|
||||
if got := sess.changedKey; got.Password != key.Password {
|
||||
t.Fatalf("changedKey = %#v, want %#v", got, key)
|
||||
}
|
||||
if !state.Dirty {
|
||||
t.Fatal("Dirty = false, want true after ChangeMasterKey")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnterGroupAppendsPathAndClearsSelection(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -929,6 +948,7 @@ type lifecycleStubSession struct {
|
||||
openPath string
|
||||
saveAsPath string
|
||||
remotePath string
|
||||
changedKey vault.MasterKey
|
||||
}
|
||||
|
||||
func (s *lifecycleStubSession) Current() (vault.Model, error) {
|
||||
@@ -954,3 +974,8 @@ func (s *lifecycleStubSession) OpenRemote(_ webdav.Client, path string, _ vault.
|
||||
s.remotePath = path
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *lifecycleStubSession) ChangeMasterKey(key vault.MasterKey) error {
|
||||
s.changedKey = key
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user