@@ -1444,4 +1444,84 @@ describe('Curl converter should', function() {
14441444 });
14451445 });
14461446 });
1447+
1448+ describe('It should correctly generate request with cookie header', function() {
1449+ it('containing -b option', function(done) {
1450+ convert({
1451+ type: 'string',
1452+ data: `curl 'https://httpbin.org/anything' \
1453+ -b 'dashboard_beta=yes; postman-beta.track=default' \
1454+ -H 'authority: httpbin.org'
1455+ --data "{\"context\":{\"client\":{\"hl\":\"en\"}},\"state\":true}"
1456+ `
1457+ }, function (err, result) {
1458+ expect(result.result).to.equal(true);
1459+ expect(result.output.length).to.equal(1);
1460+ expect(result.output[0].type).to.equal('request');
1461+ expect(result.output[0].data.url).to.equal('https://httpbin.org/anything');
1462+ expect(result.output[0].data.method).to.equal('POST');
1463+
1464+ const headerArr = result.output[0].data.header;
1465+ expect(headerArr.length).to.equal(2);
1466+ expect(headerArr[0].key).to.equal('authority');
1467+ expect(headerArr[0].value).to.equal('httpbin.org');
1468+ expect(headerArr[1].key).to.equal('Cookie');
1469+ expect(headerArr[1].value).to.equal('dashboard_beta=yes; postman-beta.track=default');
1470+ done();
1471+ });
1472+ });
1473+
1474+ it('containing --cookie option', function(done) {
1475+ convert({
1476+ type: 'string',
1477+ data: `curl 'https://httpbin.org/anything' \
1478+ --cookie 'dashboard_beta=yes; postman-beta.track=default' \
1479+ -H 'authority: httpbin.org'
1480+ --data "{\"context\":{\"client\":{\"hl\":\"en\"}},\"state\":true}"
1481+ `
1482+ }, function (err, result) {
1483+ expect(result.result).to.equal(true);
1484+ expect(result.output.length).to.equal(1);
1485+ expect(result.output[0].type).to.equal('request');
1486+ expect(result.output[0].data.url).to.equal('https://httpbin.org/anything');
1487+ expect(result.output[0].data.method).to.equal('POST');
1488+
1489+ const headerArr = result.output[0].data.header;
1490+ expect(headerArr.length).to.equal(2);
1491+ expect(headerArr[0].key).to.equal('authority');
1492+ expect(headerArr[0].value).to.equal('httpbin.org');
1493+ expect(headerArr[1].key).to.equal('Cookie');
1494+ expect(headerArr[1].value).to.equal('dashboard_beta=yes; postman-beta.track=default');
1495+ done();
1496+ });
1497+ });
1498+
1499+ it('containing multiple cookies', function(done) {
1500+ convert({
1501+ type: 'string',
1502+ data: `curl 'https://httpbin.org/anything' \
1503+ -b 'dashboard_beta=yes; postman-beta.track=default' \
1504+ -b 'name=JohnDoe' \
1505+ -H 'authority: httpbin.org' \
1506+ --data "{\"context\":{\"client\":{\"hl\":\"en\"}},\"state\":true}"
1507+ `
1508+ }, function (err, result) {
1509+ expect(result.result).to.equal(true);
1510+ expect(result.output.length).to.equal(1);
1511+ expect(result.output[0].type).to.equal('request');
1512+ expect(result.output[0].data.url).to.equal('https://httpbin.org/anything');
1513+ expect(result.output[0].data.method).to.equal('POST');
1514+
1515+ const headerArr = result.output[0].data.header;
1516+ expect(headerArr.length).to.equal(3);
1517+ expect(headerArr[0].key).to.equal('authority');
1518+ expect(headerArr[0].value).to.equal('httpbin.org');
1519+ expect(headerArr[1].key).to.equal('Cookie');
1520+ expect(headerArr[1].value).to.equal('dashboard_beta=yes; postman-beta.track=default');
1521+ expect(headerArr[2].key).to.equal('Cookie');
1522+ expect(headerArr[2].value).to.equal('name=JohnDoe');
1523+ done();
1524+ });
1525+ });
1526+ });
14471527});
0 commit comments