Fix reconfig_credential() to send the xml data

Previously, reconfig_credential() passed empty `data` with
`Content-Length: 0` to the credentials configuration rather
than the credentials data.

This patch fixes the issue by passing the config_xml data to
the configuration API to properly update the credential.

Change-Id: Idef50f5a31d55991698b6217f55f15a9308b8526
This commit is contained in:
Jeff Schroeder 2019-08-07 21:05:03 -05:00 committed by Thanh Ha
parent 36c99d3436
commit 9bf7f81509
No known key found for this signature in database
GPG Key ID: 5783F720616E3180
2 changed files with 11 additions and 2 deletions

View File

@ -2136,9 +2136,14 @@ class Jenkins(object):
folder_url, short_name = self._get_job_folder(folder_name)
name = self._get_tag_text('id', config_xml)
self.assert_credential_exists(name, folder_name, domain_name)
reconfig_url = self._build_url(CONFIG_CREDENTIAL, locals())
self.jenkins_open(requests.Request(
'POST', self._build_url(CONFIG_CREDENTIAL, locals())
))
'POST', reconfig_url,
data=config_xml.encode('utf-8'),
headers=DEFAULT_HEADERS
))
def list_credentials(self, folder_name, domain_name='_'):
'''List credentials in domain of folder

View File

@ -332,6 +332,10 @@ class JenkinsReconfigCredentialTest(JenkinsCredentialTestBase):
jenkins_mock.call_args_list[2][0][0].url,
self.make_url('job/Test%20Folder/credentials/store/folder/domain/'
'_/credential/Test%20Credential/config.xml'))
self.assertEqual(
jenkins_mock.call_args_list[2][0][0].data,
self.config_xml.encode('utf-8'))
self._check_requests(jenkins_mock.call_args_list)