|
|
|
@ -21,6 +21,7 @@ import (
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
|
|
|
|
"sync"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
@ -204,3 +205,33 @@ func TestRepoAddFileCompletion(t *testing.T) {
|
|
|
|
|
checkFileCompletion(t, "repo add reponame", false)
|
|
|
|
|
checkFileCompletion(t, "repo add reponame https://example.com", false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRepoAddWithPasswordFromStdin(t *testing.T) {
|
|
|
|
|
srv := repotest.NewTempServerWithCleanupAndBasicAuth(t, "testdata/testserver/*.*")
|
|
|
|
|
defer srv.Stop()
|
|
|
|
|
|
|
|
|
|
defer resetEnv()()
|
|
|
|
|
|
|
|
|
|
in, err := os.Open("testdata/password")
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("unexpected error, got '%v'", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tmpdir := ensure.TempDir(t)
|
|
|
|
|
repoFile := filepath.Join(tmpdir, "repositories.yaml")
|
|
|
|
|
|
|
|
|
|
store := storageFixture()
|
|
|
|
|
|
|
|
|
|
const testName = "test-name"
|
|
|
|
|
const username = "username"
|
|
|
|
|
cmd := fmt.Sprintf("repo add %s %s --repository-config %s --repository-cache %s --username %s --password-stdin", testName, srv.URL(), repoFile, tmpdir, username)
|
|
|
|
|
var result string
|
|
|
|
|
_, result, err = executeActionCommandStdinC(store, in, cmd)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("unexpected error, got '%v'", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(result, fmt.Sprintf("\"%s\" has been added to your repositories", testName)) {
|
|
|
|
|
t.Errorf("Repo was not successfully added. Output: %s", result)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|