2020-09-28 05:09:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe API::DebianProjectPackages do
|
|
|
|
include HttpBasicAuthHelpers
|
|
|
|
include WorkhorseHelpers
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
include_context 'Debian repository shared context', :project, true do
|
2021-07-27 08:10:54 -04:00
|
|
|
context 'with invalid parameter' do
|
|
|
|
let(:url) { "/projects/1/packages/debian/dists/with+space/InRelease" }
|
|
|
|
|
|
|
|
it_behaves_like 'Debian repository GET request', :bad_request, /^distribution is invalid$/
|
|
|
|
end
|
|
|
|
|
2021-01-22 07:08:52 -05:00
|
|
|
describe 'GET projects/:id/packages/debian/dists/*distribution/Release.gpg' do
|
2021-06-14 14:10:28 -04:00
|
|
|
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/Release.gpg" }
|
2020-09-28 05:09:35 -04:00
|
|
|
|
2021-07-30 05:10:05 -04:00
|
|
|
it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^-----BEGIN PGP SIGNATURE-----/
|
2020-09-28 05:09:35 -04:00
|
|
|
end
|
|
|
|
|
2021-01-22 07:08:52 -05:00
|
|
|
describe 'GET projects/:id/packages/debian/dists/*distribution/Release' do
|
2021-06-14 14:10:28 -04:00
|
|
|
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/Release" }
|
2020-09-28 05:09:35 -04:00
|
|
|
|
2021-06-21 23:07:55 -04:00
|
|
|
it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^Codename: fixture-distribution\n$/
|
2020-09-28 05:09:35 -04:00
|
|
|
end
|
|
|
|
|
2021-01-22 07:08:52 -05:00
|
|
|
describe 'GET projects/:id/packages/debian/dists/*distribution/InRelease' do
|
2021-06-14 14:10:28 -04:00
|
|
|
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/InRelease" }
|
2020-09-28 05:09:35 -04:00
|
|
|
|
2021-07-30 05:10:05 -04:00
|
|
|
it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^-----BEGIN PGP SIGNED MESSAGE-----/
|
2020-09-28 05:09:35 -04:00
|
|
|
end
|
|
|
|
|
2021-01-22 07:08:52 -05:00
|
|
|
describe 'GET projects/:id/packages/debian/dists/*distribution/:component/binary-:architecture/Packages' do
|
2021-06-28 02:07:45 -04:00
|
|
|
let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/#{component.name}/binary-#{architecture.name}/Packages" }
|
2020-09-28 05:09:35 -04:00
|
|
|
|
2021-06-28 02:07:45 -04:00
|
|
|
it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /Description: This is an incomplete Packages file/
|
2020-09-28 05:09:35 -04:00
|
|
|
end
|
|
|
|
|
2021-07-27 08:10:54 -04:00
|
|
|
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}" }
|
|
|
|
|
|
|
|
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
|
|
|
|
include_context 'with file_name', params[:file_name]
|
2020-09-28 05:09:35 -04:00
|
|
|
|
2021-07-27 08:10:54 -04:00
|
|
|
it_behaves_like 'Debian repository read endpoint', 'GET request', :success, params[:success_body]
|
|
|
|
end
|
2020-09-28 05:09:35 -04:00
|
|
|
end
|
|
|
|
|
2021-01-22 07:08:52 -05:00
|
|
|
describe 'PUT projects/:id/packages/debian/:file_name' do
|
2020-09-28 05:09:35 -04:00
|
|
|
let(:method) { :put }
|
2021-05-18 11:10:46 -04:00
|
|
|
let(:url) { "/projects/#{container.id}/packages/debian/#{file_name}" }
|
2021-06-07 08:10:00 -04:00
|
|
|
let(:snowplow_gitlab_standard_context) { { project: container, user: user, namespace: container.namespace } }
|
2020-09-28 05:09:35 -04:00
|
|
|
|
2021-05-25 11:10:33 -04:00
|
|
|
context 'with a deb' do
|
|
|
|
let(:file_name) { 'libsample0_1.2.3~alpha2_amd64.deb' }
|
|
|
|
|
|
|
|
it_behaves_like 'Debian repository write endpoint', 'upload request', :created
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a changes file' do
|
|
|
|
let(:file_name) { 'sample_1.2.3~alpha2_amd64.changes' }
|
|
|
|
|
|
|
|
it_behaves_like 'Debian repository write endpoint', 'upload request', :created
|
|
|
|
end
|
2020-09-28 05:09:35 -04:00
|
|
|
end
|
2021-01-12 22:10:20 -05:00
|
|
|
|
2021-01-22 07:08:52 -05:00
|
|
|
describe 'PUT projects/:id/packages/debian/:file_name/authorize' do
|
2021-05-25 11:10:33 -04:00
|
|
|
let(:file_name) { 'libsample0_1.2.3~alpha2_amd64.deb' }
|
2021-01-12 22:10:20 -05:00
|
|
|
let(:method) { :put }
|
2021-05-18 11:10:46 -04:00
|
|
|
let(:url) { "/projects/#{container.id}/packages/debian/#{file_name}/authorize" }
|
2021-01-12 22:10:20 -05:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it_behaves_like 'Debian repository write endpoint', 'upload authorize request', :created
|
2021-01-12 22:10:20 -05:00
|
|
|
end
|
2020-09-28 05:09:35 -04:00
|
|
|
end
|
|
|
|
end
|