Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
0
Merge Requests
0
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-shell
Commits
650ecad9
Commit
650ecad9
authored
Sep 30, 2019
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up files
parent
9304b1d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
5 deletions
+34
-5
go/internal/config/config.go
go/internal/config/config.go
+1
-3
go/internal/gitlabnet/client_test.go
go/internal/gitlabnet/client_test.go
+28
-0
go/internal/sshenv/sshenv_test.go
go/internal/sshenv/sshenv_test.go
+4
-1
support/go-test
support/go-test
+1
-1
No files found.
go/internal/config/config.go
View file @
650ecad9
...
...
@@ -51,9 +51,7 @@ func NewFromDir(dir string) (*Config, error) {
}
func
newFromFile
(
filename
string
)
(
*
Config
,
error
)
{
cfg
:=
&
Config
{
RootDir
:
path
.
Dir
(
filename
),
}
cfg
:=
&
Config
{
RootDir
:
path
.
Dir
(
filename
)}
configBytes
,
err
:=
ioutil
.
ReadFile
(
filename
)
if
err
!=
nil
{
...
...
go/internal/gitlabnet/client_test.go
View file @
650ecad9
...
...
@@ -57,6 +57,13 @@ func TestClients(t *testing.T) {
require
.
Equal
(
t
,
"127.0.0.1"
,
header
)
},
},
{
Path
:
"/api/v4/internal/with_empty_ip"
,
Handler
:
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
header
:=
r
.
Header
.
Get
(
"X-Forwarded-For"
)
require
.
Equal
(
t
,
""
,
header
)
},
},
{
Path
:
"/api/v4/internal/error"
,
Handler
:
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
@@ -107,6 +114,7 @@ func TestClients(t *testing.T) {
tc
.
config
.
GitlabUrl
=
url
tc
.
config
.
Secret
=
"sssh, it's a secret"
client
,
err
:=
GetClient
(
tc
.
config
)
require
.
NoError
(
t
,
err
)
...
...
@@ -117,6 +125,7 @@ func TestClients(t *testing.T) {
testErrorMessage
(
t
,
client
)
testAuthenticationHeader
(
t
,
client
)
testXForwardedForHeader
(
t
,
client
)
testEmptyForwardedForHeader
(
t
,
client
)
})
}
}
...
...
@@ -251,3 +260,22 @@ func testXForwardedForHeader(t *testing.T, client *GitlabClient) {
response
.
Body
.
Close
()
})
}
func
testEmptyForwardedForHeader
(
t
*
testing
.
T
,
client
*
GitlabClient
)
{
t
.
Run
(
"X-Forwarded-For empty for GET"
,
func
(
t
*
testing
.
T
)
{
response
,
err
:=
client
.
Get
(
"/with_empty_ip"
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
response
)
response
.
Body
.
Close
()
})
t
.
Run
(
"X-Forwarded-For empty for POST"
,
func
(
t
*
testing
.
T
)
{
data
:=
map
[
string
]
string
{
"key"
:
"value"
}
response
,
err
:=
client
.
Post
(
"/with_empty_ip"
,
data
)
require
.
NoError
(
t
,
err
)
require
.
NotNil
(
t
,
response
)
response
.
Body
.
Close
()
})
}
go/internal/sshenv/sshenv_test.go
View file @
650ecad9
...
...
@@ -12,6 +12,9 @@ func TestLocalAddr(t *testing.T) {
require
.
NoError
(
t
,
err
)
defer
cleanup
()
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
LocalAddr
(),
"127.0.0.1"
)
}
func
TestEmptyLocalAddr
(
t
*
testing
.
T
)
{
require
.
Equal
(
t
,
LocalAddr
(),
""
)
}
support/go-test
View file @
650ecad9
...
...
@@ -5,7 +5,7 @@ include GoBuild
def
main
ensure_build_dir_exists
run!
(
GO_ENV
,
%w[go test
-v
./...]
,
chdir:
GO_DIR
)
run!
(
GO_ENV
,
%w[go test ./...]
,
chdir:
GO_DIR
)
puts
'OK'
end
...
...
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