Skip to content

Commit 6a40770

Browse files
author
Paulo Gomes
committed
libgit2: remove redundant test
Both libgit2 and go-git now have tests that confirms support for the supported authentication algorithms. This test was created previously and is no longer needed. Signed-off-by: Paulo Gomes <[email protected]>
1 parent e180b3c commit 6a40770

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

pkg/git/libgit2/checkout_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,13 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"net/url"
2423
"os"
2524
"path/filepath"
2625
"testing"
2726
"time"
2827

2928
git2go "github.com/libgit2/git2go/v33"
3029
. "github.com/onsi/gomega"
31-
corev1 "k8s.io/api/core/v1"
32-
33-
"github.com/fluxcd/pkg/gittestserver"
34-
"github.com/fluxcd/pkg/ssh"
35-
36-
"github.com/fluxcd/source-controller/pkg/git"
3730
)
3831

3932
func TestCheckoutBranch_Checkout(t *testing.T) {
@@ -517,67 +510,3 @@ func mockSignature(time time.Time) *git2go.Signature {
517510
When: time,
518511
}
519512
}
520-
521-
// This test is specifically to detect regression in libgit2's ED25519 key
522-
// support for client authentication.
523-
// Refer: https://github.com/fluxcd/source-controller/issues/399
524-
func TestCheckout_ED25519(t *testing.T) {
525-
g := NewWithT(t)
526-
timeout := 5 * time.Second
527-
528-
// Create a git test server.
529-
server, err := gittestserver.NewTempGitServer()
530-
g.Expect(err).ToNot(HaveOccurred())
531-
defer os.RemoveAll(server.Root())
532-
server.Auth("test-user", "test-pswd")
533-
server.AutoCreate()
534-
535-
server.KeyDir(filepath.Join(server.Root(), "keys"))
536-
g.Expect(server.ListenSSH()).To(Succeed())
537-
538-
go func() {
539-
server.StartSSH()
540-
}()
541-
defer server.StopSSH()
542-
543-
repoPath := "test.git"
544-
545-
err = server.InitRepo(testRepositoryPath, git.DefaultBranch, repoPath)
546-
g.Expect(err).NotTo(HaveOccurred())
547-
548-
sshURL := server.SSHAddress()
549-
repoURL := sshURL + "/" + repoPath
550-
551-
// Fetch host key.
552-
u, err := url.Parse(sshURL)
553-
g.Expect(err).NotTo(HaveOccurred())
554-
g.Expect(u.Host).ToNot(BeEmpty())
555-
knownHosts, err := ssh.ScanHostKey(u.Host, timeout, git.HostKeyAlgos)
556-
g.Expect(err).ToNot(HaveOccurred())
557-
558-
kp, err := ssh.NewEd25519Generator().Generate()
559-
g.Expect(err).ToNot(HaveOccurred())
560-
561-
secret := corev1.Secret{
562-
Data: map[string][]byte{
563-
"identity": kp.PrivateKey,
564-
"known_hosts": knownHosts,
565-
},
566-
}
567-
568-
authOpts, err := git.AuthOptionsFromSecret(repoURL, &secret)
569-
g.Expect(err).ToNot(HaveOccurred())
570-
571-
// Prepare for checkout.
572-
branchCheckoutStrat := &CheckoutBranch{Branch: git.DefaultBranch}
573-
tmpDir := t.TempDir()
574-
575-
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
576-
defer cancel()
577-
578-
// Checkout the repo.
579-
// This should always fail because the generated key above isn't present in
580-
// the git server.
581-
_, err = branchCheckoutStrat.Checkout(ctx, tmpDir, repoURL, authOpts)
582-
g.Expect(err).ToNot(HaveOccurred())
583-
}

0 commit comments

Comments
 (0)