summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/bitmask/core/web/api.py2
-rw-r--r--tests/unit/core/test_web_api.py8
2 files changed, 10 insertions, 0 deletions
diff --git a/src/leap/bitmask/core/web/api.py b/src/leap/bitmask/core/web/api.py
index 6c386b5..d31afa5 100644
--- a/src/leap/bitmask/core/web/api.py
+++ b/src/leap/bitmask/core/web/api.py
@@ -25,6 +25,8 @@ class Api(Resource):
# expects strings. This 'str(param)' conversion can be removed
# if we move to python3
for param in json.loads(params):
+ if isinstance(param, basestring):
+ param = param.encode('ascii', 'replace')
command.append(str(param))
d = self.dispatcher.dispatch(command)
diff --git a/tests/unit/core/test_web_api.py b/tests/unit/core/test_web_api.py
index 6d61686..f19505d 100644
--- a/tests/unit/core/test_web_api.py
+++ b/tests/unit/core/test_web_api.py
@@ -142,7 +142,15 @@ class RESTApiTests(unittest.TestCase):
def tearDown(self):
return self.plainPort.stopListening()
+ @defer.inlineCallbacks
+ def test_param_encoding(self):
+ params = ['test_types', 1, True]
+ call = yield self.makeAPICall('core/version',
+ params=params)
+ self.assertCall(call, self.canned.backend.version)
+
# core commands
+ # TODO these tests can be generated dinamically
@defer.inlineCallbacks
def test_core_version(self):