diff options
-rw-r--r-- | test/integration/targets/uri/tasks/redirect-urllib2.yml | 105 |
1 files changed, 85 insertions, 20 deletions
diff --git a/test/integration/targets/uri/tasks/redirect-urllib2.yml b/test/integration/targets/uri/tasks/redirect-urllib2.yml index 73e879601b..9435db4758 100644 --- a/test/integration/targets/uri/tasks/redirect-urllib2.yml +++ b/test/integration/targets/uri/tasks/redirect-urllib2.yml @@ -1,4 +1,3 @@ -# NOTE: The HTTP HEAD turns into an HTTP GET - name: Test HTTP 301 using HEAD uri: url: https://{{ httpbin_host }}/redirect-to?status_code=301&url=https://{{ httpbin_host }}/anything @@ -10,13 +9,27 @@ - assert: that: - http_301_head is successful - - http_301_head.json.data == '' - - http_301_head.json.method == 'GET' - - http_301_head.json.url == 'https://{{ httpbin_host }}/anything' - http_301_head.redirected == true - http_301_head.status == 200 - http_301_head.url == 'https://{{ httpbin_host }}/anything' +# HTTP 301 responses on HEAD requests behave differently depending on the Python version +# see: https://github.com/python/cpython/issues/99730 + +- name: Check results on Python versions 3.13 and later + assert: + that: + - http_301_head.json is undefined + when: ansible_python_version is version("3.13", ">=") + +- name: Check results on Python versions before 3.13 + assert: + that: + - http_301_head.json.data == '' + - http_301_head.json.method == 'GET' + - http_301_head.json.url == 'https://{{ httpbin_host }}/anything' + when: ansible_python_version is version("3.13", "<") + - name: Test HTTP 301 using GET uri: url: https://{{ httpbin_host }}/redirect-to?status_code=301&url=https://{{ httpbin_host }}/anything @@ -56,7 +69,6 @@ - http_301_post.status == 200 - http_301_post.url == 'https://{{ httpbin_host }}/anything' -# NOTE: The HTTP HEAD turns into an HTTP GET - name: Test HTTP 302 using HEAD uri: url: https://{{ httpbin_host }}/redirect-to?status_code=302&url=https://{{ httpbin_host }}/anything @@ -68,13 +80,27 @@ - assert: that: - http_302_head is successful - - http_302_head.json.data == '' - - http_302_head.json.method == 'GET' - - http_302_head.json.url == 'https://{{ httpbin_host }}/anything' - http_302_head.redirected == true - http_302_head.status == 200 - http_302_head.url == 'https://{{ httpbin_host }}/anything' +# HTTP 302 responses on HEAD requests behave differently depending on the Python version +# see: https://github.com/python/cpython/issues/99730 + +- name: Check results on Python versions 3.13 and later + assert: + that: + - http_302_head.json is undefined + when: ansible_python_version is version("3.13", ">=") + +- name: Check results on Python versions before 3.13 + assert: + that: + - http_302_head.json.data == '' + - http_302_head.json.method == 'GET' + - http_302_head.json.url == 'https://{{ httpbin_host }}/anything' + when: ansible_python_version is version("3.13", "<") + - name: Test HTTP 302 using GET uri: url: https://{{ httpbin_host }}/redirect-to?status_code=302&url=https://{{ httpbin_host }}/anything @@ -114,7 +140,6 @@ - http_302_post.status == 200 - http_302_post.url == 'https://{{ httpbin_host }}/anything' -# NOTE: The HTTP HEAD turns into an HTTP GET - name: Test HTTP 303 using HEAD uri: url: https://{{ httpbin_host }}/redirect-to?status_code=303&url=https://{{ httpbin_host }}/anything @@ -126,13 +151,27 @@ - assert: that: - http_303_head is successful - - http_303_head.json.data == '' - - http_303_head.json.method == 'GET' - - http_303_head.json.url == 'https://{{ httpbin_host }}/anything' - http_303_head.redirected == true - http_303_head.status == 200 - http_303_head.url == 'https://{{ httpbin_host }}/anything' +# HTTP 303 responses on HEAD requests behave differently depending on the Python version +# see: https://github.com/python/cpython/issues/99730 + +- name: Check results on Python versions 3.13 and later + assert: + that: + - http_303_head.json is undefined + when: ansible_python_version is version("3.13", ">=") + +- name: Check results on Python versions before 3.13 + assert: + that: + - http_303_head.json.data == '' + - http_303_head.json.method == 'GET' + - http_303_head.json.url == 'https://{{ httpbin_host }}/anything' + when: ansible_python_version is version("3.13", "<") + - name: Test HTTP 303 using GET uri: url: https://{{ httpbin_host }}/redirect-to?status_code=303&url=https://{{ httpbin_host }}/anything @@ -172,7 +211,6 @@ - http_303_post.status == 200 - http_303_post.url == 'https://{{ httpbin_host }}/anything' -# NOTE: The HTTP HEAD turns into an HTTP GET - name: Test HTTP 307 using HEAD uri: url: https://{{ httpbin_host }}/redirect-to?status_code=307&url=https://{{ httpbin_host }}/anything @@ -184,13 +222,27 @@ - assert: that: - http_307_head is successful - - http_307_head.json.data == '' - - http_307_head.json.method == 'GET' - - http_307_head.json.url == 'https://{{ httpbin_host }}/anything' - http_307_head.redirected == true - http_307_head.status == 200 - http_307_head.url == 'https://{{ httpbin_host }}/anything' +# HTTP 307 responses on HEAD requests behave differently depending on the Python version +# see: https://github.com/python/cpython/issues/99730 + +- name: Check results on Python versions 3.13 and later + assert: + that: + - http_307_head.json is undefined + when: ansible_python_version is version("3.13", ">=") + +- name: Check results on Python versions before 3.13 + assert: + that: + - http_307_head.json.data == '' + - http_307_head.json.method == 'GET' + - http_307_head.json.url == 'https://{{ httpbin_host }}/anything' + when: ansible_python_version is version("3.13", "<") + - name: Test HTTP 307 using GET uri: url: https://{{ httpbin_host }}/redirect-to?status_code=307&url=https://{{ httpbin_host }}/anything @@ -254,13 +306,9 @@ # See: https://github.com/python/cpython/issues/84501 when: ansible_python_version is version('3.11', '<') -# NOTE: The HTTP HEAD turns into an HTTP GET - assert: that: - http_308_head is successful - - http_308_head.json.data == '' - - http_308_head.json.method == 'GET' - - http_308_head.json.url == 'https://{{ httpbin_host }}/anything' - http_308_head.redirected == true - http_308_head.status == 200 - http_308_head.url == 'https://{{ httpbin_host }}/anything' @@ -268,6 +316,23 @@ # See: https://github.com/python/cpython/issues/84501 when: ansible_python_version is version('3.11', '>=') +# HTTP 308 responses on HEAD requests behave differently depending on the Python version +# see: https://github.com/python/cpython/issues/99730 + +- name: Check results on Python versions 3.13 and later + assert: + that: + - http_308_head.json is undefined + when: ansible_python_version is version("3.13", ">=") + +- name: Check results on Python versions before 3.13 + assert: + that: + - http_308_head.json.data == '' + - http_308_head.json.method == 'GET' + - http_308_head.json.url == 'https://{{ httpbin_host }}/anything' + when: ansible_python_version is version('3.11', '>=') and ansible_python_version is version("3.13", "<") + # FIXME: This is fixed in https://github.com/ansible/ansible/pull/36809 - name: Test HTTP 308 using GET uri: |