prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Exception handling for Conjur Secrets Manager Lookup not working properly
  ### Please confirm the following
  
  - [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
  - [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
  - [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
  
  ### Bug Summary
  
  When using the Conjur Secrets Manager Lookup credential type against Conjur Cloud, exception handling does not properly switch to the proper URI endpoint automatically.  Any attempts currently fail with HTTP 404.
  
  ### AWX version
  
  0.1.dev32763+g3d73b80
  
  ### Select the relevant components
  
  - [X] UI
  - [ ] API
  - [ ] Docs
  - [ ] Collection
  - [ ] CLI
  - [ ] Other
  
  ### Installation method
  
  docker development environment
  
  ### Modifications
  
  no
  
  ### Ansible version
  
  _No response_
  
  ### Operating system
  
  _No response_
  
  ### Web browser
  
  _No response_
  
  ### Steps to reproduce
  
  1. Select "CyberArk Conjur Secrets Manager Lookup" as the credential type for a new credential object in AWX.
  2. Configure for a Conjur Cloud tenant.
  3. Run "Test" and a failure with "HTTP 404" is returned.
  
  ### Expected results
  
  The test should pass.
  
  ### Actual results
  
  The test fails with an HTTP 404 error code.
  
  ### Additional information
  
  This fix is being implemented in a PR within moments.
  
  </issue>
  <code>
  [start of awx/main/credential_plugins/conjur.py]
  1 from .plugin import CredentialPlugin, CertFiles, raise_for_status
  2 
  3 from urllib.parse import urljoin, quote
  4 
  5 from django.utils.translation import gettext_lazy as _
  6 import requests
  7 
  8 
  9 conjur_inputs = {
  10     'fields': [
  11         {
  12             'id': 'url',
  13             'label': _('Conjur URL'),
  14             'type': 'string',
  15             'format': 'url',
  16         },
  17         {
  18             'id': 'api_key',
  19             'label': _('API Key'),
  20             'type': 'string',
  21             'secret': True,
  22         },
  23         {
  24             'id': 'account',
  25             'label': _('Account'),
  26             'type': 'string',
  27         },
  28         {
  29             'id': 'username',
  30             'label': _('Username'),
  31             'type': 'string',
  32         },
  33         {'id': 'cacert', 'label': _('Public Key Certificate'), 'type': 'string', 'multiline': True},
  34     ],
  35     'metadata': [
  36         {
  37             'id': 'secret_path',
  38             'label': _('Secret Identifier'),
  39             'type': 'string',
  40             'help_text': _('The identifier for the secret e.g., /some/identifier'),
  41         },
  42         {
  43             'id': 'secret_version',
  44             'label': _('Secret Version'),
  45             'type': 'string',
  46             'help_text': _('Used to specify a specific secret version (if left empty, the latest version will be used).'),
  47         },
  48     ],
  49     'required': ['url', 'api_key', 'account', 'username'],
  50 }
  51 
  52 
  53 def conjur_backend(**kwargs):
  54     url = kwargs['url']
  55     api_key = kwargs['api_key']
  56     account = quote(kwargs['account'], safe='')
  57     username = quote(kwargs['username'], safe='')
  58     secret_path = quote(kwargs['secret_path'], safe='')
  59     version = kwargs.get('secret_version')
  60     cacert = kwargs.get('cacert', None)
  61 
  62     auth_kwargs = {
  63         'headers': {'Content-Type': 'text/plain', 'Accept-Encoding': 'base64'},
  64         'data': api_key,
  65         'allow_redirects': False,
  66     }
  67 
  68     with CertFiles(cacert) as cert:
  69         # https://www.conjur.org/api.html#authentication-authenticate-post
  70         auth_kwargs['verify'] = cert
  71         try:
  72             resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)
  73         except requests.exceptions.ConnectionError:
  74             resp = requests.post(urljoin(url, '/'.join(['api', 'authn', account, username, 'authenticate'])), **auth_kwargs)
  75     raise_for_status(resp)
  76     token = resp.content.decode('utf-8')
  77 
  78     lookup_kwargs = {
  79         'headers': {'Authorization': 'Token token="{}"'.format(token)},
  80         'allow_redirects': False,
  81     }
  82 
  83     # https://www.conjur.org/api.html#secrets-retrieve-a-secret-get
  84     path = urljoin(url, '/'.join(['secrets', account, 'variable', secret_path]))
  85     path_conjurcloud = urljoin(url, '/'.join(['api', 'secrets', account, 'variable', secret_path]))
  86     if version:
  87         ver = "version={}".format(version)
  88         path = '?'.join([path, ver])
  89         path_conjurcloud = '?'.join([path_conjurcloud, ver])
  90 
  91     with CertFiles(cacert) as cert:
  92         lookup_kwargs['verify'] = cert
  93         try:
  94             resp = requests.get(path, timeout=30, **lookup_kwargs)
  95         except requests.exceptions.ConnectionError:
  96             resp = requests.get(path_conjurcloud, timeout=30, **lookup_kwargs)
  97     raise_for_status(resp)
  98     return resp.text
  99 
  100 
  101 conjur_plugin = CredentialPlugin('CyberArk Conjur Secrets Manager Lookup', inputs=conjur_inputs, backend=conjur_backend)
  102
  [end of awx/main/credential_plugins/conjur.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/awx/main/credential_plugins/conjur.py b/awx/main/credential_plugins/conjur.py
  --- a/awx/main/credential_plugins/conjur.py
  +++ b/awx/main/credential_plugins/conjur.py
  @@ -70,7 +70,8 @@
           auth_kwargs['verify'] = cert
           try:
               resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)
  -        except requests.exceptions.ConnectionError:
  +            resp.raise_for_status()
  +        except requests.exceptions.HTTPError:
               resp = requests.post(urljoin(url, '/'.join(['api', 'authn', account, username, 'authenticate'])), **auth_kwargs)
       raise_for_status(resp)
       token = resp.content.decode('utf-8')
  @@ -92,7 +93,8 @@
           lookup_kwargs['verify'] = cert
           try:
               resp = requests.get(path, timeout=30, **lookup_kwargs)
  -        except requests.exceptions.ConnectionError:
  +            resp.raise_for_status()
  +        except requests.exceptions.HTTPError:
               resp = requests.get(path_conjurcloud, timeout=30, **lookup_kwargs)
       raise_for_status(resp)
       return resp.text
  
verification_info: {"golden_diff": "diff --git a/awx/main/credential_plugins/conjur.py b/awx/main/credential_plugins/conjur.py\n--- a/awx/main/credential_plugins/conjur.py\n+++ b/awx/main/credential_plugins/conjur.py\n@@ -70,7 +70,8 @@\n         auth_kwargs['verify'] = cert\n         try:\n             resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)\n-        except requests.exceptions.ConnectionError:\n+            resp.raise_for_status()\n+        except requests.exceptions.HTTPError:\n             resp = requests.post(urljoin(url, '/'.join(['api', 'authn', account, username, 'authenticate'])), **auth_kwargs)\n     raise_for_status(resp)\n     token = resp.content.decode('utf-8')\n@@ -92,7 +93,8 @@\n         lookup_kwargs['verify'] = cert\n         try:\n             resp = requests.get(path, timeout=30, **lookup_kwargs)\n-        except requests.exceptions.ConnectionError:\n+            resp.raise_for_status()\n+        except requests.exceptions.HTTPError:\n             resp = requests.get(path_conjurcloud, timeout=30, **lookup_kwargs)\n     raise_for_status(resp)\n     return resp.text\n", "issue": "Exception handling for Conjur Secrets Manager Lookup not working properly\n### Please confirm the following\n\n- [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).\n- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.\n- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.\n\n### Bug Summary\n\nWhen using the Conjur Secrets Manager Lookup credential type against Conjur Cloud, exception handling does not properly switch to the proper URI endpoint automatically.  Any attempts currently fail with HTTP 404.\n\n### AWX version\n\n0.1.dev32763+g3d73b80\n\n### Select the relevant components\n\n- [X] UI\n- [ ] API\n- [ ] Docs\n- [ ] Collection\n- [ ] CLI\n- [ ] Other\n\n### Installation method\n\ndocker development environment\n\n### Modifications\n\nno\n\n### Ansible version\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Web browser\n\n_No response_\n\n### Steps to reproduce\n\n1. Select \"CyberArk Conjur Secrets Manager Lookup\" as the credential type for a new credential object in AWX.\r\n2. Configure for a Conjur Cloud tenant.\r\n3. Run \"Test\" and a failure with \"HTTP 404\" is returned.\n\n### Expected results\n\nThe test should pass.\n\n### Actual results\n\nThe test fails with an HTTP 404 error code.\n\n### Additional information\n\nThis fix is being implemented in a PR within moments.\n", "before_files": [{"content": "from .plugin import CredentialPlugin, CertFiles, raise_for_status\n\nfrom urllib.parse import urljoin, quote\n\nfrom django.utils.translation import gettext_lazy as _\nimport requests\n\n\nconjur_inputs = {\n    'fields': [\n        {\n            'id': 'url',\n            'label': _('Conjur URL'),\n            'type': 'string',\n            'format': 'url',\n        },\n        {\n            'id': 'api_key',\n            'label': _('API Key'),\n            'type': 'string',\n            'secret': True,\n        },\n        {\n            'id': 'account',\n            'label': _('Account'),\n            'type': 'string',\n        },\n        {\n            'id': 'username',\n            'label': _('Username'),\n            'type': 'string',\n        },\n        {'id': 'cacert', 'label': _('Public Key Certificate'), 'type': 'string', 'multiline': True},\n    ],\n    'metadata': [\n        {\n            'id': 'secret_path',\n            'label': _('Secret Identifier'),\n            'type': 'string',\n            'help_text': _('The identifier for the secret e.g., /some/identifier'),\n        },\n        {\n            'id': 'secret_version',\n            'label': _('Secret Version'),\n            'type': 'string',\n            'help_text': _('Used to specify a specific secret version (if left empty, the latest version will be used).'),\n        },\n    ],\n    'required': ['url', 'api_key', 'account', 'username'],\n}\n\n\ndef conjur_backend(**kwargs):\n    url = kwargs['url']\n    api_key = kwargs['api_key']\n    account = quote(kwargs['account'], safe='')\n    username = quote(kwargs['username'], safe='')\n    secret_path = quote(kwargs['secret_path'], safe='')\n    version = kwargs.get('secret_version')\n    cacert = kwargs.get('cacert', None)\n\n    auth_kwargs = {\n        'headers': {'Content-Type': 'text/plain', 'Accept-Encoding': 'base64'},\n        'data': api_key,\n        'allow_redirects': False,\n    }\n\n    with CertFiles(cacert) as cert:\n        # https://www.conjur.org/api.html#authentication-authenticate-post\n        auth_kwargs['verify'] = cert\n        try:\n            resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)\n        except requests.exceptions.ConnectionError:\n            resp = requests.post(urljoin(url, '/'.join(['api', 'authn', account, username, 'authenticate'])), **auth_kwargs)\n    raise_for_status(resp)\n    token = resp.content.decode('utf-8')\n\n    lookup_kwargs = {\n        'headers': {'Authorization': 'Token token=\"{}\"'.format(token)},\n        'allow_redirects': False,\n    }\n\n    # https://www.conjur.org/api.html#secrets-retrieve-a-secret-get\n    path = urljoin(url, '/'.join(['secrets', account, 'variable', secret_path]))\n    path_conjurcloud = urljoin(url, '/'.join(['api', 'secrets', account, 'variable', secret_path]))\n    if version:\n        ver = \"version={}\".format(version)\n        path = '?'.join([path, ver])\n        path_conjurcloud = '?'.join([path_conjurcloud, ver])\n\n    with CertFiles(cacert) as cert:\n        lookup_kwargs['verify'] = cert\n        try:\n            resp = requests.get(path, timeout=30, **lookup_kwargs)\n        except requests.exceptions.ConnectionError:\n            resp = requests.get(path_conjurcloud, timeout=30, **lookup_kwargs)\n    raise_for_status(resp)\n    return resp.text\n\n\nconjur_plugin = CredentialPlugin('CyberArk Conjur Secrets Manager Lookup', inputs=conjur_inputs, backend=conjur_backend)\n", "path": "awx/main/credential_plugins/conjur.py"}]}