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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
0f8fe93c
Commit
0f8fe93c
authored
Mar 24, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Whitespace, remove unused method
parent
31bc876b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
spec/requests/git_http_spec.rb
spec/requests/git_http_spec.rb
+10
-14
No files found.
spec/requests/git_http_spec.rb
View file @
0f8fe93c
...
@@ -40,7 +40,7 @@ describe 'Git HTTP requests', lib: true do
...
@@ -40,7 +40,7 @@ describe 'Git HTTP requests', lib: true do
download
(
"/
#{
wiki
.
repository
.
path_with_namespace
}
.git"
)
do
|
response
|
download
(
"/
#{
wiki
.
repository
.
path_with_namespace
}
.git"
)
do
|
response
|
json_body
=
ActiveSupport
::
JSON
.
decode
(
response
.
body
)
json_body
=
ActiveSupport
::
JSON
.
decode
(
response
.
body
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_body
[
'RepoPath'
]).
to
include
(
wiki
.
repository
.
path_with_namespace
)
expect
(
json_body
[
'RepoPath'
]).
to
include
(
wiki
.
repository
.
path_with_namespace
)
end
end
...
@@ -75,7 +75,7 @@ describe 'Git HTTP requests', lib: true do
...
@@ -75,7 +75,7 @@ describe 'Git HTTP requests', lib: true do
context
"when username and password are provided"
do
context
"when username and password are provided"
do
let
(
:env
)
{
{
user:
user
.
username
,
password:
'nope'
}
}
let
(
:env
)
{
{
user:
user
.
username
,
password:
'nope'
}
}
context
"when authentication fails"
do
context
"when authentication fails"
do
it
"responds with status 401"
do
it
"responds with status 401"
do
download
(
path
,
env
)
do
|
response
|
download
(
path
,
env
)
do
|
response
|
...
@@ -87,9 +87,9 @@ describe 'Git HTTP requests', lib: true do
...
@@ -87,9 +87,9 @@ describe 'Git HTTP requests', lib: true do
it
"responds with status 401"
do
it
"responds with status 401"
do
expect
(
Rack
::
Attack
::
Allow2Ban
).
to
receive
(
:filter
).
and_return
(
true
)
expect
(
Rack
::
Attack
::
Allow2Ban
).
to
receive
(
:filter
).
and_return
(
true
)
allow_any_instance_of
(
Rack
::
Request
).
to
receive
(
:ip
).
and_return
(
'1.2.3.4'
)
allow_any_instance_of
(
Rack
::
Request
).
to
receive
(
:ip
).
and_return
(
'1.2.3.4'
)
clone_get
(
path
,
env
)
clone_get
(
path
,
env
)
expect
(
response
.
status
).
to
eq
(
401
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
end
...
@@ -97,7 +97,7 @@ describe 'Git HTTP requests', lib: true do
...
@@ -97,7 +97,7 @@ describe 'Git HTTP requests', lib: true do
context
"when authentication succeeds"
do
context
"when authentication succeeds"
do
let
(
:env
)
{
{
user:
user
.
username
,
password:
user
.
password
}
}
let
(
:env
)
{
{
user:
user
.
username
,
password:
user
.
password
}
}
context
"when the user has access to the project"
do
context
"when the user has access to the project"
do
before
do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
...
@@ -117,9 +117,9 @@ describe 'Git HTTP requests', lib: true do
...
@@ -117,9 +117,9 @@ describe 'Git HTTP requests', lib: true do
context
"when the user isn't blocked"
do
context
"when the user isn't blocked"
do
it
"responds with status 200"
do
it
"responds with status 200"
do
expect
(
Rack
::
Attack
::
Allow2Ban
).
to
receive
(
:reset
)
expect
(
Rack
::
Attack
::
Allow2Ban
).
to
receive
(
:reset
)
clone_get
(
path
,
env
)
clone_get
(
path
,
env
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
end
end
...
@@ -183,25 +183,21 @@ describe 'Git HTTP requests', lib: true do
...
@@ -183,25 +183,21 @@ describe 'Git HTTP requests', lib: true do
def
clone_get
(
project
,
options
=
{})
def
clone_get
(
project
,
options
=
{})
get
"/
#{
project
}
/info/refs"
,
{
service:
'git-upload-pack'
},
auth_env
(
*
options
.
values_at
(
:user
,
:password
))
get
"/
#{
project
}
/info/refs"
,
{
service:
'git-upload-pack'
},
auth_env
(
*
options
.
values_at
(
:user
,
:password
))
end
end
def
clone_post
(
project
,
options
=
{})
def
clone_post
(
project
,
options
=
{})
post
"/
#{
project
}
/git-upload-pack"
,
{},
auth_env
(
*
options
.
values_at
(
:user
,
:password
))
post
"/
#{
project
}
/git-upload-pack"
,
{},
auth_env
(
*
options
.
values_at
(
:user
,
:password
))
end
end
def
clone_path
(
project
)
"/
#{
project
.
path_with_namespace
}
.git/info/refs"
end
def
download
(
project
,
user:
nil
,
password:
nil
)
def
download
(
project
,
user:
nil
,
password:
nil
)
args
=
[
project
,
{
user:
user
,
password:
password
}]
args
=
[
project
,
{
user:
user
,
password:
password
}]
clone_get
*
args
clone_get
*
args
yield
response
yield
response
clone_post
*
args
clone_post
*
args
yield
response
yield
response
end
end
def
auth_env
(
user
,
password
)
def
auth_env
(
user
,
password
)
if
user
&&
password
if
user
&&
password
{
'HTTP_AUTHORIZATION'
=>
ActionController
::
HttpAuthentication
::
Basic
.
encode_credentials
(
user
,
password
)
}
{
'HTTP_AUTHORIZATION'
=>
ActionController
::
HttpAuthentication
::
Basic
.
encode_credentials
(
user
,
password
)
}
...
...
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