From 5c98ffc0c57fe98d0a99cc75cdc196050a5898b4 Mon Sep 17 00:00:00 2001 From: Allen Ji Date: Tue, 5 May 2020 21:52:30 -0400 Subject: [PATCH 1/3] Add step in client init to check for creds --- pubtools/pulplib/_impl/client/client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pubtools/pulplib/_impl/client/client.py b/pubtools/pulplib/_impl/client/client.py index 229ff95a..61654f8f 100644 --- a/pubtools/pulplib/_impl/client/client.py +++ b/pubtools/pulplib/_impl/client/client.py @@ -162,6 +162,13 @@ def __init__(self, url, **kwargs): .with_retry(retry_policy=self._RETRY_POLICY) ) + # run an initial auth request to validate url and credentials + # failed response status will raise exception + url = os.path.join(self._url, "pulp/api/v2/actions/login/") + res = self._do_request(method="POST", url=url, json={}) + self._unpack_response(res) + + def get_repository(self, repository_id): """Get a repository by ID. From 47166738d4f531a805837d106d7241ae177f2fda Mon Sep 17 00:00:00 2001 From: Allen Ji Date: Tue, 5 May 2020 23:27:58 -0400 Subject: [PATCH 2/3] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e04865f9..adcdf764 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def get_requirements(): setup( name="pubtools-pulplib", - version="2.6.1", + version="2.6.2", packages=find_packages(exclude=["tests"]), package_data={"pubtools.pulplib._impl.schema": ["*.yaml"]}, url="https://github.com/release-engineering/pubtools-pulplib", From d9c28e190ed8abf1c56f8908b059cc0eb5f0d4d9 Mon Sep 17 00:00:00 2001 From: Allen Ji Date: Tue, 5 May 2020 23:41:24 -0400 Subject: [PATCH 3/3] raise error directly from response --- pubtools/pulplib/_impl/client/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pubtools/pulplib/_impl/client/client.py b/pubtools/pulplib/_impl/client/client.py index 61654f8f..895d174d 100644 --- a/pubtools/pulplib/_impl/client/client.py +++ b/pubtools/pulplib/_impl/client/client.py @@ -165,9 +165,8 @@ def __init__(self, url, **kwargs): # run an initial auth request to validate url and credentials # failed response status will raise exception url = os.path.join(self._url, "pulp/api/v2/actions/login/") - res = self._do_request(method="POST", url=url, json={}) - self._unpack_response(res) - + response = self._do_request(method="POST", url=url, json={}) + response.raise_for_status() def get_repository(self, repository_id): """Get a repository by ID.