Skip to content

Commit

Permalink
fix: gittest server tls: unknown certificate authority (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
debanjan97 authored Sep 10, 2024
1 parent 5aeb9cd commit bea4330
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion testhelper/gittest/gittest.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (s *Server) GetServerCA() []byte {
}

func (s *Server) GetLatestCommitHash(t testing.TB, branch string) string {
cmd := exec.Command("git", "ls-remote", s.URL, fmt.Sprintf("refs/heads/%s", branch))
cmd := exec.Command("git", "-c", "http.sslVerify=false", "ls-remote", s.URL, fmt.Sprintf("refs/heads/%s", branch))
out, err := cmd.Output()
require.NoError(t, err, "should be able to run the ls-remote command")
commitHash := strings.Split(string(out), "\t")[0]
Expand Down
7 changes: 7 additions & 0 deletions testhelper/gittest/gittest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ func TestGitServer(t *testing.T) {
url := s.URL
require.NoError(t, exec.Command("git", "-c", "http.sslVerify=false", "clone", url, tempDir).Run(), "should be able to clone the repository")
require.FileExists(t, tempDir+"/README.md", "README.md should exist in the cloned repository")

out, err := execCmd("git", "-C", tempDir, "rev-parse", "HEAD")
require.NoError(t, err, "should be able to get the HEAD commit")
require.NotEmpty(t, out, "HEAD commit should not be empty")

latestCommit := s.GetLatestCommitHash(t, "main")
require.Equal(t, strings.TrimSpace(out), latestCommit, "HEAD commit should match the latest commit")
})
}

Expand Down

0 comments on commit bea4330

Please sign in to comment.