prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  CyberArk Conjur Secret Lookup - Versioning Does Not Work
  ### 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 providing a version number on the "Metadata" section of the CyberArk Conjur Secret Lookup External Secret Management System pane when defining a secret to retrieve on a credential, the secret value associated with the version number is not returned during execution of the job.  Regardless of the version number given, only the latest secret value is ever returned.
  
  ### AWX version
  
  Ansible Automation Platform Controller 4.1.1
  
  ### Select the relevant components
  
  - [ ] UI
  - [ ] API
  - [ ] Docs
  - [ ] Collection
  - [ ] CLI
  - [X] Other
  
  ### Installation method
  
  N/A
  
  ### Modifications
  
  no
  
  ### Ansible version
  
  ansible [core 2.12.2]
  
  ### Operating system
  
  Red Hat Enterprise Linux release 8.6 (Ootpa)
  
  ### Web browser
  
  _No response_
  
  ### Steps to reproduce
  
  1. Configure CyberArk Conjur Secret Lookup.
  2. Configure Credential to use External Secret Management System.
  3. On Metadata, provide a version number not equal to `null` or `1`.
  4. Run a job to execute a playbook that has `debug.msg` print the value to STDOUT.
  
  ### Expected results
  
  The value returned should change based on the version being requested by the External Secret Management System metadata.
  
  ### Actual results
  
  The latest version of the secret is always returned and versioning is ignored.
  
  ### Additional information
  
  ![image](https://user-images.githubusercontent.com/1924063/188949257-37a35059-82a2-4beb-8864-45f84466accd.png)
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `awx/main/credential_plugins/conjur.py`
  Content:
  ```
  1 from .plugin import CredentialPlugin, CertFiles, raise_for_status
  2 
  3 import base64
  4 from urllib.parse import urljoin, quote
  5 
  6 from django.utils.translation import gettext_lazy as _
  7 import requests
  8 
  9 
  10 conjur_inputs = {
  11     'fields': [
  12         {
  13             'id': 'url',
  14             'label': _('Conjur URL'),
  15             'type': 'string',
  16             'format': 'url',
  17         },
  18         {
  19             'id': 'api_key',
  20             'label': _('API Key'),
  21             'type': 'string',
  22             'secret': True,
  23         },
  24         {
  25             'id': 'account',
  26             'label': _('Account'),
  27             'type': 'string',
  28         },
  29         {
  30             'id': 'username',
  31             'label': _('Username'),
  32             'type': 'string',
  33         },
  34         {'id': 'cacert', 'label': _('Public Key Certificate'), 'type': 'string', 'multiline': True},
  35     ],
  36     'metadata': [
  37         {
  38             'id': 'secret_path',
  39             'label': _('Secret Identifier'),
  40             'type': 'string',
  41             'help_text': _('The identifier for the secret e.g., /some/identifier'),
  42         },
  43         {
  44             'id': 'secret_version',
  45             'label': _('Secret Version'),
  46             'type': 'string',
  47             'help_text': _('Used to specify a specific secret version (if left empty, the latest version will be used).'),
  48         },
  49     ],
  50     'required': ['url', 'api_key', 'account', 'username'],
  51 }
  52 
  53 
  54 def conjur_backend(**kwargs):
  55     url = kwargs['url']
  56     api_key = kwargs['api_key']
  57     account = quote(kwargs['account'], safe='')
  58     username = quote(kwargs['username'], safe='')
  59     secret_path = quote(kwargs['secret_path'], safe='')
  60     version = kwargs.get('secret_version')
  61     cacert = kwargs.get('cacert', None)
  62 
  63     auth_kwargs = {
  64         'headers': {'Content-Type': 'text/plain'},
  65         'data': api_key,
  66         'allow_redirects': False,
  67     }
  68 
  69     with CertFiles(cacert) as cert:
  70         # https://www.conjur.org/api.html#authentication-authenticate-post
  71         auth_kwargs['verify'] = cert
  72         resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)
  73     raise_for_status(resp)
  74     token = base64.b64encode(resp.content).decode('utf-8')
  75 
  76     lookup_kwargs = {
  77         'headers': {'Authorization': 'Token token="{}"'.format(token)},
  78         'allow_redirects': False,
  79     }
  80 
  81     # https://www.conjur.org/api.html#secrets-retrieve-a-secret-get
  82     path = urljoin(url, '/'.join(['secrets', account, 'variable', secret_path]))
  83     if version:
  84         path = '?'.join([path, version])
  85 
  86     with CertFiles(cacert) as cert:
  87         lookup_kwargs['verify'] = cert
  88         resp = requests.get(path, timeout=30, **lookup_kwargs)
  89     raise_for_status(resp)
  90     return resp.text
  91 
  92 
  93 conjur_plugin = CredentialPlugin('CyberArk Conjur Secret Lookup', inputs=conjur_inputs, backend=conjur_backend)
  94
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
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
  @@ -81,7 +81,8 @@
       # https://www.conjur.org/api.html#secrets-retrieve-a-secret-get
       path = urljoin(url, '/'.join(['secrets', account, 'variable', secret_path]))
       if version:
  -        path = '?'.join([path, version])
  +        ver = "version={}".format(version)
  +        path = '?'.join([path, ver])
   
       with CertFiles(cacert) as cert:
           lookup_kwargs['verify'] = cert
  
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@@ -81,7 +81,8 @@\n     # https://www.conjur.org/api.html#secrets-retrieve-a-secret-get\n     path = urljoin(url, '/'.join(['secrets', account, 'variable', secret_path]))\n     if version:\n-        path = '?'.join([path, version])\n+        ver = \"version={}\".format(version)\n+        path = '?'.join([path, ver])\n \n     with CertFiles(cacert) as cert:\n         lookup_kwargs['verify'] = cert\n", "issue": "CyberArk Conjur Secret Lookup - Versioning Does Not Work\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 providing a version number on the \"Metadata\" section of the CyberArk Conjur Secret Lookup External Secret Management System pane when defining a secret to retrieve on a credential, the secret value associated with the version number is not returned during execution of the job.  Regardless of the version number given, only the latest secret value is ever returned.\n\n### AWX version\n\nAnsible Automation Platform Controller 4.1.1\n\n### Select the relevant components\n\n- [ ] UI\n- [ ] API\n- [ ] Docs\n- [ ] Collection\n- [ ] CLI\n- [X] Other\n\n### Installation method\n\nN/A\n\n### Modifications\n\nno\n\n### Ansible version\n\nansible [core 2.12.2]\n\n### Operating system\n\nRed Hat Enterprise Linux release 8.6 (Ootpa)\n\n### Web browser\n\n_No response_\n\n### Steps to reproduce\n\n1. Configure CyberArk Conjur Secret Lookup.\r\n2. Configure Credential to use External Secret Management System.\r\n3. On Metadata, provide a version number not equal to `null` or `1`.\r\n4. Run a job to execute a playbook that has `debug.msg` print the value to STDOUT.\n\n### Expected results\n\nThe value returned should change based on the version being requested by the External Secret Management System metadata.\n\n### Actual results\n\nThe latest version of the secret is always returned and versioning is ignored.\n\n### Additional information\n\n![image](https://user-images.githubusercontent.com/1924063/188949257-37a35059-82a2-4beb-8864-45f84466accd.png)\r\n\n", "before_files": [{"content": "from .plugin import CredentialPlugin, CertFiles, raise_for_status\n\nimport base64\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'},\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        resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)\n    raise_for_status(resp)\n    token = base64.b64encode(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    if version:\n        path = '?'.join([path, version])\n\n    with CertFiles(cacert) as cert:\n        lookup_kwargs['verify'] = cert\n        resp = requests.get(path, timeout=30, **lookup_kwargs)\n    raise_for_status(resp)\n    return resp.text\n\n\nconjur_plugin = CredentialPlugin('CyberArk Conjur Secret Lookup', inputs=conjur_inputs, backend=conjur_backend)\n", "path": "awx/main/credential_plugins/conjur.py"}], "after_files": [{"content": "from .plugin import CredentialPlugin, CertFiles, raise_for_status\n\nimport base64\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'},\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        resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)\n    raise_for_status(resp)\n    token = base64.b64encode(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    if version:\n        ver = \"version={}\".format(version)\n        path = '?'.join([path, ver])\n\n    with CertFiles(cacert) as cert:\n        lookup_kwargs['verify'] = cert\n        resp = requests.get(path, timeout=30, **lookup_kwargs)\n    raise_for_status(resp)\n    return resp.text\n\n\nconjur_plugin = CredentialPlugin('CyberArk Conjur Secret Lookup', inputs=conjur_inputs, backend=conjur_backend)\n", "path": "awx/main/credential_plugins/conjur.py"}]}