aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/test
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-12-01 09:59:19 +0100
committerGitHub <noreply@github.com>2016-12-01 09:59:19 +0100
commitc15bf1dff332873644290db0e186b8f5ad9b8fb2 (patch)
tree1dd79212333823b70f2792ad116864ea127e4a1c /plumbing/transport/test
parent7de79aef5d4aa3100382d4df3e99525f9949e8d1 (diff)
downloadgo-git-c15bf1dff332873644290db0e186b8f5ad9b8fb2.tar.gz
capabilities: full integration (#151)
* format/pktline: fix readPayloadLen err handling * protocol/pakp: UploadReq validation and creation of capabilities * protocol/pakp: AdvRef tests * protocol/pakp: capability.List.Delete * protocol: filter unsupported capabilities * remote capability negociation * transport: UploadRequest validation * requested changes
Diffstat (limited to 'plumbing/transport/test')
-rw-r--r--plumbing/transport/test/common.go40
1 files changed, 32 insertions, 8 deletions
diff --git a/plumbing/transport/test/common.go b/plumbing/transport/test/common.go
index ed2e141..3b7f05f 100644
--- a/plumbing/transport/test/common.go
+++ b/plumbing/transport/test/common.go
@@ -43,7 +43,7 @@ func (s *FetchPackSuite) TestInfoNotExists(c *C) {
r, err = s.Client.NewFetchPackSession(s.NonExistentEndpoint)
c.Assert(err, IsNil)
req := packp.NewUploadPackRequest()
- req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
+ req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
reader, err := r.FetchPack(req)
c.Assert(err, Equals, transport.ErrRepositoryNotFound)
c.Assert(reader, IsNil)
@@ -70,6 +70,16 @@ func (s *FetchPackSuite) TestDefaultBranch(c *C) {
c.Assert(symrefs[0], Equals, "HEAD:refs/heads/master")
}
+func (s *FetchPackSuite) TestAdvertisedReferencesFilterUnsupported(c *C) {
+ r, err := s.Client.NewFetchPackSession(s.Endpoint)
+ c.Assert(err, IsNil)
+ defer func() { c.Assert(r.Close(), IsNil) }()
+
+ info, err := r.AdvertisedReferences()
+ c.Assert(err, IsNil)
+ c.Assert(info.Capabilities.Supports(capability.MultiACK), Equals, false)
+}
+
func (s *FetchPackSuite) TestCapabilities(c *C) {
r, err := s.Client.NewFetchPackSession(s.Endpoint)
c.Assert(err, IsNil)
@@ -90,7 +100,7 @@ func (s *FetchPackSuite) TestFullFetchPack(c *C) {
c.Assert(info, NotNil)
req := packp.NewUploadPackRequest()
- req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
+ req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
reader, err := r.FetchPack(req)
c.Assert(err, IsNil)
@@ -104,7 +114,7 @@ func (s *FetchPackSuite) TestFetchPack(c *C) {
defer func() { c.Assert(r.Close(), IsNil) }()
req := packp.NewUploadPackRequest()
- req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
+ req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
reader, err := r.FetchPack(req)
c.Assert(err, IsNil)
@@ -112,14 +122,28 @@ func (s *FetchPackSuite) TestFetchPack(c *C) {
s.checkObjectNumber(c, reader, 28)
}
+func (s *FetchPackSuite) TestFetchPackInvalidReq(c *C) {
+ r, err := s.Client.NewFetchPackSession(s.Endpoint)
+ c.Assert(err, IsNil)
+ defer func() { c.Assert(r.Close(), IsNil) }()
+
+ req := packp.NewUploadPackRequest()
+ req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
+ req.Capabilities.Set(capability.Sideband)
+ req.Capabilities.Set(capability.Sideband64k)
+
+ _, err = r.FetchPack(req)
+ c.Assert(err, NotNil)
+}
+
func (s *FetchPackSuite) TestFetchPackNoChanges(c *C) {
r, err := s.Client.NewFetchPackSession(s.Endpoint)
c.Assert(err, IsNil)
defer func() { c.Assert(r.Close(), IsNil) }()
req := packp.NewUploadPackRequest()
- req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
- req.Have(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
+ req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
+ req.Haves = append(req.Haves, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
reader, err := r.FetchPack(req)
c.Assert(err, Equals, transport.ErrEmptyUploadPackRequest)
@@ -132,8 +156,8 @@ func (s *FetchPackSuite) TestFetchPackMulti(c *C) {
defer func() { c.Assert(r.Close(), IsNil) }()
req := packp.NewUploadPackRequest()
- req.Want(plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
- req.Want(plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881"))
+ req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5"))
+ req.Wants = append(req.Wants, plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881"))
reader, err := r.FetchPack(req)
c.Assert(err, IsNil)
@@ -146,7 +170,7 @@ func (s *FetchPackSuite) TestFetchError(c *C) {
c.Assert(err, IsNil)
req := packp.NewUploadPackRequest()
- req.Want(plumbing.NewHash("1111111111111111111111111111111111111111"))
+ req.Wants = append(req.Wants, plumbing.NewHash("1111111111111111111111111111111111111111"))
reader, err := r.FetchPack(req)
c.Assert(err, Equals, transport.ErrEmptyUploadPackRequest)