diff --git a/CHANGELOG.md b/CHANGELOG.md index 6548658..b49a36d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.10.1 - Fixed #71: does not encode query string in URL correctly on Android -- Fixed #72: app crashes if response encoding is not UTF-8 +- Fixed #72: app crashes if response encoding is not UTF-8 (thanks jkfb) ## 1.10.0 diff --git a/test/app-template/www/certificates/httpbin.org.cer b/test/app-template/www/certificates/httpbin.org.cer new file mode 100644 index 0000000..cc00688 Binary files /dev/null and b/test/app-template/www/certificates/httpbin.org.cer differ diff --git a/test/app-test-definitions.js b/test/app-test-definitions.js index 597d78c..5dcc6e8 100644 --- a/test/app-test-definitions.js +++ b/test/app-test-definitions.js @@ -1,12 +1,15 @@ const hooks = { onBeforeEachTest: function(done) { cordova.plugin.http.clearCookies(); - cordova.plugin.http.acceptAllCerts(false, done, done); + cordova.plugin.http.acceptAllCerts(false, function() { + cordova.plugin.http.enableSSLPinning(false, done, done); + }, done); } }; const helpers = { acceptAllCerts: function(done) { cordova.plugin.http.acceptAllCerts(true, done, done); }, + enableSSLPinning: function(done) { cordova.plugin.http.enableSSLPinning(true, done, done); }, setJsonSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('json')); }, setUtf8StringSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('utf8')); }, setUrlEncodedSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('urlencoded')); }, @@ -424,6 +427,25 @@ const tests = [ result.type.should.be.equal('resolved'); result.data.data.should.be.equal(''); } + },{ + description: 'should pin SSL cert correctly (GET)', + expected: 'resolved: {"status": 200 ...', + before: helpers.enableSSLPinning, + func: function(resolve, reject) { + cordova.plugin.http.get('https://httpbin.org', {}, {}, resolve, reject); + }, + validationFunc: function(driver, result) { + result.type.should.be.equal('resolved'); + } + },{ + description: 'should send deeply structured JSON object correctly (POST) #65', + expected: 'resolved: {"status": 200, "data": "{\\"data\\": \\"{\\\\"outerObj\\\\":{\\\\"innerStr\\\\":\\\\"testString\\\\",\\\\"innerArr\\\\":[1,2,3]}}\\" ...', + before: helpers.setJsonSerializer, + func: function(resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', { outerObj: { innerStr: 'testString', innerArr: [1, 2, 3] }}, {}, resolve, reject); }, + validationFunc: function(driver, result) { + result.type.should.be.equal('resolved'); + JSON.parse(result.data.data).json.should.eql({ outerObj: { innerStr: 'testString', innerArr: [1, 2, 3] }}); + } } ];