Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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-ce
Commits
2bc7f818
Commit
2bc7f818
authored
Jun 25, 2019
by
Francisco Javier López
Committed by
Nick Thomas
Jun 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added param validation to help method TestAuthServer
parent
fcc5f946
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
15 deletions
+27
-15
authorization_test.go
authorization_test.go
+1
-1
channel_test.go
channel_test.go
+1
-1
gitaly_integration_test.go
gitaly_integration_test.go
+3
-3
gitaly_test.go
gitaly_test.go
+7
-7
main_test.go
main_test.go
+15
-3
No files found.
authorization_test.go
View file @
2bc7f818
...
...
@@ -23,7 +23,7 @@ func okHandler(w http.ResponseWriter, _ *http.Request, _ *api.Response) {
func
runPreAuthorizeHandler
(
t
*
testing
.
T
,
ts
*
httptest
.
Server
,
suffix
string
,
url
*
regexp
.
Regexp
,
apiResponse
interface
{},
returnCode
,
expectedCode
int
)
*
httptest
.
ResponseRecorder
{
if
ts
==
nil
{
ts
=
testAuthServer
(
url
,
returnCode
,
apiResponse
)
ts
=
testAuthServer
(
url
,
nil
,
returnCode
,
apiResponse
)
defer
ts
.
Close
()
}
...
...
channel_test.go
View file @
2bc7f818
...
...
@@ -157,7 +157,7 @@ func wireupChannel(channelPath string, modifier func(*api.Response), subprotocol
if
modifier
!=
nil
{
modifier
(
authResponse
)
}
upstream
:=
testAuthServer
(
nil
,
200
,
authResponse
)
upstream
:=
testAuthServer
(
nil
,
nil
,
200
,
authResponse
)
workhorse
:=
startWorkhorseServer
(
upstream
.
URL
)
return
serverConns
,
websocketURL
(
workhorse
.
URL
,
channelPath
),
func
()
{
...
...
gitaly_integration_test.go
View file @
2bc7f818
...
...
@@ -88,7 +88,7 @@ func TestAllowedClone(t *testing.T) {
require
.
NoError
(
t
,
ensureGitalyRepository
(
t
,
apiResponse
))
// Prepare test server and backend
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
...
...
@@ -112,7 +112,7 @@ func TestAllowedShallowClone(t *testing.T) {
require
.
NoError
(
t
,
ensureGitalyRepository
(
t
,
apiResponse
))
// Prepare test server and backend
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
...
...
@@ -136,7 +136,7 @@ func TestAllowedPush(t *testing.T) {
require
.
NoError
(
t
,
ensureGitalyRepository
(
t
,
apiResponse
))
// Prepare the test server and backend
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
...
...
gitaly_test.go
View file @
2bc7f818
...
...
@@ -43,7 +43,7 @@ func TestFailedCloneNoGitaly(t *testing.T) {
}
// Prepare test server and backend
ts
:=
testAuthServer
(
nil
,
200
,
authBody
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
authBody
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
...
...
@@ -78,7 +78,7 @@ func TestGetInfoRefsProxiedToGitalySuccessfully(t *testing.T) {
t
.
Run
(
fmt
.
Sprintf
(
"ShowAllRefs=%v,gitRpc=%v"
,
tc
.
showAllRefs
,
tc
.
gitRpc
),
func
(
t
*
testing
.
T
)
{
apiResponse
.
ShowAllRefs
=
tc
.
showAllRefs
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
...
...
@@ -118,7 +118,7 @@ func TestGetInfoRefsProxiedToGitalyInterruptedStream(t *testing.T) {
gitalyAddress
:=
"unix:"
+
socketPath
apiResponse
.
GitalyServer
.
Address
=
gitalyAddress
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
...
...
@@ -153,7 +153,7 @@ func TestPostReceivePackProxiedToGitalySuccessfully(t *testing.T) {
apiResponse
.
GitalyServer
.
Address
=
"unix:"
+
socketPath
apiResponse
.
GitConfigOptions
=
[]
string
{
"git-config-hello=world"
}
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
...
...
@@ -196,7 +196,7 @@ func TestPostReceivePackProxiedToGitalyInterrupted(t *testing.T) {
defer
gitalyServer
.
Stop
()
apiResponse
.
GitalyServer
.
Address
=
"unix:"
+
socketPath
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
...
...
@@ -246,7 +246,7 @@ func TestPostUploadPackProxiedToGitalySuccessfully(t *testing.T) {
defer
gitalyServer
.
Stop
()
apiResponse
.
GitalyServer
.
Address
=
"unix:"
+
socketPath
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
...
...
@@ -295,7 +295,7 @@ func TestPostUploadPackProxiedToGitalyInterrupted(t *testing.T) {
defer
gitalyServer
.
Stop
()
apiResponse
.
GitalyServer
.
Address
=
"unix:"
+
socketPath
ts
:=
testAuthServer
(
nil
,
200
,
apiResponse
)
ts
:=
testAuthServer
(
nil
,
nil
,
200
,
apiResponse
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
...
...
main_test.go
View file @
2bc7f818
...
...
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"os"
"os/exec"
"path"
...
...
@@ -59,7 +60,7 @@ func TestDeniedClone(t *testing.T) {
require
.
NoError
(
t
,
os
.
RemoveAll
(
scratchDir
))
// Prepare test server and backend
ts
:=
testAuthServer
(
nil
,
403
,
"Access denied"
)
ts
:=
testAuthServer
(
nil
,
nil
,
403
,
"Access denied"
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
...
...
@@ -73,7 +74,7 @@ func TestDeniedClone(t *testing.T) {
func
TestDeniedPush
(
t
*
testing
.
T
)
{
// Prepare the test server and backend
ts
:=
testAuthServer
(
nil
,
403
,
"Access denied"
)
ts
:=
testAuthServer
(
nil
,
nil
,
403
,
"Access denied"
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
...
...
@@ -491,10 +492,21 @@ func newBranch() string {
return
fmt
.
Sprintf
(
"branch-%d"
,
time
.
Now
()
.
UnixNano
())
}
func
testAuthServer
(
url
*
regexp
.
Regexp
,
code
int
,
body
interface
{})
*
httptest
.
Server
{
func
testAuthServer
(
url
*
regexp
.
Regexp
,
params
url
.
Values
,
code
int
,
body
interface
{})
*
httptest
.
Server
{
return
testhelper
.
TestServerWithHandler
(
url
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Content-Type"
,
api
.
ResponseContentType
)
if
params
!=
nil
{
currentParams
:=
r
.
URL
.
Query
()
for
key
:=
range
params
{
if
currentParams
.
Get
(
key
)
!=
params
.
Get
(
key
)
{
log
.
Println
(
"UPSTREAM"
,
r
.
Method
,
r
.
URL
,
"DENY"
,
"invalid auth server params"
)
w
.
WriteHeader
(
http
.
StatusForbidden
)
return
}
}
}
// Write pure string
if
data
,
ok
:=
body
.
(
string
);
ok
{
log
.
Println
(
"UPSTREAM"
,
r
.
Method
,
r
.
URL
,
code
)
...
...
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