Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check and raise for wrong ConanCenter URL #14531

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions conans/client/cache/remote_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def _validate_url(self, url):
:param url: URL to be validated
"""
if url:
if url.startswith("https://conan.io/center"):
raise ConanException("Wrong ConanCenter remote URL. You are adding the web "
"https://conan.io/center the correct remote API is "
"https://center.conan.io")
address = urlparse(url)
if not all([address.scheme, address.netloc]):
self._output.warning("The URL '%s' is invalid. It must contain scheme and hostname."
Expand Down
12 changes: 12 additions & 0 deletions conans/test/integration/command/remote_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,15 @@ def test_add_duplicated_name_url():
assert "WARN: Remote 'remote1' already exists in remotes" in c.out
c.run("remote list")
assert 1 == str(c.out).count("remote1")


def test_add_wrong_conancenter():
""" Avoid common error of adding the wrong ConanCenter URL
"""
c = TestClient()
c.run("remote add whatever https://conan.io/center", assert_error=True)
assert "Wrong ConanCenter remote URL. You are adding the web https://conan.io/center" in c.out
assert "the correct remote API is https://center.conan.io" in c.out
c.run("remote update conancenter --url=https://conan.io/center", assert_error=True)
assert "Wrong ConanCenter remote URL. You are adding the web https://conan.io/center" in c.out
assert "the correct remote API is https://center.conan.io" in c.out