浏览代码

HUE-7124 [frontend] Fix global search escaping test to allow <em>

Romain Rigaux 8 年之前
父节点
当前提交
6677f7b
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      desktop/core/src/desktop/api2_tests.py

+ 8 - 4
desktop/core/src/desktop/api2_tests.py

@@ -17,6 +17,7 @@
 # limitations under the License.
 
 import json
+import re
 
 from nose.tools import assert_true, assert_false, assert_equal, assert_not_equal, assert_raises
 
@@ -46,9 +47,12 @@ class TestApi2():
       })
       results = json.loads(response.content)['results']
       assert_true(results)
-      assert_false('<' in json.dumps(results))
-      assert_false('>' in json.dumps(results))
-      assert_true('&lt;' in json.dumps(results))
-      assert_true('&gt;' in json.dumps(results))
+      result_json = json.dumps(results)
+      assert_false(re.match('<(?!em)', result_json), result_json)
+      assert_false(re.match('(?!em)>', result_json), result_json)
+      assert_false('<script>' in result_json, result_json)
+      assert_false('</script>' in result_json, result_json)
+      assert_true('&lt;' in result_json, result_json)
+      assert_true('&gt;' in result_json, result_json)
     finally:
       query.delete()