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:
@@ -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)
|
||||
|
||||
@@ -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'")},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user