예제 #1
0
func (s *SuiteRemote) TestDisconnect(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	c.Assert(r.Disconnect(), IsNil)
	c.Assert(r.connected, Equals, false)
}
예제 #2
0
func (s *SuiteRemote) TestConnectWithPublicKeysCallback(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService()
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()
	c.Assert(r.connected, Equals, true)
	c.Assert(r.auth, Equals, agent.auth)
}
예제 #3
0
func (s *SuiteRemote) TestCapabilities(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()

	info, err := r.Info()
	c.Assert(err, IsNil)
	c.Assert(info.Capabilities.Get("agent").Values, HasLen, 1)
}
예제 #4
0
func (s *SuiteRemote) TestDefaultBranch(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()

	info, err := r.Info()
	c.Assert(err, IsNil)
	c.Assert(info.Capabilities.SymbolicReference("HEAD"), Equals, "refs/heads/master")
}
예제 #5
0
func (s *SuiteRemote) TestFetch(c *C) {
	agent, err := newSSHAgentConn()
	c.Assert(err, IsNil)
	defer func() { c.Assert(agent.close(), IsNil) }()

	r := NewGitUploadPackService(fixRepo)
	c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil)
	defer func() { c.Assert(r.Disconnect(), IsNil) }()

	pr := &common.GitUploadPackRequest{}
	pr.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
	reader, err := r.Fetch(pr)
	c.Assert(err, IsNil)

	b, err := ioutil.ReadAll(reader)
	c.Assert(err, IsNil)
	c.Assert(b, HasLen, 85374)
}