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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
bd30f068
Commit
bd30f068
authored
Jan 06, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove some repetition from tests
parent
13097a93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
main_test.go
main_test.go
+7
-5
No files found.
main_test.go
View file @
bd30f068
...
@@ -328,7 +328,8 @@ func TestAllowedStaticFile(t *testing.T) {
...
@@ -328,7 +328,8 @@ func TestAllowedStaticFile(t *testing.T) {
}
}
func
TestAllowedPublicUploadsFile
(
t
*
testing
.
T
)
{
func
TestAllowedPublicUploadsFile
(
t
*
testing
.
T
)
{
if
err
:=
setupStaticFile
(
"uploads/static file.txt"
,
"PRIVATE"
);
err
!=
nil
{
content
:=
"PRIVATE but allowed"
if
err
:=
setupStaticFile
(
"uploads/static file.txt"
,
content
);
err
!=
nil
{
t
.
Fatalf
(
"create public/uploads/static file.txt: %v"
,
err
)
t
.
Fatalf
(
"create public/uploads/static file.txt: %v"
,
err
)
}
}
...
@@ -355,8 +356,8 @@ func TestAllowedPublicUploadsFile(t *testing.T) {
...
@@ -355,8 +356,8 @@ func TestAllowedPublicUploadsFile(t *testing.T) {
if
_
,
err
:=
io
.
Copy
(
buf
,
resp
.
Body
);
err
!=
nil
{
if
_
,
err
:=
io
.
Copy
(
buf
,
resp
.
Body
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
buf
.
String
()
!=
"PRIVATE"
{
if
buf
.
String
()
!=
content
{
t
.
Fatalf
(
"GET %q: Expected
PRIVATE, got %q"
,
resource
,
buf
.
String
())
t
.
Fatalf
(
"GET %q: Expected
%q, got %q"
,
resource
,
content
,
buf
.
String
())
}
}
if
resp
.
StatusCode
!=
200
{
if
resp
.
StatusCode
!=
200
{
t
.
Fatalf
(
"GET %q: expected 200, got %d"
,
resource
,
resp
.
StatusCode
)
t
.
Fatalf
(
"GET %q: expected 200, got %d"
,
resource
,
resp
.
StatusCode
)
...
@@ -368,7 +369,8 @@ func TestAllowedPublicUploadsFile(t *testing.T) {
...
@@ -368,7 +369,8 @@ func TestAllowedPublicUploadsFile(t *testing.T) {
}
}
func
TestDeniedPublicUploadsFile
(
t
*
testing
.
T
)
{
func
TestDeniedPublicUploadsFile
(
t
*
testing
.
T
)
{
if
err
:=
setupStaticFile
(
"uploads/static.txt"
,
"PRIVATE"
);
err
!=
nil
{
content
:=
"PRIVATE"
if
err
:=
setupStaticFile
(
"uploads/static.txt"
,
content
);
err
!=
nil
{
t
.
Fatalf
(
"create public/uploads/static.txt: %v"
,
err
)
t
.
Fatalf
(
"create public/uploads/static.txt: %v"
,
err
)
}
}
...
@@ -394,7 +396,7 @@ func TestDeniedPublicUploadsFile(t *testing.T) {
...
@@ -394,7 +396,7 @@ func TestDeniedPublicUploadsFile(t *testing.T) {
if
_
,
err
:=
io
.
Copy
(
buf
,
resp
.
Body
);
err
!=
nil
{
if
_
,
err
:=
io
.
Copy
(
buf
,
resp
.
Body
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
buf
.
String
()
==
"PRIVATE"
{
if
buf
.
String
()
==
content
{
t
.
Fatalf
(
"GET %q: Got private file contents which should have been blocked by upstream"
,
resource
)
t
.
Fatalf
(
"GET %q: Got private file contents which should have been blocked by upstream"
,
resource
)
}
}
if
resp
.
StatusCode
!=
404
{
if
resp
.
StatusCode
!=
404
{
...
...
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