Add content-type without spaces
In public cloud implementation, the tomcat module
(specifically tomcat-coyote) used by the api-gateway
will eliminate the space within the content-type,
e.g ret = ret + ";charset=" + this.characterEncoding;
In the current rfc7231 standard, all the following
content-type are permissible and equivalent:
test/html;charset=utf-8
test/html;charset=UTF-8
test/HTML;Charset="utf-8"
test/html; charset="utf-8"
(https://tools.ietf.org/html/rfc7231#section-3.1.1.1)
However in the current tempest rest_client setting,
there is no content-type without space defined in
JSON_ENC and TXT_ENC. This results in defcore test
failure for public cloud since after tomcat module
eliminates the space, the content-type will not be
recognized as a legitimate one.
This patch intends to solve this problem by providing
additional content-type without spaces as allowed in
rfc7231 to JSON_ENC and TXT_ENC so that defcore test
won't be blocked for public cloud implementation.
Change-Id: I718ef0e3ddae513cb911aca38985162027274001
Signed-off-by: zhipengh <huangzhipeng@huawei.com>
diff --git a/releasenotes/notes/add-content-type-without-spaces-b2c9b91b257814f3.yaml b/releasenotes/notes/add-content-type-without-spaces-b2c9b91b257814f3.yaml
new file mode 100644
index 0000000..0075a36
--- /dev/null
+++ b/releasenotes/notes/add-content-type-without-spaces-b2c9b91b257814f3.yaml
@@ -0,0 +1,9 @@
+---
+upgrade:
+ - The ``JSON_ENC`` and ``TXT_ENC`` option in the ``_error_checker``
+ section have been added with additional content-type which are
+ defined in RFC7231 but missing in the currnt rest_client.py file.
+ The lack of these additional content-type will cause defcore test
+ to fail for OpenStack public cloud which uses tomcat module in the
+ api gateway. The additions are ``application/json;charset=utf-8``,
+ ``text/html;charset=utf-8``,``text/plain;charset=utf-8``
\ No newline at end of file
diff --git a/tempest/lib/common/rest_client.py b/tempest/lib/common/rest_client.py
index f5bff20..3cd1453 100644
--- a/tempest/lib/common/rest_client.py
+++ b/tempest/lib/common/rest_client.py
@@ -731,12 +731,21 @@
if resp.status < 400:
return
- JSON_ENC = ['application/json', 'application/json; charset=utf-8']
+ # NOTE(zhipengh): There is a purposefully duplicate of content-type
+ # with the only difference is with or without spaces, as specified
+ # in RFC7231.
+ JSON_ENC = ['application/json', 'application/json; charset=utf-8',
+ 'application/json;charset=utf-8']
+
# NOTE(mtreinish): This is for compatibility with Glance and swift
# APIs. These are the return content types that Glance api v1
# (and occasionally swift) are using.
+ # NOTE(zhipengh): There is a purposefully duplicate of content-type
+ # with the only difference is with or without spaces, as specified
+ # in RFC7231.
TXT_ENC = ['text/plain', 'text/html', 'text/html; charset=utf-8',
- 'text/plain; charset=utf-8']
+ 'text/plain; charset=utf-8', 'text/html;charset=utf-8',
+ 'text/plain;charset=utf-8']
if ctype.lower() in JSON_ENC:
parse_resp = True