Beispiel #1
0
func TestLoad(t *testing.T) {
	backendConfig := backends.Config{
		Type: backends.ConfigTypeMock,
	}
	backendClient := backends.NewMockBackend()
	for i, cryptoConfig := range safeCryptoConfigs {
		cryptoClient, err := crypto.New(&cryptoConfig)
		if err != nil {
			t.Fatalf("#%d: failed to create crypto client: %s", i, err.Error())
		}
		conf := &config.Config{
			Encryption: cryptoConfig,
			Storage:    backendConfig,
		}
		for j, data := range safeData {
			backendClient.Data = []byte(data)
			s, err := safe.Load([]byte(password), backendClient, cryptoClient, conf)
			if err != nil {
				t.Fatalf("#%d.#%d: failed to load safe: %s", i, j, err.Error())
			}
			if _, err := s.Get("foo"); err != nil {
				t.Fatalf("#%d.#%d: failed to get 'foo' safe account: %s", i, j, err.Error())
			}
		}
	}
}
Beispiel #2
0
Datei: util.go Projekt: bndw/pick
func loadSafe() (*safe.Safe, error) {
	password, err := utils.GetPasswordInput("Enter your master password")
	if err != nil {
		return nil, err
	}

	backendClient, err := newBackendClient()
	if err != nil {
		return nil, err
	}

	cryptoClient, err := newCryptoClient()
	if err != nil {
		return nil, err
	}

	return safe.Load(
		password,
		backendClient,
		cryptoClient,
		config,
	)
}