debian-mirror-gitlab/spec/requests/api/debian_project_packages_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
3.6 KiB
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::DebianProjectPackages do
include HttpBasicAuthHelpers
include WorkhorseHelpers
2021-06-08 01:23:25 +05:30
include_context 'Debian repository shared context', :project, true do
2021-10-27 15:23:28 +05:30
context 'with invalid parameter' do
let(:url) { "/projects/1/packages/debian/dists/with+space/InRelease" }
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages GET request', :bad_request, /^distribution is invalid$/
2021-10-27 15:23:28 +05:30
end
2021-03-11 19:13:27 +05:30
describe 'GET projects/:id/packages/debian/dists/*distribution/Release.gpg' do
2021-09-04 01:27:46 +05:30
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/Release.gpg" }
2021-01-03 14:25:43 +05:30
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages read endpoint', 'GET', :success, /^-----BEGIN PGP SIGNATURE-----/
2021-01-03 14:25:43 +05:30
end
2021-03-11 19:13:27 +05:30
describe 'GET projects/:id/packages/debian/dists/*distribution/Release' do
2021-09-04 01:27:46 +05:30
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/Release" }
2021-01-03 14:25:43 +05:30
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages read endpoint', 'GET', :success, /^Codename: fixture-distribution\n$/
2021-01-03 14:25:43 +05:30
end
2021-03-11 19:13:27 +05:30
describe 'GET projects/:id/packages/debian/dists/*distribution/InRelease' do
2021-09-04 01:27:46 +05:30
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/InRelease" }
2021-01-03 14:25:43 +05:30
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages read endpoint', 'GET', :success, /^-----BEGIN PGP SIGNED MESSAGE-----/
2021-01-03 14:25:43 +05:30
end
2021-03-11 19:13:27 +05:30
describe 'GET projects/:id/packages/debian/dists/*distribution/:component/binary-:architecture/Packages' do
2021-09-30 23:02:18 +05:30
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/#{component.name}/binary-#{architecture.name}/Packages" }
2021-01-03 14:25:43 +05:30
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages read endpoint', 'GET', :success, /Description: This is an incomplete Packages file/
2021-01-03 14:25:43 +05:30
end
2021-10-27 15:23:28 +05:30
describe 'GET projects/:id/packages/debian/pool/:codename/:letter/:package_name/:package_version/:file_name' do
let(:url) { "/projects/#{container.id}/packages/debian/pool/#{package.debian_distribution.codename}/#{letter}/#{package.name}/#{package.version}/#{file_name}" }
2021-12-11 22:18:48 +05:30
let(:file_name) { params[:file_name] }
2021-10-27 15:23:28 +05:30
using RSpec::Parameterized::TableSyntax
where(:file_name, :success_body) do
'sample_1.2.3~alpha2.tar.xz' | /^.7zXZ/
'sample_1.2.3~alpha2.dsc' | /^Format: 3.0 \(native\)/
'libsample0_1.2.3~alpha2_amd64.deb' | /^!<arch>/
'sample-udeb_1.2.3~alpha2_amd64.udeb' | /^!<arch>/
'sample_1.2.3~alpha2_amd64.buildinfo' | /Build-Tainted-By/
'sample_1.2.3~alpha2_amd64.changes' | /urgency=medium/
end
with_them do
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages read endpoint', 'GET', :success, params[:success_body]
2021-10-27 15:23:28 +05:30
end
2021-01-03 14:25:43 +05:30
end
2021-03-11 19:13:27 +05:30
describe 'PUT projects/:id/packages/debian/:file_name' do
2021-01-03 14:25:43 +05:30
let(:method) { :put }
2021-06-08 01:23:25 +05:30
let(:url) { "/projects/#{container.id}/packages/debian/#{file_name}" }
2021-09-04 01:27:46 +05:30
let(:snowplow_gitlab_standard_context) { { project: container, user: user, namespace: container.namespace } }
2021-01-03 14:25:43 +05:30
2021-09-04 01:27:46 +05:30
context 'with a deb' do
let(:file_name) { 'libsample0_1.2.3~alpha2_amd64.deb' }
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages write endpoint', 'upload', :created, nil
2021-09-04 01:27:46 +05:30
end
context 'with a changes file' do
let(:file_name) { 'sample_1.2.3~alpha2_amd64.changes' }
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages write endpoint', 'upload', :created, nil
2021-09-04 01:27:46 +05:30
end
2021-01-03 14:25:43 +05:30
end
2021-03-08 18:12:59 +05:30
2021-03-11 19:13:27 +05:30
describe 'PUT projects/:id/packages/debian/:file_name/authorize' do
2021-09-04 01:27:46 +05:30
let(:file_name) { 'libsample0_1.2.3~alpha2_amd64.deb' }
2021-03-08 18:12:59 +05:30
let(:method) { :put }
2021-06-08 01:23:25 +05:30
let(:url) { "/projects/#{container.id}/packages/debian/#{file_name}/authorize" }
2021-03-08 18:12:59 +05:30
2021-12-11 22:18:48 +05:30
it_behaves_like 'Debian packages write endpoint', 'upload authorize', :created, nil
2021-03-08 18:12:59 +05:30
end
2021-01-03 14:25:43 +05:30
end
end