Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
5058a8f9
Commit
5058a8f9
authored
Aug 02, 2018
by
Jacob Vosmaer
Committed by
Rubén Dávila
Aug 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for GitConfigOptions in PostReceivePack
parent
1313bc17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
18 deletions
+24
-18
gitaly_test.go
gitaly_test.go
+15
-10
internal/testhelper/gitaly.go
internal/testhelper/gitaly.go
+9
-8
No files found.
gitaly_test.go
View file @
5058a8f9
...
...
@@ -141,6 +141,7 @@ func TestPostReceivePackProxiedToGitalySuccessfully(t *testing.T) {
defer
gitalyServer
.
Stop
()
apiResponse
.
GitalyServer
.
Address
=
"unix://"
+
socketPath
apiResponse
.
GitConfigOptions
=
[]
string
{
"git-config-hello=world"
}
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
...
...
@@ -154,22 +155,26 @@ func TestPostReceivePackProxiedToGitalySuccessfully(t *testing.T) {
ws
.
URL
+
resource
,
map
[
string
]
string
{
"Content-Type"
:
"application/x-git-receive-pack-request"
,
"Git-Protocol"
:
"fake Git protocol"
,
"Git-Protocol"
:
gitProtocol
,
},
testhelper
.
GitalyReceivePackResponseMock
,
)
expectedBody
:=
strings
.
Join
([]
string
{
apiResponse
.
Repository
.
StorageName
,
apiResponse
.
Repository
.
RelativePath
,
apiResponse
.
GL_ID
,
apiResponse
.
GL_USERNAME
,
gitProtocol
,
string
(
testhelper
.
GitalyReceivePackResponseMock
),
},
"
\0
00"
)
split
:=
strings
.
SplitN
(
body
,
"
\0
00"
,
2
)
require
.
Len
(
t
,
split
,
2
)
gitalyRequest
:=
&
pb
.
PostReceivePackRequest
{}
require
.
NoError
(
t
,
jsonpb
.
UnmarshalString
(
split
[
0
],
gitalyRequest
))
require
.
Equal
(
t
,
apiResponse
.
Repository
.
StorageName
,
gitalyRequest
.
Repository
.
StorageName
)
require
.
Equal
(
t
,
apiResponse
.
Repository
.
RelativePath
,
gitalyRequest
.
Repository
.
RelativePath
)
require
.
Equal
(
t
,
apiResponse
.
GL_ID
,
gitalyRequest
.
GlId
)
require
.
Equal
(
t
,
apiResponse
.
GL_USERNAME
,
gitalyRequest
.
GlUsername
)
require
.
Equal
(
t
,
apiResponse
.
GitConfigOptions
,
gitalyRequest
.
GitConfigOptions
)
require
.
Equal
(
t
,
gitProtocol
,
gitalyRequest
.
GitProtocol
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"POST %q"
,
resource
)
assert
.
Equal
(
t
,
expectedBody
,
body
,
"POST %q: response body"
,
resource
)
require
.
Equal
(
t
,
string
(
testhelper
.
GitalyReceivePackResponseMock
),
split
[
1
]
)
testhelper
.
AssertResponseHeader
(
t
,
resp
,
"Content-Type"
,
"application/x-git-receive-pack-result"
)
}
...
...
internal/testhelper/gitaly.go
View file @
5058a8f9
...
...
@@ -8,6 +8,7 @@ import (
"strings"
"sync"
"github.com/golang/protobuf/jsonpb"
log
"github.com/sirupsen/logrus"
pb
"gitlab.com/gitlab-org/gitaly-proto/go"
...
...
@@ -119,17 +120,17 @@ func (s *GitalyTestServer) PostReceivePack(stream pb.SmartHTTPService_PostReceiv
}
repo
:=
req
.
GetRepository
()
if
err
:=
validateRepository
(
re
q
.
GetRepository
()
);
err
!=
nil
{
if
err
:=
validateRepository
(
re
po
);
err
!=
nil
{
return
err
}
data
:=
[]
byte
(
strings
.
Join
([]
string
{
repo
.
GetStorageName
(),
repo
.
GetRelativePath
(),
re
q
.
GlId
,
req
.
GlUsername
,
req
.
GitProtocol
,
},
"
\0
00"
)
+
"
\0
00"
)
marshaler
:=
&
jsonpb
.
Marshaler
{}
jsonString
,
err
:=
marshaler
.
MarshalToString
(
req
)
if
err
!=
nil
{
re
turn
err
}
data
:=
[]
byte
(
jsonString
+
"
\0
00"
)
// The body of the request starts in the second message
for
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment