Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests v24_features.py and v26_features.py fail on Ubuntu 16.04 #144

Open
LeonidVas opened this issue Jan 14, 2021 · 1 comment
Open

Tests v24_features.py and v26_features.py fail on Ubuntu 16.04 #144

LeonidVas opened this issue Jan 14, 2021 · 1 comment

Comments

@LeonidVas
Copy link

I tried to run the tests v24_features.py and v26_features.py, but my attempt failed.

└──╼ ./test/v24_features.py 
[+] Post/Put body
[+] Post body - error
[+] Body sould not pass
[+] Headers out
[+] Unescape issue
Traceback (most recent call last):
File "/home/leonid/work/mail/nginx_upstream_module/test/http_utils.py", line 223, in get
  res = urllib2.urlopen(req)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
  return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
  response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
  '_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
  result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1235, in http_open
  return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1202, in do_open
  h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/lib/python2.7/httplib.py", line 1103, in request
  self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1137, in _send_request
  self.putrequest(method, url, **skips)
File "/usr/lib/python2.7/httplib.py", line 968, in putrequest
  % (url, match.group()))
InvalidURL: URL can't contain control characters. '/unescape?a=some string with spaces' (found at least ' ')

Traceback (most recent call last):
File "./test/v24_features.py", line 46, in <module>
  result = get_success(preset_method_location, None, {})
File "/home/leonid/work/mail/nginx_upstream_module/test/http_utils.py", line 259, in get_success
  assert(code == 200), 'expected 200'
AssertionError: expected 200
┌─[✗]─[leonid@vasya-L460]─[~/work/mail/nginx_upstream_module]
└──╼ ./test/v26_features.py 
[+] basic insert
Traceback (most recent call last):
File "/home/leonid/work/mail/nginx_upstream_module/test/http_utils.py", line 223, in get
  res = urllib2.urlopen(req)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
  return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
  response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
  '_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
  result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1235, in http_open
  return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1202, in do_open
  h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/lib/python2.7/httplib.py", line 1103, in request
  self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1137, in _send_request
  self.putrequest(method, url, **skips)
File "/usr/lib/python2.7/httplib.py", line 968, in putrequest
  % (url, match.group()))
InvalidURL: URL can't contain control characters. '/insert?index=1&string=some big string&float=2.1&double=3.1&bool=True&int=-1000&' (found at least ' ')

Traceback (most recent call last):
File "./test/v26_features.py", line 34, in <module>
  result = get_success(BASE_URL + '/insert', insert_1, None)
File "/home/leonid/work/mail/nginx_upstream_module/test/http_utils.py", line 259, in get_success
  assert(code == 200), 'expected 200'
AssertionError: expected 200

@Totktonada
Copy link
Member

I guess that URL encoding was missed for those test cases either from scratch or after some change in the testing utilites.

I guess we can just fix it without attempts to deeply investigate where it becomes broken and why (that would be hard due to the messy git history; excuse me, Vasiliy). Whitespaces obviously should be URL encoded.

However I would try to revert changes that were introduced together with the failing test cases and so verify whether they test the relevant bugfixes / features after the fix of the testing problem.

The patch that works for me (to be verified as described above and to be splitted to atomic commits):

diff --git a/test/http_utils.py b/test/http_utils.py
index 64f71c0..fce3f8e 100644
--- a/test/http_utils.py
+++ b/test/http_utils.py
@@ -202,7 +202,7 @@ def patch(url, data):
 def arr_of_dicts_to_string(arr_of_dicts):
     res = ""
     for k in arr_of_dicts:
-        res = res + k.keys()[0] + "=" + str(k.values()[0]) + "&"
+        res = res + urllib.urlencode(k) + '&'
     return res
 
 
diff --git a/test/v24_features.py b/test/v24_features.py
index 4e9355b..597d3e5 100755
--- a/test/v24_features.py
+++ b/test/v24_features.py
@@ -41,10 +41,10 @@ post_success(preset_method_location, {"body": True}, {})
 # ============
 #
 print('[+] Unescape issue')
-arg_a = 'some string with spaces'
-preset_method_location = BASE_URL + '/unescape?a=' + arg_a
-result = get_success(preset_method_location, None, {})
-assert(result[0]['args']['a'] == arg_a), 'does not expected (args.a)'
+args = {'a': 'some string with spaces'}
+preset_method_location = BASE_URL + '/unescape'
+result = get_success(preset_method_location, args, {})
+assert(result[0]['args']['a'] == args['a']), 'does not expected (args["a"])'
 
 # ============
 #
diff --git a/test/v26_features.py b/test/v26_features.py
index cb07ea6..5be3531 100755
--- a/test/v26_features.py
+++ b/test/v26_features.py
@@ -325,7 +325,7 @@ update = [
     {'float': '-,3,2.1'},
     {'double': '=,4,4.1'},
     {'bool': '=,5,false'},
-    {'int': '%2B,6,1001'}
+    {'int': '+,6,1001'}
 ]
 
 expected = [

@Totktonada Totktonada mentioned this issue Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants