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
6a9e9f29
Commit
6a9e9f29
authored
Jan 23, 2020
by
David Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix nuget uploads
These are handled as multipart uploads Fix nuget package naming
parent
ff77bdf6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
20 deletions
+57
-20
ee/app/services/packages/nuget/create_package_service.rb
ee/app/services/packages/nuget/create_package_service.rb
+9
-3
ee/lib/api/conan_packages.rb
ee/lib/api/conan_packages.rb
+2
-2
ee/lib/api/helpers/packages_helpers.rb
ee/lib/api/helpers/packages_helpers.rb
+7
-2
ee/lib/api/helpers/packages_manager_clients_helpers.rb
ee/lib/api/helpers/packages_manager_clients_helpers.rb
+2
-2
ee/lib/api/nuget_packages.rb
ee/lib/api/nuget_packages.rb
+2
-2
ee/spec/lib/api/helpers/packages_helpers_spec.rb
ee/spec/lib/api/helpers/packages_helpers_spec.rb
+15
-1
ee/spec/requests/api/nuget_packages_spec.rb
ee/spec/requests/api/nuget_packages_spec.rb
+2
-2
ee/spec/services/packages/nuget/create_package_service_spec.rb
...ec/services/packages/nuget/create_package_service_spec.rb
+14
-2
ee/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb
...d_examples/requests/api/nuget_packages_shared_examples.rb
+4
-4
No files found.
ee/app/services/packages/nuget/create_package_service.rb
View file @
6a9e9f29
...
...
@@ -3,15 +3,21 @@
module
Packages
module
Nuget
class
CreatePackageService
<
BaseService
PACKAGE_NAME
=
'NuGet
.Package'
TEMPORARY_PACKAGE_NAME
=
'NuGet.Temporary
.Package'
PACKAGE_VERSION
=
'0.0.0'
def
execute
project
.
packages
.
nuget
.
create!
(
name:
PACKAGE_NAME
,
version:
PACKAGE_VERSION
name:
TEMPORARY_
PACKAGE_NAME
,
version:
"
#{
PACKAGE_VERSION
}
-
#{
uuid
}
"
)
end
private
def
uuid
SecureRandom
.
uuid
end
end
end
end
ee/lib/api/conan_packages.rb
View file @
6a9e9f29
...
...
@@ -250,7 +250,7 @@ module API
end
route_setting
:authentication
,
job_token_allowed:
true
put
'authorize'
do
authorize_workhorse!
(
project
)
authorize_workhorse!
(
subject:
project
)
end
end
...
...
@@ -273,7 +273,7 @@ module API
end
route_setting
:authentication
,
job_token_allowed:
true
put
'authorize'
do
authorize_workhorse!
(
project
)
authorize_workhorse!
(
subject:
project
)
end
desc
'Upload package files'
do
...
...
ee/lib/api/helpers/packages_helpers.rb
View file @
6a9e9f29
...
...
@@ -3,6 +3,8 @@
module
API
module
Helpers
module
PackagesHelpers
MAX_PACKAGE_FILE_SIZE
=
50
.
megabytes
.
freeze
def
require_packages_enabled!
not_found!
unless
::
Gitlab
.
config
.
packages
.
enabled
end
...
...
@@ -29,14 +31,17 @@ module API
authorize_read_package!
(
subject
)
end
def
authorize_workhorse!
(
subject
=
user_project
)
def
authorize_workhorse!
(
subject
:
user_project
,
has_length:
true
,
maximum_size:
MAX_PACKAGE_FILE_SIZE
)
authorize_upload!
(
subject
)
Gitlab
::
Workhorse
.
verify_api_request!
(
headers
)
status
200
content_type
Gitlab
::
Workhorse
::
INTERNAL_API_CONTENT_TYPE
::
Packages
::
PackageFileUploader
.
workhorse_authorize
(
has_length:
true
)
params
=
{
has_length:
has_length
}
params
[
:maximum_size
]
=
maximum_size
unless
has_length
::
Packages
::
PackageFileUploader
.
workhorse_authorize
(
params
)
end
def
authorize_upload!
(
subject
=
user_project
)
...
...
ee/lib/api/helpers/packages_manager_clients_helpers.rb
View file @
6a9e9f29
...
...
@@ -36,8 +36,8 @@ module API
::
Ci
::
Build
.
find_by_token
(
token
)
end
def
uploaded_package_file
uploaded_file
=
UploadedFile
.
from_params
(
params
,
:fil
e
,
::
Packages
::
PackageFileUploader
.
workhorse_local_upload_path
)
def
uploaded_package_file
(
param_name
=
:file
)
uploaded_file
=
UploadedFile
.
from_params
(
params
,
param_nam
e
,
::
Packages
::
PackageFileUploader
.
workhorse_local_upload_path
)
bad_request!
(
'Missing package file!'
)
unless
uploaded_file
uploaded_file
end
...
...
ee/lib/api/nuget_packages.rb
View file @
6a9e9f29
...
...
@@ -96,7 +96,7 @@ module API
package
=
::
Packages
::
Nuget
::
CreatePackageService
.
new
(
authorized_user_project
,
current_user
).
execute
file_params
=
params
.
merge
(
file:
uploaded_package_file
,
file:
uploaded_package_file
(
:package
)
,
file_name:
PACKAGE_FILENAME
,
file_type:
PACKAGE_FILETYPE
)
...
...
@@ -112,7 +112,7 @@ module API
forbidden!
end
put
'authorize'
do
authorize_workhorse!
(
authorized_user_project
)
authorize_workhorse!
(
subject:
authorized_user_project
,
has_length:
false
)
end
end
end
...
...
ee/spec/lib/api/helpers/packages_helpers_spec.rb
View file @
6a9e9f29
...
...
@@ -89,7 +89,7 @@ describe API::Helpers::PackagesHelpers do
describe
'#authorize_workhorse!'
do
let_it_be
(
:headers
)
{
{}
}
subject
{
helper
.
authorize_workhorse!
(
project
)
}
subject
{
helper
.
authorize_workhorse!
(
subject:
project
)
}
before
do
allow
(
helper
).
to
receive
(
:headers
).
and_return
(
headers
)
...
...
@@ -104,6 +104,20 @@ describe API::Helpers::PackagesHelpers do
expect
(
subject
).
to
eq
nil
end
context
'without length'
do
subject
{
helper
.
authorize_workhorse!
(
subject:
project
,
has_length:
false
)
}
it
'authorizes workhorse'
do
expect
(
helper
).
to
receive
(
:authorize_upload!
).
with
(
project
)
expect
(
helper
).
to
receive
(
:status
).
with
(
200
)
expect
(
helper
).
to
receive
(
:content_type
).
with
(
Gitlab
::
Workhorse
::
INTERNAL_API_CONTENT_TYPE
)
expect
(
Gitlab
::
Workhorse
).
to
receive
(
:verify_api_request!
).
with
(
headers
)
expect
(
::
Packages
::
PackageFileUploader
).
to
receive
(
:workhorse_authorize
).
with
(
has_length:
false
,
maximum_size:
::
API
::
Helpers
::
PackagesHelpers
::
MAX_PACKAGE_FILE_SIZE
)
expect
(
subject
).
to
eq
nil
end
end
end
describe
'#authorize_upload!'
do
...
...
ee/spec/requests/api/nuget_packages_spec.rb
View file @
6a9e9f29
...
...
@@ -177,13 +177,13 @@ describe API::NugetPackages do
let_it_be
(
:file_name
)
{
'package.nupkg'
}
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/packages/nuget"
}
let
(
:headers
)
{
{}
}
let
(
:params
)
{
{
fil
e:
temp_file
(
file_name
)
}
}
let
(
:params
)
{
{
packag
e:
temp_file
(
file_name
)
}
}
subject
do
workhorse_finalize
(
api
(
url
),
method: :put
,
file_key: :
fil
e
,
file_key: :
packag
e
,
params:
params
,
headers:
headers
)
...
...
ee/spec/services/packages/nuget/create_package_service_spec.rb
View file @
6a9e9f29
...
...
@@ -14,8 +14,20 @@ describe Packages::Nuget::CreatePackageService do
package
=
Packages
::
Package
.
last
expect
(
package
).
to
be_valid
expect
(
package
.
name
).
to
eq
(
Packages
::
Nuget
::
CreatePackageService
::
PACKAGE_NAME
)
expect
(
package
.
version
).
to
eq
(
Packages
::
Nuget
::
CreatePackageService
::
PACKAGE_VERSION
)
expect
(
package
.
name
).
to
eq
(
Packages
::
Nuget
::
CreatePackageService
::
TEMPORARY_PACKAGE_NAME
)
expect
(
package
.
version
).
to
start_with
(
Packages
::
Nuget
::
CreatePackageService
::
PACKAGE_VERSION
)
expect
(
package
.
package_type
).
to
eq
(
'nuget'
)
end
it
'can create two packages in a row'
do
expect
{
subject
}.
to
change
{
Packages
::
Package
.
count
}.
by
(
1
)
expect
{
described_class
.
new
(
project
,
user
,
params
).
execute
}.
to
change
{
Packages
::
Package
.
count
}.
by
(
1
)
package
=
Packages
::
Package
.
last
expect
(
package
).
to
be_valid
expect
(
package
.
name
).
to
eq
(
Packages
::
Nuget
::
CreatePackageService
::
TEMPORARY_PACKAGE_NAME
)
expect
(
package
.
version
).
to
start_with
(
Packages
::
Nuget
::
CreatePackageService
::
PACKAGE_VERSION
)
expect
(
package
.
package_type
).
to
eq
(
'nuget'
)
end
end
...
...
ee/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb
View file @
6a9e9f29
...
...
@@ -98,7 +98,7 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
context
'with object storage disabled'
do
context
'without a file from workhorse'
do
let
(
:params
)
{
{
fil
e:
nil
}
}
let
(
:params
)
{
{
packag
e:
nil
}
}
it_behaves_like
'returning response status'
,
:bad_request
end
...
...
@@ -121,7 +121,7 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
)
end
let
(
:fog_file
)
{
fog_to_uploaded_file
(
tmp_object
)
}
let
(
:params
)
{
{
file:
fog_file
,
'fil
e.remote_id'
=>
file_name
}
}
let
(
:params
)
{
{
package:
fog_file
,
'packag
e.remote_id'
=>
file_name
}
}
it_behaves_like
'creates nuget package files'
...
...
@@ -129,8 +129,8 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
context
"with invalid remote_id:
#{
remote_id
}
"
do
let
(
:params
)
do
{
fil
e:
fog_file
,
'
fil
e.remote_id'
=>
remote_id
packag
e:
fog_file
,
'
packag
e.remote_id'
=>
remote_id
}
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