|
1 | 1 | const hooks = {
|
2 | 2 | onBeforeEachTest: function(done) {
|
3 | 3 | cordova.plugin.http.clearCookies();
|
4 |
| - cordova.plugin.http.acceptAllCerts(false, done, done); |
| 4 | + cordova.plugin.http.acceptAllCerts(false, function() { |
| 5 | + cordova.plugin.http.enableSSLPinning(false, done, done); |
| 6 | + }, done); |
5 | 7 | }
|
6 | 8 | };
|
7 | 9 |
|
8 | 10 | const helpers = {
|
9 | 11 | acceptAllCerts: function(done) { cordova.plugin.http.acceptAllCerts(true, done, done); },
|
| 12 | + enableSSLPinning: function(done) { cordova.plugin.http.enableSSLPinning(true, done, done); }, |
10 | 13 | setJsonSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('json')); },
|
11 | 14 | setUtf8StringSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('utf8')); },
|
12 | 15 | setUrlEncodedSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('urlencoded')); },
|
@@ -424,6 +427,25 @@ const tests = [
|
424 | 427 | result.type.should.be.equal('resolved');
|
425 | 428 | result.data.data.should.be.equal('');
|
426 | 429 | }
|
| 430 | + },{ |
| 431 | + description: 'should pin SSL cert correctly (GET)', |
| 432 | + expected: 'resolved: {"status": 200 ...', |
| 433 | + before: helpers.enableSSLPinning, |
| 434 | + func: function(resolve, reject) { |
| 435 | + cordova.plugin.http.get('https://httpbin.org', {}, {}, resolve, reject); |
| 436 | + }, |
| 437 | + validationFunc: function(driver, result) { |
| 438 | + result.type.should.be.equal('resolved'); |
| 439 | + } |
| 440 | + },{ |
| 441 | + description: 'should send deeply structured JSON object correctly (POST) #65', |
| 442 | + expected: 'resolved: {"status": 200, "data": "{\\"data\\": \\"{\\\\"outerObj\\\\":{\\\\"innerStr\\\\":\\\\"testString\\\\",\\\\"innerArr\\\\":[1,2,3]}}\\" ...', |
| 443 | + before: helpers.setJsonSerializer, |
| 444 | + func: function(resolve, reject) { cordova.plugin.http.post('http://httpbin.org/anything', { outerObj: { innerStr: 'testString', innerArr: [1, 2, 3] }}, {}, resolve, reject); }, |
| 445 | + validationFunc: function(driver, result) { |
| 446 | + result.type.should.be.equal('resolved'); |
| 447 | + JSON.parse(result.data.data).json.should.eql({ outerObj: { innerStr: 'testString', innerArr: [1, 2, 3] }}); |
| 448 | + } |
427 | 449 | }
|
428 | 450 | ];
|
429 | 451 |
|
|
0 commit comments