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
1
Merge Requests
1
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-ce
Commits
9d7cda3d
Commit
9d7cda3d
authored
Jun 16, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `api_helpers_spec`
parent
90bba2bc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
spec/requests/api/api_helpers_spec.rb
spec/requests/api/api_helpers_spec.rb
+6
-6
No files found.
spec/requests/api/api_helpers_spec.rb
View file @
9d7cda3d
...
@@ -67,35 +67,35 @@ describe API::Helpers, api: true do
...
@@ -67,35 +67,35 @@ describe API::Helpers, api: true do
let
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
)
}
let
(
:personal_access_token
)
{
create
(
:personal_access_token
,
user:
user
)
}
it
"should return nil for an invalid token"
do
it
"should return nil for an invalid token"
do
env
[
API
::
Helpers
::
P
ERSONAL_ACCESS
_TOKEN_HEADER
]
=
'invalid token'
env
[
API
::
Helpers
::
P
RIVATE
_TOKEN_HEADER
]
=
'invalid token'
allow_any_instance_of
(
self
.
class
).
to
receive
(
:doorkeeper_guard
){
false
}
allow_any_instance_of
(
self
.
class
).
to
receive
(
:doorkeeper_guard
){
false
}
expect
(
current_user
).
to
be_nil
expect
(
current_user
).
to
be_nil
end
end
it
"should return nil for a user without access"
do
it
"should return nil for a user without access"
do
env
[
API
::
Helpers
::
P
ERSONAL_ACCESS
_TOKEN_HEADER
]
=
personal_access_token
.
token
env
[
API
::
Helpers
::
P
RIVATE
_TOKEN_HEADER
]
=
personal_access_token
.
token
allow
(
Gitlab
::
UserAccess
).
to
receive
(
:allowed?
).
and_return
(
false
)
allow
(
Gitlab
::
UserAccess
).
to
receive
(
:allowed?
).
and_return
(
false
)
expect
(
current_user
).
to
be_nil
expect
(
current_user
).
to
be_nil
end
end
it
"should leave user as is when sudo not specified"
do
it
"should leave user as is when sudo not specified"
do
env
[
API
::
Helpers
::
P
ERSONAL_ACCESS
_TOKEN_HEADER
]
=
personal_access_token
.
token
env
[
API
::
Helpers
::
P
RIVATE
_TOKEN_HEADER
]
=
personal_access_token
.
token
expect
(
current_user
).
to
eq
(
user
)
expect
(
current_user
).
to
eq
(
user
)
clear_env
clear_env
params
[
API
::
Helpers
::
P
ERSONAL_ACCESS
_TOKEN_PARAM
]
=
personal_access_token
.
token
params
[
API
::
Helpers
::
P
RIVATE
_TOKEN_PARAM
]
=
personal_access_token
.
token
expect
(
current_user
).
to
eq
(
user
)
expect
(
current_user
).
to
eq
(
user
)
end
end
it
'does not allow revoked tokens'
do
it
'does not allow revoked tokens'
do
personal_access_token
.
revoke!
personal_access_token
.
revoke!
env
[
API
::
Helpers
::
P
ERSONAL_ACCESS
_TOKEN_HEADER
]
=
personal_access_token
.
token
env
[
API
::
Helpers
::
P
RIVATE
_TOKEN_HEADER
]
=
personal_access_token
.
token
allow_any_instance_of
(
self
.
class
).
to
receive
(
:doorkeeper_guard
){
false
}
allow_any_instance_of
(
self
.
class
).
to
receive
(
:doorkeeper_guard
){
false
}
expect
(
current_user
).
to
be_nil
expect
(
current_user
).
to
be_nil
end
end
it
'does not allow expired tokens'
do
it
'does not allow expired tokens'
do
personal_access_token
.
update_attributes!
(
expires_at:
1
.
day
.
ago
)
personal_access_token
.
update_attributes!
(
expires_at:
1
.
day
.
ago
)
env
[
API
::
Helpers
::
P
ERSONAL_ACCESS
_TOKEN_HEADER
]
=
personal_access_token
.
token
env
[
API
::
Helpers
::
P
RIVATE
_TOKEN_HEADER
]
=
personal_access_token
.
token
allow_any_instance_of
(
self
.
class
).
to
receive
(
:doorkeeper_guard
){
false
}
allow_any_instance_of
(
self
.
class
).
to
receive
(
:doorkeeper_guard
){
false
}
expect
(
current_user
).
to
be_nil
expect
(
current_user
).
to
be_nil
end
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