Skip to content

Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.

1.6 KB
Raw Blame
package domain

import "testing"

func TestStripURLCredentials(t *testing.T) {
	for in, want := range map[string]string{
		"https://user:[email protected]/acme/app.git": "https://github.com/acme/app.git",
		"https://[email protected]/acme/app.git":   "https://github.com/acme/app.git",
		"http://oauth2:[email protected]/g/r.git":         "http://git.example.com/g/r.git",
		"git://u:[email protected]/r.git":                   "git://git.example.com/r.git",
		"ssh://git:[email protected]/g/r.git":              "ssh://[email protected]/g/r.git",
		"ssh://[email protected]:2222/g/r.git":            "ssh://[email protected]:2222/g/r.git",
		"[email protected]:acme/app.git":                       "[email protected]:acme/app.git",
		"https://github.com/acme/app.git":                   "https://github.com/acme/app.git",
		" https://github.com/acme/[email protected] ":                 "https://github.com/acme/[email protected]",
		"/srv/repos/app":                                    "/srv/repos/app",
		"":                                                  "",
	} {
		if got := StripURLCredentials(in); got != want {
			t.Errorf("StripURLCredentials(%q) = %q, want %q", in, got, want)
		}
	}
	if !URLHasCredentials("https://x:y@h/r.git") || URLHasCredentials("ssh://git@h/r.git") || URLHasCredentials("git@h:r.git") {
		t.Fatal("URLHasCredentials classification")
	}
	public := PublicRepository(Repository{CloneURL: "https://user:[email protected]/acme/app.git", GitToken: "t"})
	if public.CloneURL != "https://github.com/acme/app.git" || public.GitToken != "" {
		t.Fatalf("public repository leaks credentials: %+v", public)
	}
}