Files
skillshare/internal/install/source_string_test.go
T
Willie c040917bc7 fix(security): enforce credential and filesystem trust boundaries (#861)
Bind provider credentials to canonical or explicitly configured HTTPS origins and preserve that policy across remote consumers. Reject cross-site credentialed reads, linked fallback directories, and discovered-agent writes outside the source; audit staged content before rooted atomic publication.

Add boundary regressions, private Git update coverage, stable cross-platform fixtures, and aligned documentation. Verified the integrated main baseline with all executed CI checks passing.
2026-11-11 23:17:54 +08:00

54 lines
1.3 KiB
Go

package install
import "testing"
func TestSourceType_String(t *testing.T) {
tests := []struct {
st SourceType
want string
}{
{SourceTypeUnknown, "unknown"},
{SourceTypeLocalPath, "local"},
{SourceTypeGitHub, "github"},
{SourceTypeGitHTTPS, "git-https"},
{SourceTypeGitSSH, "git-ssh"},
{SourceType(99), "unknown"},
}
for _, tt := range tests {
t.Run(tt.want, func(t *testing.T) {
if got := tt.st.String(); got != tt.want {
t.Errorf("String() = %q, want %q", got, tt.want)
}
})
}
}
func TestResolveTokenForURL_NoToken(t *testing.T) {
resetAuthTestEnv(t)
token, username := ResolveTokenForURL("https://github.com/user/repo.git", ParseOptions{})
if token != "" {
t.Errorf("expected empty token, got %q", token)
}
if username != "" {
t.Errorf("expected empty username, got %q", username)
}
}
func TestDetectPlatformForURL(t *testing.T) {
tests := []struct {
url string
want Platform
}{
{"https://github.com/user/repo.git", PlatformGitHub},
{"https://gitlab.com/user/repo.git", PlatformGitLab},
{"https://example.com/repo.git", PlatformUnknown},
}
for _, tt := range tests {
t.Run(tt.url, func(t *testing.T) {
if got := DetectPlatformForURL(tt.url); got != tt.want {
t.Errorf("DetectPlatformForURL() = %v, want %v", got, tt.want)
}
})
}
}