Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
74e50787
Commit
74e50787
authored
7 years ago
by
Eugen Rochko
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix #4637 - Re-add missing doorkeeper_authorize for /api/v1/verify_credentials (#4650)
parent
110227ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/api/v1/accounts/credentials_controller.rb
+1
-0
1 addition, 0 deletions
app/controllers/api/v1/accounts/credentials_controller.rb
spec/controllers/api/v1/accounts/credentials_controller_spec.rb
+58
-36
58 additions, 36 deletions
...ontrollers/api/v1/accounts/credentials_controller_spec.rb
with
59 additions
and
36 deletions
app/controllers/api/v1/accounts/credentials_controller.rb
+
1
−
0
View file @
74e50787
# frozen_string_literal: true
class
Api::V1::Accounts::CredentialsController
<
Api
::
BaseController
before_action
->
{
doorkeeper_authorize!
:read
},
except:
[
:update
]
before_action
->
{
doorkeeper_authorize!
:write
},
only:
[
:update
]
before_action
:require_user!
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/api/v1/accounts/credentials_controller_spec.rb
+
58
−
36
View file @
74e50787
...
...
@@ -4,57 +4,79 @@ describe Api::V1::Accounts::CredentialsController do
render_views
let
(
:user
)
{
Fabricate
(
:user
,
account:
Fabricate
(
:account
,
username:
'alice'
))
}
let
(
:token
)
{
Fabricate
(
:accessible_access_token
,
resource_owner_id:
user
.
id
,
scopes:
'write'
)
}
let
(
:token
)
{
Fabricate
(
:accessible_access_token
,
resource_owner_id:
user
.
id
,
scopes:
'
read
write'
)
}
before
do
allow
(
controller
).
to
receive
(
:doorkeeper_token
)
{
token
}
end
describe
'GET #show'
do
it
'returns http success'
do
get
:show
expect
(
response
).
to
have_http_status
(
:success
)
context
'with an oauth token'
do
before
do
allow
(
controller
).
to
receive
(
:doorkeeper_token
)
{
token
}
end
end
describe
'PATCH #update'
do
describe
'with valid data'
do
before
do
allow
(
ActivityPub
::
UpdateDistributionWorker
).
to
receive
(
:perform_async
)
patch
:update
,
params:
{
display_name:
"Alice Isn't Dead"
,
note:
"Hi!
\n\n
Toot toot!"
,
avatar:
fixture_file_upload
(
'files/avatar.gif'
,
'image/gif'
),
header:
fixture_file_upload
(
'files/attachment.jpg'
,
'image/jpeg'
),
}
end
describe
'GET #show'
do
it
'returns http success'
do
get
:show
expect
(
response
).
to
have_http_status
(
:success
)
end
end
describe
'PATCH #update'
do
describe
'with valid data'
do
before
do
allow
(
ActivityPub
::
UpdateDistributionWorker
).
to
receive
(
:perform_async
)
patch
:update
,
params:
{
display_name:
"Alice Isn't Dead"
,
note:
"Hi!
\n\n
Toot toot!"
,
avatar:
fixture_file_upload
(
'files/avatar.gif'
,
'image/gif'
),
header:
fixture_file_upload
(
'files/attachment.jpg'
,
'image/jpeg'
),
}
end
it
'updates account info'
do
user
.
account
.
reload
it
'returns http success'
do
expect
(
response
).
to
have_http_status
(
:success
)
end
expect
(
user
.
account
.
display_name
).
to
eq
(
"Alice Isn't Dead"
)
expect
(
user
.
account
.
note
).
to
eq
(
"Hi!
\n\n
Toot toot!"
)
expect
(
user
.
account
.
avatar
).
to
exist
expect
(
user
.
account
.
header
).
to
exist
it
'updates account info'
do
user
.
account
.
reload
expect
(
user
.
account
.
display_name
).
to
eq
(
"Alice Isn't Dead"
)
expect
(
user
.
account
.
note
).
to
eq
(
"Hi!
\n\n
Toot toot!"
)
expect
(
user
.
account
.
avatar
).
to
exist
expect
(
user
.
account
.
header
).
to
exist
end
it
'queues up an account update distribution'
do
expect
(
ActivityPub
::
UpdateDistributionWorker
).
to
have_received
(
:perform_async
).
with
(
user
.
account_id
)
end
end
it
'queues up an account update distribution'
do
expect
(
ActivityPub
::
UpdateDistributionWorker
).
to
have_received
(
:perform_async
).
with
(
user
.
account_id
)
describe
'with invalid data'
do
before
do
patch
:update
,
params:
{
note:
'This is too long. '
*
10
}
end
it
'returns http unprocessable entity'
do
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
end
end
end
end
describe
'with invalid data'
do
before
do
patch
:update
,
params:
{
note:
'This is too long. '
*
10
}
context
'without an oauth token'
do
before
do
allow
(
controller
).
to
receive
(
:doorkeeper_token
)
{
nil
}
end
describe
'GET #show'
do
it
'returns http unauthorized'
do
get
:show
expect
(
response
).
to
have_http_status
(
:unauthorized
)
end
end
it
'returns http unprocessable entity'
do
expect
(
response
).
to
have_http_status
(
:unprocessable_entity
)
describe
'PATCH #update'
do
it
'returns http unauthorized'
do
patch
:update
,
params:
{
note:
'Foo'
}
expect
(
response
).
to
have_http_status
(
:unauthorized
)
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment