示例#1
0
文件: app.go 项目: schmich/ward
func (app *App) openStore() *store.Store {
	for {
		master := readPassword("Master password: "******"%s\n", err)

		if _, ok := err.(crypto.IncorrectPasswordError); !ok {
			if _, ok = err.(crypto.InvalidPasswordError); !ok {
				os.Exit(1)
			}
		}
	}
}
示例#2
0
func (s *StoreSuite) TestUpdateMasterPassword(c *C) {
	fileName := tempFileName()
	db, _ := store.Create(fileName, "pass", 1)
	credentials := make(map[string]*store.Credential, 100)
	for i := 0; i < 100; i++ {
		login := strconv.Itoa(i)
		credentials[login] = &store.Credential{
			Login:    login,
			Password: "******",
			Realm:    "baz",
			Note:     "quux",
		}
		db.AddCredential(credentials[login])
	}
	c.Assert(len(db.AllCredentials()), Equals, len(credentials))
	db.UpdateMasterPassword("newpass", 100)
	db.Close()
	db, _ = store.Open(fileName, "newpass")
	newCredentials := db.AllCredentials()
	c.Assert(len(newCredentials), Equals, len(credentials))
	for _, credential := range newCredentials {
		assertCredentialsEqual(c, credential, credentials[credential.Login])
	}
}