summaryrefslogtreecommitdiff
path: root/remote_test.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2014-10-15 15:43:02 +0200
committerCarlos Martín Nieto <[email protected]>2014-10-15 15:56:59 +0200
commit17a9214307250b5fd2769385c73b723d55a26dab (patch)
tree474e1f510abd0e1a93d3e7e227219db301c382c2 /remote_test.go
parent5eda8d6935d6d2b0db9bf3264832e575701696ff (diff)
Update to libgit2 master
The option to ignore the server's certificate has been removed, replaced witha callback for the user to perform their own checking. Remote.Fetch() now performs opportunistic updates and takes a list of refspecs to use as the active set for a particular fetch.
Diffstat (limited to 'remote_test.go')
-rw-r--r--remote_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go
index 7cef1ec..8021f71 100644
--- a/remote_test.go
+++ b/remote_test.go
@@ -1,6 +1,8 @@
package git
import (
+ "fmt"
+ "crypto/x509"
"os"
"testing"
)
@@ -45,3 +47,35 @@ func TestListRemotes(t *testing.T) {
compareStringList(t, expected, actual)
}
+
+
+func assertHostname(cert *x509.Certificate, valid bool, hostname string, t *testing.T) int {
+ fmt.Println("hostname", hostname)
+ if hostname != "github.com" {
+ t.Fatal("Hostname does not match")
+ return ErrUser
+ }
+
+ return 0
+}
+
+func TestCertificateCheck(t *testing.T) {
+ repo := createTestRepo(t)
+ defer os.RemoveAll(repo.Workdir())
+ defer repo.Free()
+
+ remote, err := repo.CreateRemote("origin", "https://github.com/libgit2/TestGitRepository")
+ checkFatal(t, err)
+
+ callbacks := RemoteCallbacks{
+ CertificateCheckCallback: func (cert *x509.Certificate, valid bool, hostname string) int {
+ return assertHostname(cert, valid, hostname, t)
+ },
+ }
+
+ err = remote.SetCallbacks(&callbacks)
+ checkFatal(t, err)
+ err = remote.Fetch([]string{}, nil, "")
+ checkFatal(t, err)
+ fmt.Println("after Fetch()")
+}