BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0e73d7b6
Commit
0e73d7b6
authored
Oct 22, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9762 from huacnlee/fix/api-helpers-bad-autoload-name-for-master
Fix API::APIHelpers -> API::Helpers again for master
parents
a7174efa
3d613fe1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
api.rb
lib/api/api.rb
+1
-1
helpers.rb
lib/api/helpers.rb
+1
-1
api.rb
lib/ci/api/api.rb
+1
-1
api_helpers_spec.rb
spec/requests/api/api_helpers_spec.rb
+13
-13
No files found.
lib/api/api.rb
View file @
0e73d7b6
...
...
@@ -25,7 +25,7 @@ module API
format
:json
content_type
:txt
,
"text/plain"
helpers
API
Helpers
helpers
Helpers
mount
Groups
mount
GroupMembers
...
...
lib/api/helpers.rb
View file @
0e73d7b6
module
API
module
API
Helpers
module
Helpers
PRIVATE_TOKEN_HEADER
=
"HTTP_PRIVATE_TOKEN"
PRIVATE_TOKEN_PARAM
=
:private_token
SUDO_HEADER
=
"HTTP_SUDO"
...
...
lib/ci/api/api.rb
View file @
0e73d7b6
...
...
@@ -26,7 +26,7 @@ module Ci
format
:json
helpers
Helpers
helpers
::
API
::
API
Helpers
helpers
::
API
::
Helpers
mount
Builds
mount
Commits
...
...
spec/requests/api/api_helpers_spec.rb
View file @
0e73d7b6
require
'spec_helper'
describe
API
,
api:
true
do
include
API
::
API
Helpers
include
API
::
Helpers
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
...
...
@@ -13,25 +13,25 @@ describe API, api: true do
def
set_env
(
token_usr
,
identifier
)
clear_env
clear_param
env
[
API
::
API
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
token_usr
.
private_token
env
[
API
::
API
Helpers
::
SUDO_HEADER
]
=
identifier
env
[
API
::
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
token_usr
.
private_token
env
[
API
::
Helpers
::
SUDO_HEADER
]
=
identifier
end
def
set_param
(
token_usr
,
identifier
)
clear_env
clear_param
params
[
API
::
API
Helpers
::
PRIVATE_TOKEN_PARAM
]
=
token_usr
.
private_token
params
[
API
::
API
Helpers
::
SUDO_PARAM
]
=
identifier
params
[
API
::
Helpers
::
PRIVATE_TOKEN_PARAM
]
=
token_usr
.
private_token
params
[
API
::
Helpers
::
SUDO_PARAM
]
=
identifier
end
def
clear_env
env
.
delete
(
API
::
API
Helpers
::
PRIVATE_TOKEN_HEADER
)
env
.
delete
(
API
::
API
Helpers
::
SUDO_HEADER
)
env
.
delete
(
API
::
Helpers
::
PRIVATE_TOKEN_HEADER
)
env
.
delete
(
API
::
Helpers
::
SUDO_HEADER
)
end
def
clear_param
params
.
delete
(
API
::
API
Helpers
::
PRIVATE_TOKEN_PARAM
)
params
.
delete
(
API
::
API
Helpers
::
SUDO_PARAM
)
params
.
delete
(
API
::
Helpers
::
PRIVATE_TOKEN_PARAM
)
params
.
delete
(
API
::
Helpers
::
SUDO_PARAM
)
end
def
error!
(
message
,
status
)
...
...
@@ -40,22 +40,22 @@ describe API, api: true do
describe
".current_user"
do
it
"should return nil for an invalid token"
do
env
[
API
::
API
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
'invalid token'
env
[
API
::
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
'invalid token'
allow_any_instance_of
(
self
.
class
).
to
receive
(
:doorkeeper_guard
){
false
}
expect
(
current_user
).
to
be_nil
end
it
"should return nil for a user without access"
do
env
[
API
::
API
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
user
.
private_token
env
[
API
::
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
user
.
private_token
allow
(
Gitlab
::
UserAccess
).
to
receive
(
:allowed?
).
and_return
(
false
)
expect
(
current_user
).
to
be_nil
end
it
"should leave user as is when sudo not specified"
do
env
[
API
::
API
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
user
.
private_token
env
[
API
::
Helpers
::
PRIVATE_TOKEN_HEADER
]
=
user
.
private_token
expect
(
current_user
).
to
eq
(
user
)
clear_env
params
[
API
::
API
Helpers
::
PRIVATE_TOKEN_PARAM
]
=
user
.
private_token
params
[
API
::
Helpers
::
PRIVATE_TOKEN_PARAM
]
=
user
.
private_token
expect
(
current_user
).
to
eq
(
user
)
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