create_node: avoid double-encoding
Prior to this change, create_node() would double-encode certain url params: once when quote()'ing in _get_encoded_params(), and again in urlencode(). This would cause HTTP 400 errors when creating a node with a name that contains a url-encodable character, like "my+test+node". Reviewed-by: Alfredo Deza <adeza@redhat.com> Change-Id: I237e2988e168af81e623d3f065753f2e9b617696
This commit is contained in:
parent
2b69951603
commit
04c153cc0b
@ -287,7 +287,7 @@ class Jenkins(object):
|
||||
|
||||
if variables:
|
||||
if format_spec == CREATE_NODE:
|
||||
url_path = format_spec % urlencode(self._get_encoded_params(variables))
|
||||
url_path = format_spec % urlencode(variables)
|
||||
else:
|
||||
url_path = format_spec % self._get_encoded_params(variables)
|
||||
else:
|
||||
|
@ -253,6 +253,14 @@ class JenkinsCreateNodeTest(JenkinsNodesTestBase):
|
||||
actual)
|
||||
self._check_requests(jenkins_mock.call_args_list)
|
||||
|
||||
def test_build_url(self):
|
||||
j = jenkins.Jenkins('https://test.noexist/')
|
||||
# Note the use of a URL-encodable character "+" here.
|
||||
variables = {'name': '10.0.0.1+test-node'}
|
||||
result = j._build_url(jenkins.CREATE_NODE, variables=variables)
|
||||
expected = 'https://test.noexist/computer/doCreateItem?name=10.0.0.1%2Btest-node'
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
@patch.object(jenkins.Jenkins, 'jenkins_open')
|
||||
def test_already_exists(self, jenkins_mock):
|
||||
jenkins_mock.side_effect = [
|
||||
|
Loading…
Reference in New Issue
Block a user