mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-15 14:56:42 +00:00
GODT-2173: fix: Migrate Bridge password from v2.X.
This commit is contained in:
@ -21,7 +21,6 @@ import (
|
||||
"encoding/base64"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker-credential-helpers/credentials"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -33,7 +32,7 @@ var testData = map[string]string{ //nolint:gochecknoglobals
|
||||
}
|
||||
|
||||
func TestInsertReadRemove(t *testing.T) {
|
||||
keychain := newKeychain(newTestHelper(), hostURL("bridge"))
|
||||
keychain := newKeychain(NewTestHelper(), hostURL("bridge"))
|
||||
|
||||
for id, secret := range testData {
|
||||
expectedList, _ := keychain.List()
|
||||
@ -115,35 +114,3 @@ func TestInsertReadRemove(t *testing.T) {
|
||||
require.NotContains(t, actualList, id)
|
||||
}
|
||||
}
|
||||
|
||||
type testHelper map[string]*credentials.Credentials
|
||||
|
||||
func newTestHelper() testHelper {
|
||||
return make(testHelper)
|
||||
}
|
||||
|
||||
func (h testHelper) Add(creds *credentials.Credentials) error {
|
||||
h[creds.ServerURL] = creds
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h testHelper) Delete(url string) error {
|
||||
delete(h, url)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h testHelper) Get(url string) (string, string, error) {
|
||||
creds := h[url]
|
||||
|
||||
return creds.Username, creds.Secret, nil
|
||||
}
|
||||
|
||||
func (h testHelper) List() (map[string]string, error) {
|
||||
list := make(map[string]string)
|
||||
|
||||
for url, creds := range h {
|
||||
list[url] = creds.Username
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user