Commit 673e2871 authored by Steve Abrams's avatar Steve Abrams

Fix Conan project-level download urls

Fixes a bug that was returning instance-level
conan urls when project-level urls were requested.
parent 2a7c3adf
---
title: Fix Conan project-level API to return correct download-urls and fix Conan project-level
functionality
merge_request: 56899
author:
type: fixed
......@@ -402,16 +402,3 @@ The GitLab Conan repository supports the following Conan CLI commands:
packages you have permission to view.
- `conan info`: View the information on a given package from the Package Registry.
- `conan remove`: Delete the package from the Package Registry.
## Troubleshooting Conan packages
### `ERROR: <package> was not found in remote <remote>`
When you attempt to install a Conan package, you might receive a `404` error
like `ERROR: <package> was not found in remote <remote>`.
This issue occurs when you request a download from the project-level Conan API.
The resulting URL is missing is project's `/<id>` and Conan commands, like
`conan install`, fail.
For more information, see [issue 270129](https://gitlab.com/gitlab-org/gitlab/-/issues/270129).
......@@ -14,7 +14,8 @@ module API
package,
current_user,
project,
conan_package_reference: params[:conan_package_reference]
conan_package_reference: params[:conan_package_reference],
id: params[:id]
)
render_api_error!("No recipe manifest found", 404) if yield(presenter).empty?
......
......@@ -41,13 +41,6 @@ RSpec.shared_context 'conan recipe endpoints' do
let(:jwt) { build_jwt(personal_access_token) }
let(:headers) { build_token_auth_header(jwt.encoded) }
let(:conan_package_reference) { '123456789' }
let(:presenter) { double('::Packages::Conan::PackagePresenter') }
before do
allow(::Packages::Conan::PackagePresenter).to receive(:new)
.with(package, user, package.project, any_args)
.and_return(presenter)
end
end
RSpec.shared_context 'conan file download endpoints' do
......
......@@ -205,6 +205,14 @@ RSpec.shared_examples 'empty recipe for not found package' do
'aa/bb/%{project}/ccc' % { project: ::Packages::Conan::Metadatum.package_username_from(full_path: project.full_path) }
end
let(:presenter) { double('::Packages::Conan::PackagePresenter') }
before do
allow(::Packages::Conan::PackagePresenter).to receive(:new)
.with(package, user, package.project, any_args)
.and_return(presenter)
end
it 'returns not found' do
allow(::Packages::Conan::PackagePresenter).to receive(:new)
.with(
......@@ -248,8 +256,6 @@ RSpec.shared_examples 'recipe download_urls' do
'conanmanifest.txt' => "#{url_prefix}/packages/conan/v1/files/#{package.conan_recipe_path}/0/export/conanmanifest.txt"
}
allow(presenter).to receive(:recipe_urls) { expected_response }
subject
expect(json_response).to eq(expected_response)
......@@ -268,8 +274,6 @@ RSpec.shared_examples 'package download_urls' do
'conan_package.tgz' => "#{url_prefix}/packages/conan/v1/files/#{package.conan_recipe_path}/0/package/123456789/0/conan_package.tgz"
}
allow(presenter).to receive(:package_urls) { expected_response }
subject
expect(json_response).to eq(expected_response)
......@@ -309,13 +313,14 @@ RSpec.shared_examples 'recipe snapshot endpoint' do
context 'with existing package' do
it 'returns a hash of files with their md5 hashes' do
conan_file_file = package.package_files.find_by(file_name: 'conanfile.py')
conan_manifest_file = package.package_files.find_by(file_name: 'conanmanifest.txt')
expected_response = {
'conanfile.py' => 'md5hash1',
'conanmanifest.txt' => 'md5hash2'
'conanfile.py' => conan_file_file.file_md5,
'conanmanifest.txt' => conan_manifest_file.file_md5
}
allow(presenter).to receive(:recipe_snapshot) { expected_response }
subject
expect(json_response).to eq(expected_response)
......@@ -333,13 +338,11 @@ RSpec.shared_examples 'package snapshot endpoint' do
context 'with existing package' do
it 'returns a hash of md5 values for the files' do
expected_response = {
'conaninfo.txt' => "md5hash1",
'conanmanifest.txt' => "md5hash2",
'conan_package.tgz' => "md5hash3"
'conaninfo.txt' => "12345abcde",
'conanmanifest.txt' => "12345abcde",
'conan_package.tgz' => "12345abcde"
}
allow(presenter).to receive(:package_snapshot) { expected_response }
subject
expect(json_response).to eq(expected_response)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment