|
|
@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
import socket
|
|
|
|
import socket
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.six import StringIO
|
|
|
|
from ansible.module_utils.six import StringIO
|
|
|
|
from ansible.module_utils.six.moves.http_cookiejar import Cookie
|
|
|
|
from ansible.module_utils.six.moves.http_cookiejar import Cookie
|
|
|
@ -133,9 +134,16 @@ def test_fetch_url_cookies(mocker, fake_ansible_module):
|
|
|
|
r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')
|
|
|
|
r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')
|
|
|
|
|
|
|
|
|
|
|
|
assert info['cookies'] == {'Baz': 'qux', 'Foo': 'bar'}
|
|
|
|
assert info['cookies'] == {'Baz': 'qux', 'Foo': 'bar'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info < (3, 11):
|
|
|
|
# Python sorts cookies in order of most specific (ie. longest) path first
|
|
|
|
# Python sorts cookies in order of most specific (ie. longest) path first
|
|
|
|
# items with the same path are reversed from response order
|
|
|
|
# items with the same path are reversed from response order
|
|
|
|
assert info['cookies_string'] == 'Baz=qux; Foo=bar'
|
|
|
|
assert info['cookies_string'] == 'Baz=qux; Foo=bar'
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# Python 3.11 and later preserve the Set-Cookie order.
|
|
|
|
|
|
|
|
# See: https://github.com/python/cpython/pull/22745/
|
|
|
|
|
|
|
|
assert info['cookies_string'] == 'Foo=bar; Baz=qux'
|
|
|
|
|
|
|
|
|
|
|
|
# The key here has a `-` as opposed to what we see in the `uri` module that converts to `_`
|
|
|
|
# The key here has a `-` as opposed to what we see in the `uri` module that converts to `_`
|
|
|
|
# Note: this is response order, which differs from cookies_string
|
|
|
|
# Note: this is response order, which differs from cookies_string
|
|
|
|
assert info['set-cookie'] == 'Foo=bar, Baz=qux'
|
|
|
|
assert info['set-cookie'] == 'Foo=bar, Baz=qux'
|
|
|
|