diff options
author | Michael Muré <batolettre@gmail.com> | 2020-07-28 12:56:46 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-09-29 20:42:21 +0200 |
commit | 3ecbf8db28105d147340b80d65a5a6d537233135 (patch) | |
tree | 9bda351f7d1d520fa0ae51b155792ffca3517a9d /repository/git_testing.go | |
parent | b127481364176ac7ecb56c1604e1460251574859 (diff) | |
download | git-bug-3ecbf8db28105d147340b80d65a5a6d537233135.tar.gz |
bridge: store credentials in the Keyring instead of the git config
Diffstat (limited to 'repository/git_testing.go')
-rw-r--r-- | repository/git_testing.go | 18 |
1 files changed, 17 insertions, 1 deletions
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 +} |