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
8d33f75e
Commit
8d33f75e
authored
Jan 26, 2021
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Debian API endpoint for Packages files
Changelog: added
parent
25263e5b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
14 deletions
+29
-14
lib/api/concerns/packages/debian_package_endpoints.rb
lib/api/concerns/packages/debian_package_endpoints.rb
+17
-5
spec/requests/api/debian_group_packages_spec.rb
spec/requests/api/debian_group_packages_spec.rb
+3
-3
spec/requests/api/debian_project_packages_spec.rb
spec/requests/api/debian_project_packages_spec.rb
+3
-3
spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb
..._examples/requests/api/debian_packages_shared_examples.rb
+6
-3
No files found.
lib/api/concerns/packages/debian_package_endpoints.rb
View file @
8d33f75e
...
...
@@ -6,9 +6,9 @@ module API
module
DebianPackageEndpoints
extend
ActiveSupport
::
Concern
DISTRIBUTION_REGEX
=
%r{[a-z
A-Z0-9][a-zA-Z0-9.-]*}
.
freeze
COMPONENT_REGEX
=
%r{[a-z
-]+}
.
freeze
ARCHITECTURE_REGEX
=
%r{[a-z
][
a-z0-9]*}
.
freeze
DISTRIBUTION_REGEX
=
%r{[a-z
0-9][a-z0-9.-]*}i
.
freeze
COMPONENT_REGEX
=
%r{[a-z
0-9][a-z0-9.-]*}i
.
freeze
ARCHITECTURE_REGEX
=
%r{[a-z
0-9][-
a-z0-9]*}
.
freeze
LETTER_REGEX
=
%r{(lib)?[a-z0-9]}
.
freeze
PACKAGE_REGEX
=
API
::
NO_SLASH_URL_PART_REGEX
DISTRIBUTION_REQUIREMENTS
=
{
...
...
@@ -100,8 +100,20 @@ module API
route_setting
:authentication
,
authenticate_non_public:
true
get
'Packages'
do
# https://gitlab.com/gitlab-org/gitlab/-/issues/5835#note_414103286
'TODO Packages'
relation
=
"::Packages::Debian::
#{
project_or_group
.
class
.
name
}
ComponentFile"
.
constantize
component_file
=
relation
.
preload_distribution
.
with_container
(
project_or_group
)
.
with_codename_or_suite
(
params
[
:distribution
])
.
with_component_name
(
params
[
:component
])
.
with_file_type
(
:packages
)
.
with_architecture_name
(
params
[
:architecture
])
.
with_compression_type
(
nil
)
.
order_created_asc
.
last!
present_carrierwave_file!
(
component_file
.
file
)
end
end
end
...
...
spec/requests/api/debian_group_packages_spec.rb
View file @
8d33f75e
...
...
@@ -25,13 +25,13 @@ RSpec.describe API::DebianGroupPackages do
end
describe
'GET groups/:id/-/packages/debian/dists/*distribution/:component/binary-:architecture/Packages'
do
let
(
:url
)
{
"/groups/
#{
container
.
id
}
/-/packages/debian/dists/
#{
distribution
.
codename
}
/
#{
component
}
/binary-
#{
architectur
e
}
/Packages"
}
let
(
:url
)
{
"/groups/
#{
container
.
id
}
/-/packages/debian/dists/
#{
distribution
.
codename
}
/
#{
component
.
name
}
/binary-
#{
architecture
.
nam
e
}
/Packages"
}
it_behaves_like
'Debian repository read endpoint'
,
'GET request'
,
:success
,
/
^TODO Packages$
/
it_behaves_like
'Debian repository read endpoint'
,
'GET request'
,
:success
,
/
Description: This is an incomplete Packages file
/
end
describe
'GET groups/:id/-/packages/debian/pool/:component/:letter/:source_package/:file_name'
do
let
(
:url
)
{
"/groups/
#{
container
.
id
}
/-/packages/debian/pool/
#{
component
}
/
#{
letter
}
/
#{
source_package
}
/
#{
package_name
}
_
#{
package_version
}
_
#{
architectur
e
}
.deb"
}
let
(
:url
)
{
"/groups/
#{
container
.
id
}
/-/packages/debian/pool/
#{
component
.
name
}
/
#{
letter
}
/
#{
source_package
}
/
#{
package_name
}
_
#{
package_version
}
_
#{
architecture
.
nam
e
}
.deb"
}
it_behaves_like
'Debian repository read endpoint'
,
'GET request'
,
:success
,
/^TODO File$/
end
...
...
spec/requests/api/debian_project_packages_spec.rb
View file @
8d33f75e
...
...
@@ -25,13 +25,13 @@ RSpec.describe API::DebianProjectPackages do
end
describe
'GET projects/:id/packages/debian/dists/*distribution/:component/binary-:architecture/Packages'
do
let
(
:url
)
{
"/projects/
#{
container
.
id
}
/packages/debian/dists/
#{
distribution
.
codename
}
/
#{
component
}
/binary-
#{
architectur
e
}
/Packages"
}
let
(
:url
)
{
"/projects/
#{
container
.
id
}
/packages/debian/dists/
#{
distribution
.
codename
}
/
#{
component
.
name
}
/binary-
#{
architecture
.
nam
e
}
/Packages"
}
it_behaves_like
'Debian repository read endpoint'
,
'GET request'
,
:success
,
/
^TODO Packages$
/
it_behaves_like
'Debian repository read endpoint'
,
'GET request'
,
:success
,
/
Description: This is an incomplete Packages file
/
end
describe
'GET projects/:id/packages/debian/pool/:component/:letter/:source_package/:file_name'
do
let
(
:url
)
{
"/projects/
#{
container
.
id
}
/packages/debian/pool/
#{
component
}
/
#{
letter
}
/
#{
source_package
}
/
#{
package_name
}
_
#{
package_version
}
_
#{
architectur
e
}
.deb"
}
let
(
:url
)
{
"/projects/
#{
container
.
id
}
/packages/debian/pool/
#{
component
.
name
}
/
#{
letter
}
/
#{
source_package
}
/
#{
package_name
}
_
#{
package_version
}
_
#{
architecture
.
nam
e
}
.deb"
}
it_behaves_like
'Debian repository read endpoint'
,
'GET request'
,
:success
,
/^TODO File$/
end
...
...
spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb
View file @
8d33f75e
...
...
@@ -16,11 +16,13 @@ RSpec.shared_context 'Debian repository shared context' do |container_type, can_
let_it_be
(
:private_component
,
freeze:
true
)
{
create
(
"debian_
#{
container_type
}
_component"
,
distribution:
private_distribution
,
name:
'existing-component'
)
}
let_it_be
(
:private_architecture_all
,
freeze:
true
)
{
create
(
"debian_
#{
container_type
}
_architecture"
,
distribution:
private_distribution
,
name:
'all'
)
}
let_it_be
(
:private_architecture
,
freeze:
true
)
{
create
(
"debian_
#{
container_type
}
_architecture"
,
distribution:
private_distribution
,
name:
'existing-arch'
)
}
let_it_be
(
:private_component_file
)
{
create
(
"debian_
#{
container_type
}
_component_file"
,
component:
private_component
,
architecture:
private_architecture
)
}
let_it_be
(
:public_distribution
,
freeze:
true
)
{
create
(
"debian_
#{
container_type
}
_distribution"
,
:with_file
,
container:
public_container
,
codename:
'existing-codename'
)
}
let_it_be
(
:public_component
,
freeze:
true
)
{
create
(
"debian_
#{
container_type
}
_component"
,
distribution:
public_distribution
,
name:
'existing-component'
)
}
let_it_be
(
:public_architecture_all
,
freeze:
true
)
{
create
(
"debian_
#{
container_type
}
_architecture"
,
distribution:
public_distribution
,
name:
'all'
)
}
let_it_be
(
:public_architecture
,
freeze:
true
)
{
create
(
"debian_
#{
container_type
}
_architecture"
,
distribution:
public_distribution
,
name:
'existing-arch'
)
}
let_it_be
(
:public_component_file
)
{
create
(
"debian_
#{
container_type
}
_component_file"
,
component:
public_component
,
architecture:
public_architecture
)
}
if
container_type
==
:group
let_it_be
(
:private_project
)
{
create
(
:project
,
:private
,
group:
private_container
)
}
...
...
@@ -40,14 +42,15 @@ RSpec.shared_context 'Debian repository shared context' do |container_type, can_
let
(
:visibility_level
)
{
:public
}
let
(
:distribution
)
{
{
private:
private_distribution
,
public:
public_distribution
}[
visibility_level
]
}
let
(
:architecture
)
{
{
private:
private_architecture
,
public:
public_architecture
}[
visibility_level
]
}
let
(
:component
)
{
{
private:
private_component
,
public:
public_component
}[
visibility_level
]
}
let
(
:component_file
)
{
{
private:
private_component_file
,
public:
public_component_file
}[
visibility_level
]
}
let
(
:component
)
{
'main'
}
let
(
:architecture
)
{
'amd64'
}
let
(
:source_package
)
{
'sample'
}
let
(
:letter
)
{
source_package
[
0
..
2
]
==
'lib'
?
source_package
[
0
..
3
]
:
source_package
[
0
]
}
let
(
:package_name
)
{
'libsample0'
}
let
(
:package_version
)
{
'1.2.3~alpha2'
}
let
(
:file_name
)
{
"
#{
package_name
}
_
#{
package_version
}
_
#{
architecture
}
.deb"
}
let
(
:file_name
)
{
"
#{
package_name
}
_
#{
package_version
}
_
#{
architecture
.
name
}
.deb"
}
let
(
:method
)
{
:get
}
...
...
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