Skip to content

Commit 3f1ee62

Browse files
author
Sefa Ilkimen
committed
add some specs
1 parent c73b15b commit 3f1ee62

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## 1.10.1
44

55
- Fixed #71: does not encode query string in URL correctly on Android
6-
- Fixed #72: app crashes if response encoding is not UTF-8
6+
- Fixed #72: app crashes if response encoding is not UTF-8 (thanks jkfb)
77

88
## 1.10.0
99

Binary file not shown.

test/app-test-definitions.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
const hooks = {
22
onBeforeEachTest: function(done) {
33
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);
57
}
68
};
79

810
const helpers = {
911
acceptAllCerts: function(done) { cordova.plugin.http.acceptAllCerts(true, done, done); },
12+
enableSSLPinning: function(done) { cordova.plugin.http.enableSSLPinning(true, done, done); },
1013
setJsonSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('json')); },
1114
setUtf8StringSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('utf8')); },
1215
setUrlEncodedSerializer: function(done) { done(cordova.plugin.http.setDataSerializer('urlencoded')); },
@@ -424,6 +427,25 @@ const tests = [
424427
result.type.should.be.equal('resolved');
425428
result.data.data.should.be.equal('');
426429
}
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+
}
427449
}
428450
];
429451

0 commit comments

Comments
 (0)