Skip to content

Commit

Permalink
Added more testcases
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sethiya <[email protected]>
  • Loading branch information
Yash Sethiya authored and Yash Sethiya committed Jan 27, 2024
1 parent 44b3b08 commit 0708c18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/fetch/vendir.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func extractImageRegistry(name string) string {
func extractGitHostname(input string) string {
u, err := url.Parse(input)
if err != nil {
return "github.com"
return ""
}
return u.Hostname()
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/fetch/vendir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Test_GitURL_skipsTLS(t *testing.T) {
Namespace: "default",
},
Data: map[string]string{
"dangerousSkipTLSVerify": "github.com, gitlab.com, hostname.com",
"dangerousSkipTLSVerify": "github.com, gitlab.com, hostname.com, 0.0.0.0",
},
}
k8scs := k8sfake.NewSimpleClientset(configMap)
Expand All @@ -84,6 +84,7 @@ func Test_GitURL_skipsTLS(t *testing.T) {
{"https://gitlab.com/bitnami/charts/", true},
{"ssh://[email protected]:/path/to/repo.git", true},
{"https://bitbucket.org/bitnami/charts/", false},
{"https://0.0.0.0/bitnami/charts/", true},
}
for i, tc := range testCases {
err = vendir.AddDir(v1alpha1.AppFetch{
Expand All @@ -93,6 +94,8 @@ func Test_GitURL_skipsTLS(t *testing.T) {
assert.NoError(t, err)

vConf := vendir.Config()
t.Logf("%+v", vConf)
t.Logf("%+v", vConf.Directories[i].Contents[0].Git)
assert.Equal(t, i+1, len(vConf.Directories), "Failed on iteration %d", i)
assert.Equal(t, tc.shouldSkipTLS, vConf.Directories[i].Contents[0].Git.DangerousSkipTLSVerify, "Failed with URL %s", tc.URL)
}
Expand Down

0 comments on commit 0708c18

Please sign in to comment.