Exemplo n.º 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")
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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:*******")
}
Exemplo n.º 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")
	}
}
Exemplo n.º 7
0
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
}
Exemplo n.º 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)
}
Exemplo n.º 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()
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}