示例#1
0
func (s *SuiteCommon) TestNewGitUploadPackServiceHTTP(c *C) {
	e, err := common.NewEndpoint("http://github.com/src-d/go-git")
	c.Assert(err, IsNil)

	output, err := NewGitUploadPackService(e)
	c.Assert(err, IsNil)
	c.Assert(typeAsString(output), Equals, "*http.GitUploadPackService")

	e, err = common.NewEndpoint("https://github.com/src-d/go-git")
	c.Assert(err, IsNil)

	output, err = NewGitUploadPackService(e)
	c.Assert(err, IsNil)
	c.Assert(typeAsString(output), Equals, "*http.GitUploadPackService")
}
示例#2
0
func (s *SuiteCommon) TestNewGitUploadPackServiceUnknown(c *C) {
	e, err := common.NewEndpoint("unknown://github.com/src-d/go-git")
	c.Assert(err, IsNil)

	_, err = NewGitUploadPackService(e)
	c.Assert(err, NotNil)
}
示例#3
0
func (s *RemoteSuite) TestInfoNotExists(c *C) {
	endpoint, _ := common.NewEndpoint("https://github.com/git-fixture/not-exists")
	r := NewGitUploadPackService(endpoint)
	c.Assert(r.Connect(), IsNil)

	info, err := r.Info()
	c.Assert(err, Equals, common.ErrAuthorizationRequired)
	c.Assert(info, IsNil)
}
示例#4
0
func (s *FetcherSuite) TestVersions(c *C) {
	pkg := &Package{}
	pkg.Repository, _ = common.NewEndpoint("https://github.com/git-fixtures/basic")

	f := NewFetcher(pkg, nil)
	versions, err := f.Versions()
	c.Assert(err, IsNil)
	c.Assert(versions, HasLen, 2)
}
示例#5
0
func (s *RemoteSuite) TestNewGitUploadPackServiceAuth(c *C) {
	e, err := common.NewEndpoint("https://*****:*****@github.com/git-fixtures/basic")
	c.Assert(err, IsNil)

	r := NewGitUploadPackService(e)
	auth := r.(*GitUploadPackService).auth

	c.Assert(auth.String(), Equals, "http-basic-auth - foo:*******")
}
示例#6
0
func (s *RemoteSuite) SetUpSuite(c *C) {
	var err error
	s.Endpoint, err = common.NewEndpoint("[email protected]:git-fixtures/basic.git")
	c.Assert(err, IsNil)

	if os.Getenv("SSH_AUTH_SOCK") == "" {
		c.Skip("SSH_AUTH_SOCK is not set")
	}
}
示例#7
0
文件: proxy.go 项目: mcuadros/gop.kg
func (s *Server) buildEndpoint(server, orgnization, repository string) common.Endpoint {
	e, err := common.NewEndpoint(fmt.Sprintf(
		"https://%s/%s/%s", server, orgnization, repository,
	))

	if err != nil {
		panic(fmt.Sprintf("unreachable: %s", err.Error()))
	}

	return e
}
示例#8
0
func (s *RemoteSuite) TestNewGitUploadPackServiceFactory(c *C) {
	e, err := common.NewEndpoint("https://*****:*****@github.com/git-fixtures/basic")
	c.Assert(err, IsNil)

	roundTripper := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
	client := &http.Client{Transport: roundTripper}
	r := NewGitUploadPackServiceFactory(client)(e).(*GitUploadPackService)

	c.Assert(r.auth.String(), Equals, "http-basic-auth - foo:*******")
	c.Assert(r.client.Transport, Equals, roundTripper)
}
示例#9
0
func (r *Remote) connectUploadPackService() error {
	endpoint, err := common.NewEndpoint(r.c.URL)
	if err != nil {
		return err
	}

	r.upSrv, err = clients.NewGitUploadPackService(endpoint)
	if err != nil {
		return err
	}

	return r.upSrv.Connect()
}
示例#10
0
func (s *FetcherSuite) TestFetch(c *C) {
	pkg := &Package{}
	pkg.Repository, _ = common.NewEndpoint("https://github.com/git-fixtures/basic")

	f := NewFetcher(pkg, nil)

	ref := plumbing.NewReferenceFromStrings("foo", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")

	buf := bytes.NewBuffer(nil)
	n, err := f.Fetch(buf, ref)
	c.Assert(err, IsNil)
	c.Assert(n, Equals, int64(85374))
	c.Assert(buf.Len(), Equals, 85374)
}
示例#11
0
func (s *RemoteSuite) SetUpSuite(c *C) {
	var err error
	s.Endpoint, err = common.NewEndpoint("https://github.com/git-fixtures/basic")
	c.Assert(err, IsNil)
}