1
0
mirror of https://github.com/helm/chart-testing.git synced 2026-02-05 09:45:14 +01:00

Consider username and password in repo urls (#162)

Signed-off-by: Reinhard Naegele <unguiculus@gmail.com>
This commit is contained in:
Reinhard Nägele
2019-07-09 07:24:17 +02:00
committed by GitHub
parent f53c402ee2
commit e731d947fb
2 changed files with 4 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ import (
type AccountValidator struct{}
var repoDomainPattern = regexp.MustCompile("(?:https://|git@)([^/:]+)")
var repoDomainPattern = regexp.MustCompile("(?:https://(?:[^@:]+:[^@:]+@)?|git@)([^/:]+)")
func (v AccountValidator) Validate(repoURL string, account string) error {
domain, err := parseOutGitRepoDomain(repoURL)

View File

@@ -16,10 +16,13 @@ func TestParseOutGitDomain(t *testing.T) {
}{
{"GitHub SSH", "git@github.com:foo/bar", "github.com", nil},
{"GitHub HTTPS", "https://github.com/foo/bar", "github.com", nil},
{"GitHub HTTPS with username/password", "https://foo:token@github.com/foo/bar", "github.com", nil},
{"Gitlab SSH", "git@gitlab.com:foo/bar", "gitlab.com", nil},
{"Gitlab HTTPS", "https://gitlab.com/foo/bar", "gitlab.com", nil},
{"Gitlab HTTPS with username/password", "https://gitlab-ci-token:password@gitlab.com/foo/bar", "gitlab.com", nil},
{"Bitbucket SSH", "git@bitbucket.com:foo/bar", "bitbucket.com", nil},
{"Bitbucket HTTPS", "https://bitbucket.com/foo/bar", "bitbucket.com", nil},
{"Bitbucket HTTPS with username/password", "https://user:pass@bitbucket.com/foo/bar", "bitbucket.com", nil},
{"Invalid", "foo/bar", "", fmt.Errorf("Could not parse git repository domain for 'foo/bar'")},
}