mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Clean up ACI error text (#30501)
* Clean up ACI error text * Get rid of explicit unicode strings, use PY2
This commit is contained in:
parent
83ef5237cd
commit
6a6f88d035
1 changed files with 107 additions and 136 deletions
|
@ -32,7 +32,7 @@ try:
|
||||||
if sys.version_info >= (2, 7):
|
if sys.version_info >= (2, 7):
|
||||||
from xmljson import cobra
|
from xmljson import cobra
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise SkipTest("aci Ansible modules require the lxml and xmljson Python libraries")
|
raise SkipTest("ACI Ansible modules require the lxml and xmljson Python libraries")
|
||||||
|
|
||||||
|
|
||||||
class AciRest(unittest.TestCase):
|
class AciRest(unittest.TestCase):
|
||||||
|
@ -41,17 +41,17 @@ class AciRest(unittest.TestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
expected_result = {
|
expected_result = {
|
||||||
u'error_code': u'401',
|
'error_code': '401',
|
||||||
u'error_text': u'Username or password is incorrect - FAILED local authentication',
|
'error_text': 'Username or password is incorrect - FAILED local authentication',
|
||||||
u'imdata': [{
|
'imdata': [{
|
||||||
u'error': {
|
'error': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'code': u'401',
|
'code': '401',
|
||||||
u'text': u'Username or password is incorrect - FAILED local authentication',
|
'text': 'Username or password is incorrect - FAILED local authentication',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
u'totalCount': '1',
|
'totalCount': '1',
|
||||||
}
|
}
|
||||||
|
|
||||||
json_response = '{"totalCount":"1","imdata":[{"error":{"attributes":{"code":"401","text":"Username or password is incorrect - FAILED local authentication"}}}]}' # NOQA
|
json_response = '{"totalCount":"1","imdata":[{"error":{"attributes":{"code":"401","text":"Username or password is incorrect - FAILED local authentication"}}}]}' # NOQA
|
||||||
|
@ -75,47 +75,47 @@ class AciRest(unittest.TestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
expected_result = {
|
expected_result = {
|
||||||
u'error_code': 0,
|
'error_code': 0,
|
||||||
u'error_text': u'Success',
|
'error_text': 'Success',
|
||||||
u'imdata': [{
|
'imdata': [{
|
||||||
u'aaaLogin': {
|
'aaaLogin': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'token': u'ZldYAsoO9d0FfAQM8xaEVWvQPSOYwpnqzhwpIC1r4MaToknJjlIuAt9+TvXqrZ8lWYIGPj6VnZkWiS8nJfaiaX/AyrdD35jsSxiP3zydh+849xym7ALCw/fFNsc7b5ik1HaMuSUtdrN8fmCEUy7Pq/QNpGEqkE8m7HaxAuHpmvXgtdW1bA+KKJu2zY1c/tem', # NOQA
|
'token': 'ZldYAsoO9d0FfAQM8xaEVWvQPSOYwpnqzhwpIC1r4MaToknJjlIuAt9+TvXqrZ8lWYIGPj6VnZkWiS8nJfaiaX/AyrdD35jsSxiP3zydh+849xym7ALCw/fFNsc7b5ik1HaMuSUtdrN8fmCEUy7Pq/QNpGEqkE8m7HaxAuHpmvXgtdW1bA+KKJu2zY1c/tem', # NOQA
|
||||||
u'siteFingerprint': u'NdxD72K/uXaUK0wn',
|
'siteFingerprint': 'NdxD72K/uXaUK0wn',
|
||||||
u'refreshTimeoutSeconds': u'600',
|
'refreshTimeoutSeconds': '600',
|
||||||
u'maximumLifetimeSeconds': u'86400',
|
'maximumLifetimeSeconds': '86400',
|
||||||
u'guiIdleTimeoutSeconds': u'1200',
|
'guiIdleTimeoutSeconds': '1200',
|
||||||
u'restTimeoutSeconds': u'90',
|
'restTimeoutSeconds': '90',
|
||||||
u'creationTime': u'1500134817',
|
'creationTime': '1500134817',
|
||||||
u'firstLoginTime': u'1500134817',
|
'firstLoginTime': '1500134817',
|
||||||
u'userName': u'admin',
|
'userName': 'admin',
|
||||||
u'remoteUser': u'false',
|
'remoteUser': 'false',
|
||||||
u'unixUserId': u'15374',
|
'unixUserId': '15374',
|
||||||
u'sessionId': u'o7hObsqNTfCmDGcZI5c4ng==',
|
'sessionId': 'o7hObsqNTfCmDGcZI5c4ng==',
|
||||||
u'lastName': u'',
|
'lastName': '',
|
||||||
u'firstName': u'',
|
'firstName': '',
|
||||||
u'version': u'2.0(2f)',
|
'version': '2.0(2f)',
|
||||||
u'buildTime': u'Sat Aug 20 23:07:07 PDT 2016',
|
'buildTime': 'Sat Aug 20 23:07:07 PDT 2016',
|
||||||
u'node': u'topology/pod-1/node-1',
|
'node': 'topology/pod-1/node-1',
|
||||||
},
|
},
|
||||||
u'children': [{
|
'children': [{
|
||||||
u'aaaUserDomain': {
|
'aaaUserDomain': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'name': u'all',
|
'name': 'all',
|
||||||
u'rolesR': u'admin',
|
'rolesR': 'admin',
|
||||||
u'rolesW': u'admin',
|
'rolesW': 'admin',
|
||||||
},
|
},
|
||||||
u'children': [{
|
'children': [{
|
||||||
u'aaaReadRoles': {
|
'aaaReadRoles': {
|
||||||
u'attributes': {},
|
'attributes': {},
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
u'aaaWriteRoles': {
|
'aaaWriteRoles': {
|
||||||
u'attributes': {},
|
'attributes': {},
|
||||||
u'children': [{
|
'children': [{
|
||||||
u'role': {
|
'role': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'name': u'admin',
|
'name': 'admin',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
|
@ -123,33 +123,33 @@ class AciRest(unittest.TestCase):
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
u'DnDomainMapEntry': {
|
'DnDomainMapEntry': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'dn': u'uni/tn-common',
|
'dn': 'uni/tn-common',
|
||||||
u'readPrivileges': u'admin',
|
'readPrivileges': 'admin',
|
||||||
u'writePrivileges': u'admin',
|
'writePrivileges': 'admin',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
u'DnDomainMapEntry': {
|
'DnDomainMapEntry': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'dn': u'uni/tn-infra',
|
'dn': 'uni/tn-infra',
|
||||||
u'readPrivileges': u'admin',
|
'readPrivileges': 'admin',
|
||||||
u'writePrivileges': u'admin',
|
'writePrivileges': 'admin',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
u'DnDomainMapEntry': {
|
'DnDomainMapEntry': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'dn': u'uni/tn-mgmt',
|
'dn': 'uni/tn-mgmt',
|
||||||
u'readPrivileges': u'admin',
|
'readPrivileges': 'admin',
|
||||||
u'writePrivileges': u'admin',
|
'writePrivileges': 'admin',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
u'totalCount': u'1',
|
'totalCount': '1',
|
||||||
}
|
}
|
||||||
|
|
||||||
json_response = '{"totalCount":"1","imdata":[{"aaaLogin":{"attributes":{"token":"ZldYAsoO9d0FfAQM8xaEVWvQPSOYwpnqzhwpIC1r4MaToknJjlIuAt9+TvXqrZ8lWYIGPj6VnZkWiS8nJfaiaX/AyrdD35jsSxiP3zydh+849xym7ALCw/fFNsc7b5ik1HaMuSUtdrN8fmCEUy7Pq/QNpGEqkE8m7HaxAuHpmvXgtdW1bA+KKJu2zY1c/tem","siteFingerprint":"NdxD72K/uXaUK0wn","refreshTimeoutSeconds":"600","maximumLifetimeSeconds":"86400","guiIdleTimeoutSeconds":"1200","restTimeoutSeconds":"90","creationTime":"1500134817","firstLoginTime":"1500134817","userName":"admin","remoteUser":"false","unixUserId":"15374","sessionId":"o7hObsqNTfCmDGcZI5c4ng==","lastName":"","firstName":"","version":"2.0(2f)","buildTime":"Sat Aug 20 23:07:07 PDT 2016","node":"topology/pod-1/node-1"},"children":[{"aaaUserDomain":{"attributes":{"name":"all","rolesR":"admin","rolesW":"admin"},"children":[{"aaaReadRoles":{"attributes":{}}},{"aaaWriteRoles":{"attributes":{},"children":[{"role":{"attributes":{"name":"admin"}}}]}}]}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-common","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-infra","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-mgmt","readPrivileges":"admin","writePrivileges":"admin"}}}]}}]}' # NOQA
|
json_response = '{"totalCount":"1","imdata":[{"aaaLogin":{"attributes":{"token":"ZldYAsoO9d0FfAQM8xaEVWvQPSOYwpnqzhwpIC1r4MaToknJjlIuAt9+TvXqrZ8lWYIGPj6VnZkWiS8nJfaiaX/AyrdD35jsSxiP3zydh+849xym7ALCw/fFNsc7b5ik1HaMuSUtdrN8fmCEUy7Pq/QNpGEqkE8m7HaxAuHpmvXgtdW1bA+KKJu2zY1c/tem","siteFingerprint":"NdxD72K/uXaUK0wn","refreshTimeoutSeconds":"600","maximumLifetimeSeconds":"86400","guiIdleTimeoutSeconds":"1200","restTimeoutSeconds":"90","creationTime":"1500134817","firstLoginTime":"1500134817","userName":"admin","remoteUser":"false","unixUserId":"15374","sessionId":"o7hObsqNTfCmDGcZI5c4ng==","lastName":"","firstName":"","version":"2.0(2f)","buildTime":"Sat Aug 20 23:07:07 PDT 2016","node":"topology/pod-1/node-1"},"children":[{"aaaUserDomain":{"attributes":{"name":"all","rolesR":"admin","rolesW":"admin"},"children":[{"aaaReadRoles":{"attributes":{}}},{"aaaWriteRoles":{"attributes":{},"children":[{"role":{"attributes":{"name":"admin"}}}]}}]}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-common","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-infra","readPrivileges":"admin","writePrivileges":"admin"}}},{"DnDomainMapEntry":{"attributes":{"dn":"uni/tn-mgmt","readPrivileges":"admin","writePrivileges":"admin"}}}]}}]}' # NOQA
|
||||||
|
@ -170,17 +170,17 @@ class AciRest(unittest.TestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
expected_result = {
|
expected_result = {
|
||||||
u'error_code': u'401',
|
'error_code': '401',
|
||||||
u'error_text': u'Username or password is incorrect - FAILED local authentication',
|
'error_text': 'Username or password is incorrect - FAILED local authentication',
|
||||||
u'imdata': [{
|
'imdata': [{
|
||||||
u'error': {
|
'error': {
|
||||||
u'attributes': {
|
'attributes': {
|
||||||
u'code': u'401',
|
'code': '401',
|
||||||
u'text': u'Username or password is incorrect - FAILED local authentication',
|
'text': 'Username or password is incorrect - FAILED local authentication',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
u'totalCount': '1',
|
'totalCount': '1',
|
||||||
}
|
}
|
||||||
|
|
||||||
json_response = '{"totalCount":"1","imdata":[{"error":{"attributes":{"code":"401","text":"Username or password is incorrect - FAILED local authentication"}}}]}' # NOQA
|
json_response = '{"totalCount":"1","imdata":[{"error":{"attributes":{"code":"401","text":"Username or password is incorrect - FAILED local authentication"}}}]}' # NOQA
|
||||||
|
@ -204,18 +204,15 @@ class AciRest(unittest.TestCase):
|
||||||
self.maxDiffi = None
|
self.maxDiffi = None
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
expected_json_result = {
|
error_text = "Unable to parse output as JSON, see 'raw' output. No JSON object could be decoded"
|
||||||
'error_code': -1,
|
|
||||||
'error_text': "Unable to parse output as JSON, see 'raw' output. No JSON object could be decoded",
|
|
||||||
'raw': '',
|
|
||||||
}
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
expected_json_result = {
|
error_text = "Unable to parse output as JSON, see 'raw' output. Expecting value: line 1 column 1 (char 0)"
|
||||||
u'error_code': -1,
|
|
||||||
u'error_text': u"Unable to parse output as JSON, see 'raw' output. Expecting value: line 1 column 1 (char 0)",
|
expected_json_result = {
|
||||||
u'raw': u'',
|
'error_code': -1,
|
||||||
}
|
'error_text': error_text,
|
||||||
|
'raw': '',
|
||||||
|
}
|
||||||
|
|
||||||
json_response = ''
|
json_response = ''
|
||||||
json_result = dict()
|
json_result = dict()
|
||||||
|
@ -227,31 +224,19 @@ class AciRest(unittest.TestCase):
|
||||||
return
|
return
|
||||||
|
|
||||||
elif etree.LXML_VERSION < (3, 3, 0, 0):
|
elif etree.LXML_VERSION < (3, 3, 0, 0):
|
||||||
expected_xml_result = {
|
error_text = "Unable to parse output as XML, see 'raw' output. None",
|
||||||
'error_code': -1,
|
|
||||||
'error_text': "Unable to parse output as XML, see 'raw' output. None",
|
|
||||||
'raw': '',
|
|
||||||
}
|
|
||||||
|
|
||||||
elif etree.LXML_VERSION < (4, 0, 0, 0):
|
elif etree.LXML_VERSION < (4, 0, 0, 0):
|
||||||
error_text = to_native(u"Unable to parse output as XML, see 'raw' output. None (line 0)", errors='surrogate_or_strict')
|
error_text = to_native(u"Unable to parse output as XML, see 'raw' output. None (line 0)", errors='surrogate_or_strict')
|
||||||
expected_xml_result = {
|
elif PY2:
|
||||||
'error_code': -1,
|
error_text = "Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (line 1)"
|
||||||
'error_text': error_text,
|
|
||||||
'raw': '',
|
|
||||||
}
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if PY3:
|
error_text = "Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (<string>, line 1)"
|
||||||
error_text = u"Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (<string>, line 1)"
|
|
||||||
else:
|
|
||||||
error_text = "Unable to parse output as XML, see 'raw' output. Document is empty, line 1, column 1 (line 1)"
|
|
||||||
|
|
||||||
expected_xml_result = {
|
expected_xml_result = {
|
||||||
'error_code': -1,
|
'error_code': -1,
|
||||||
'error_text': error_text,
|
'error_text': error_text,
|
||||||
'raw': '',
|
'raw': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_response = ''
|
xml_response = ''
|
||||||
xml_result = dict()
|
xml_result = dict()
|
||||||
|
@ -262,25 +247,17 @@ class AciRest(unittest.TestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
if sys.version_info < (2, 7):
|
if sys.version_info < (2, 7):
|
||||||
expected_json_result = {
|
error_text = "Unable to parse output as JSON, see 'raw' output. Expecting object: line 1 column 8 (char 8)"
|
||||||
'error_code': -1,
|
elif PY2:
|
||||||
'error_text': "Unable to parse output as JSON, see 'raw' output. Expecting object: line 1 column 8 (char 8)",
|
error_text = "Unable to parse output as JSON, see 'raw' output. No JSON object could be decoded"
|
||||||
'raw': '{ "aaa":',
|
|
||||||
}
|
|
||||||
|
|
||||||
elif sys.version_info < (3, 0):
|
|
||||||
expected_json_result = {
|
|
||||||
'error_code': -1,
|
|
||||||
'error_text': "Unable to parse output as JSON, see 'raw' output. No JSON object could be decoded",
|
|
||||||
'raw': '{ "aaa":',
|
|
||||||
}
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
expected_json_result = {
|
error_text = "Unable to parse output as JSON, see 'raw' output. Expecting value: line 1 column 9 (char 8)"
|
||||||
u'error_code': -1,
|
|
||||||
u'error_text': u"Unable to parse output as JSON, see 'raw' output. Expecting value: line 1 column 9 (char 8)",
|
expected_json_result = {
|
||||||
u'raw': u'{ "aaa":',
|
'error_code': -1,
|
||||||
}
|
'error_text': error_text,
|
||||||
|
'raw': '{ "aaa":',
|
||||||
|
}
|
||||||
|
|
||||||
json_response = '{ "aaa":'
|
json_response = '{ "aaa":'
|
||||||
json_result = dict()
|
json_result = dict()
|
||||||
|
@ -292,25 +269,19 @@ class AciRest(unittest.TestCase):
|
||||||
return
|
return
|
||||||
|
|
||||||
elif etree.LXML_VERSION < (3, 3, 0, 0):
|
elif etree.LXML_VERSION < (3, 3, 0, 0):
|
||||||
expected_xml_result = {
|
error_text = "Unable to parse output as XML, see 'raw' output. Couldn't find end of Start Tag aaa line 1, line 1, column 5" # NOQA
|
||||||
'error_code': -1,
|
|
||||||
'error_text': "Unable to parse output as XML, see 'raw' output. Couldn't find end of Start Tag aaa line 1, line 1, column 5", # NOQA
|
|
||||||
'raw': '<aaa ',
|
|
||||||
}
|
|
||||||
|
|
||||||
elif sys.version_info < (3, 0):
|
elif PY2:
|
||||||
expected_xml_result = {
|
error_text = "Unable to parse output as XML, see 'raw' output. Couldn't find end of Start Tag aaa line 1, line 1, column 6 (line 1)" # NOQA
|
||||||
'error_code': -1,
|
|
||||||
'error_text': u"Unable to parse output as XML, see 'raw' output. Couldn't find end of Start Tag aaa line 1, line 1, column 6 (line 1)", # NOQA
|
|
||||||
'raw': u'<aaa ',
|
|
||||||
}
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
expected_xml_result = {
|
error_text = "Unable to parse output as XML, see 'raw' output. Couldn't find end of Start Tag aaa line 1, line 1, column 6 (<string>, line 1)" # NOQA
|
||||||
u'error_code': -1,
|
|
||||||
u'error_text': u"Unable to parse output as XML, see 'raw' output. Couldn't find end of Start Tag aaa line 1, line 1, column 6 (<string>, line 1)", # NOQA
|
expected_xml_result = {
|
||||||
u'raw': u'<aaa ',
|
'error_code': -1,
|
||||||
}
|
'error_text': error_text,
|
||||||
|
'raw': '<aaa ',
|
||||||
|
}
|
||||||
|
|
||||||
xml_response = '<aaa '
|
xml_response = '<aaa '
|
||||||
xml_result = dict()
|
xml_result = dict()
|
||||||
|
|
Loading…
Reference in a new issue