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
1ead057d
Commit
1ead057d
authored
Jan 19, 2022
by
Darby Frey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding custom error response for when file upload is too large
parent
b7b5f4c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
lib/api/ci/secure_files.rb
lib/api/ci/secure_files.rb
+3
-0
spec/requests/api/ci/secure_files_spec.rb
spec/requests/api/ci/secure_files_spec.rb
+15
-0
No files found.
lib/api/ci/secure_files.rb
View file @
1ead057d
...
...
@@ -60,6 +60,7 @@ module API
route_setting
:authentication
,
basic_auth_personal_access_token:
true
,
job_token_allowed:
true
post
':id/secure_files'
do
secure_file
=
user_project
.
secure_files
.
new
(
name:
params
[
:name
],
permissions:
params
[
:permissions
]
||
:read_only
...
...
@@ -67,6 +68,8 @@ module API
secure_file
.
file
=
params
[
:file
]
file_too_large!
unless
secure_file
.
file
.
size
<
::
Ci
::
SecureFile
::
FILE_SIZE_LIMIT
.
to_i
if
secure_file
.
save
present
secure_file
,
with:
Entities
::
Ci
::
SecureFile
else
...
...
spec/requests/api/ci/secure_files_spec.rb
View file @
1ead057d
...
...
@@ -226,6 +226,21 @@ RSpec.describe API::Ci::SecureFiles do
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
end
it
'returns a 413 error when the file size is too large'
do
allow_next_instance_of
(
Ci
::
SecureFile
)
do
|
instance
|
allow
(
instance
).
to
receive_message_chain
(
:file
,
:size
).
and_return
(
6
.
megabytes
.
to_i
)
end
post_params
=
{
file:
fixture_file_upload
(
'spec/fixtures/ci_secure_files/upload-keystore.jks'
),
name:
'upload-keystore.jks'
}
post
api
(
"/projects/
#{
project
.
id
}
/secure_files"
,
user
),
params:
post_params
expect
(
response
).
to
have_gitlab_http_status
(
:payload_too_large
)
end
end
context
'authorized user with invalid permissions'
do
...
...
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