From 3ecbf8db28105d147340b80d65a5a6d537233135 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 28 Jul 2020 12:56:46 +0200 Subject: bridge: store credentials in the Keyring instead of the git config --- repository/git_testing.go | 18 +++++++++++++++++- repository/repo.go | 5 ----- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'repository') diff --git a/repository/git_testing.go b/repository/git_testing.go index 5ae4ccc9..7d40bf1f 100644 --- a/repository/git_testing.go +++ b/repository/git_testing.go @@ -3,6 +3,8 @@ package repository import ( "io/ioutil" "log" + + "github.com/99designs/keyring" ) // This is intended for testing only @@ -34,7 +36,11 @@ func CreateTestRepo(bare bool) TestedRepo { log.Fatal("failed to set user.email for test repository: ", err) } - return repo + // make sure we use a mock keyring for testing to not interact with the global system + return &replaceKeyring{ + TestedRepo: repo, + keyring: keyring.NewArrayKeyring(nil), + } } func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) { @@ -56,3 +62,13 @@ func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) { return repoA, repoB, remote } + +// replaceKeyring allow to replace the Keyring of the underlying repo +type replaceKeyring struct { + TestedRepo + keyring Keyring +} + +func (rk replaceKeyring) Keyring() Keyring { + return rk.keyring +} diff --git a/repository/repo.go b/repository/repo.go index 696b032e..7a69a14f 100644 --- a/repository/repo.go +++ b/repository/repo.go @@ -20,11 +20,6 @@ var ( type RepoConfig interface { // LocalConfig give access to the repository scoped configuration LocalConfig() Config - - // GlobalConfig give access to the git global configuration - // Deprecated: to remove in favor of Keyring() - // TODO: remove - GlobalConfig() Config } // RepoKeyring give access to a user-wide storage for secrets -- cgit