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
71f620be
Commit
71f620be
authored
Dec 09, 2015
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9ed9b81e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
main_test.go
main_test.go
+8
-7
No files found.
main_test.go
View file @
71f620be
...
@@ -460,6 +460,7 @@ func sha1s(data []byte) string {
...
@@ -460,6 +460,7 @@ func sha1s(data []byte) string {
return
fmt
.
Sprintf
(
"%x"
,
sha1
.
Sum
(
data
))
return
fmt
.
Sprintf
(
"%x"
,
sha1
.
Sum
(
data
))
}
}
// download an URL
func
download
(
t
*
testing
.
T
,
url
string
,
h
http
.
Header
)
(
*
http
.
Response
,
[]
byte
)
{
func
download
(
t
*
testing
.
T
,
url
string
,
h
http
.
Header
)
(
*
http
.
Response
,
[]
byte
)
{
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -489,18 +490,18 @@ type DownloadContext struct {
...
@@ -489,18 +490,18 @@ type DownloadContext struct {
Header
http
.
Header
Header
http
.
Header
}
}
func
DownloadContextNew
(
t
*
testing
.
T
,
urlPrefix
string
)
*
DownloadContext
{
func
NewDownloadContext
(
t
*
testing
.
T
,
urlPrefix
string
)
*
DownloadContext
{
h
:=
make
(
http
.
Header
)
h
:=
make
(
http
.
Header
)
return
&
DownloadContext
{
t
,
urlPrefix
,
h
}
return
&
DownloadContext
{
t
,
urlPrefix
,
h
}
}
}
func
(
dl
DownloadContext
)
download
Raw
(
path
string
)
(
*
http
.
Response
,
[]
byte
)
{
func
(
dl
DownloadContext
)
download
(
path
string
)
(
*
http
.
Response
,
[]
byte
)
{
return
download
(
dl
.
t
,
dl
.
urlPrefix
+
path
,
dl
.
Header
)
return
download
(
dl
.
t
,
dl
.
urlPrefix
+
path
,
dl
.
Header
)
}
}
// download `path` and expect content sha1 to be `expectSha1`
// download `path` and expect content sha1 to be `expectSha1`
func
(
dl
DownloadContext
)
ExpectSha1
(
path
,
expectSha1
string
)
{
func
(
dl
DownloadContext
)
ExpectSha1
(
path
,
expectSha1
string
)
{
resp
,
out
:=
dl
.
download
Raw
(
path
)
resp
,
out
:=
dl
.
download
(
path
)
if
resp
.
StatusCode
!=
200
{
if
resp
.
StatusCode
!=
200
{
dl
.
t
.
Fatalf
(
"Unexpected status code (expected 200, got %v)"
,
resp
.
StatusCode
)
dl
.
t
.
Fatalf
(
"Unexpected status code (expected 200, got %v)"
,
resp
.
StatusCode
)
}
}
...
@@ -517,7 +518,7 @@ func (dl DownloadContext) Expect(path, expect string) {
...
@@ -517,7 +518,7 @@ func (dl DownloadContext) Expect(path, expect string) {
// download `path` and expect HTTP status code to be `code`
// download `path` and expect HTTP status code to be `code`
func
(
dl
DownloadContext
)
ExpectCode
(
path
string
,
code
int
)
{
func
(
dl
DownloadContext
)
ExpectCode
(
path
string
,
code
int
)
{
resp
,
_
:=
dl
.
download
Raw
(
path
)
resp
,
_
:=
dl
.
download
(
path
)
if
resp
.
StatusCode
!=
code
{
if
resp
.
StatusCode
!=
code
{
dl
.
t
.
Fatalf
(
"Unexpected status code (expected %v, got %v)"
,
code
,
resp
.
StatusCode
)
dl
.
t
.
Fatalf
(
"Unexpected status code (expected %v, got %v)"
,
code
,
resp
.
StatusCode
)
}
}
...
@@ -529,7 +530,7 @@ func TestBlobDownload(t *testing.T) {
...
@@ -529,7 +530,7 @@ func TestBlobDownload(t *testing.T) {
defer
ts
.
Close
()
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
defer
ws
.
Close
()
dl
:=
DownloadContextNew
(
t
,
fmt
.
Sprintf
(
"%s/%s/raw"
,
ws
.
URL
,
testProject
))
dl
:=
NewDownloadContext
(
t
,
fmt
.
Sprintf
(
"%s/%s/raw"
,
ws
.
URL
,
testProject
))
dl
.
Expect
(
"/5f923865/README.md"
,
"testme
\n
======
\n\n
Sample repo for testing gitlab features
\n
"
)
dl
.
Expect
(
"/5f923865/README.md"
,
"testme
\n
======
\n\n
Sample repo for testing gitlab features
\n
"
)
dl
.
ExpectSha1
(
"/5f923865/README.md"
,
"5f7af35c185a9e5face2f4afb6d7c4f00328d04c"
)
dl
.
ExpectSha1
(
"/5f923865/README.md"
,
"5f7af35c185a9e5face2f4afb6d7c4f00328d04c"
)
...
@@ -544,7 +545,7 @@ func TestDeniedBlobDownload(t *testing.T) {
...
@@ -544,7 +545,7 @@ func TestDeniedBlobDownload(t *testing.T) {
defer
ts
.
Close
()
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
defer
ws
.
Close
()
dl
:=
DownloadContextNew
(
t
,
fmt
.
Sprintf
(
"%s/%s/raw"
,
ws
.
URL
,
testProject
))
dl
:=
NewDownloadContext
(
t
,
fmt
.
Sprintf
(
"%s/%s/raw"
,
ws
.
URL
,
testProject
))
dl
.
ExpectCode
(
"/5f923865/README.md"
,
403
)
dl
.
ExpectCode
(
"/5f923865/README.md"
,
403
)
dl
.
ExpectCode
(
"/5f923865/files/ruby/popen.rb"
,
403
)
dl
.
ExpectCode
(
"/5f923865/files/ruby/popen.rb"
,
403
)
...
@@ -576,7 +577,7 @@ func TestPrivateBlobDownload(t *testing.T) {
...
@@ -576,7 +577,7 @@ func TestPrivateBlobDownload(t *testing.T) {
defer
ts
.
Close
()
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
defer
ws
.
Close
()
dl
:=
DownloadContextNew
(
t
,
fmt
.
Sprintf
(
"%s/%s/raw"
,
ws
.
URL
,
testProject
))
dl
:=
NewDownloadContext
(
t
,
fmt
.
Sprintf
(
"%s/%s/raw"
,
ws
.
URL
,
testProject
))
dl
.
ExpectCode
(
"/5f923865/README.md"
,
403
)
dl
.
ExpectCode
(
"/5f923865/README.md"
,
403
)
dl
.
ExpectCode
(
"/5f923865/README.md?bbb_token=TOKEN-4BBB"
,
403
)
dl
.
ExpectCode
(
"/5f923865/README.md?bbb_token=TOKEN-4BBB"
,
403
)
...
...
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