Skip to content

Commit

Permalink
Merge pull request #397 from pactumjs/chore/replace-lightcookie
Browse files Browse the repository at this point in the history
chore: replace lightcookie with cookie-lite
  • Loading branch information
leelaprasadv authored Jan 10, 2025
2 parents cf485a8 + c963362 commit e4802e5
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 38 deletions.
54 changes: 30 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"form-data-lite": "^1.0.3",
"json-query": "^2.2.2",
"klona": "^2.0.6",
"lightcookie": "^1.0.25",
"cookie-lite": "^0.0.1",
"openapi-fuzzer-core": "^1.0.6",
"pactum-matchers": "^1.1.7",
"parse-graphql": "^1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/toss.helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const lc = require('lightcookie');
const cl = require('cookie-lite');
const jqy = require('json-query');

const config = require('../config');
Expand Down Expand Up @@ -30,7 +30,7 @@ function getPathValueFromRequestResponse(path, request, response) {
if (!request.headers) {
request.headers = {};
}
const cookies = lc.parse(request.headers['cookie']);
const cookies = cl.parse(request.headers['cookie']);
data = cookies;
} else if (path.startsWith('req.body')) {
path = path.replace('req.body', '');
Expand All @@ -43,7 +43,7 @@ function getPathValueFromRequestResponse(path, request, response) {
if (!response.headers) {
response.headers = {};
}
const cookies = lc.parse(response.headers['set-cookie']);
const cookies = cl.parse(response.headers['set-cookie']);
data = cookies;
} else {
path = path.replace('res.body', '');
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { compare } = require('pactum-matchers').utils;
const graphQL = require('./graphQL');
const lc = require('lightcookie');
const cl = require('cookie-lite');
const { PactumRequestError } = require('../helpers/errors');

const log = require('../plugins/logger');
Expand Down Expand Up @@ -69,7 +69,7 @@ const utils = {
if (value !== undefined) {
cookieObject[key] = value;
} else if (value === undefined) {
cookieObject = lc.parse(key);
cookieObject = cl.parse(key);
}
} else {
if (!helper.isValidObject(key)) {
Expand Down
6 changes: 3 additions & 3 deletions src/models/Interaction.model.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const lc = require('lightcookie');
const cl = require('cookie-lite');
const { setMatchingRules, getValue } = require('pactum-matchers').utils;
const processor = require('../helpers/dataProcessor');
const helper = require('../helpers/helper');
Expand Down Expand Up @@ -121,7 +121,7 @@ class InteractionRequest {
this.headers = getValue(request.headers);
}
if (request.cookies && typeof request.cookies === 'object') {
const cookie = lc.serialize(request.cookies);
const cookie = cl.serialize(request.cookies);
if (!this.headers) {
this.headers = {};
}
Expand Down Expand Up @@ -170,7 +170,7 @@ class InteractionResponse {
setMatchingRules(this.matchingRules, response.body, '$.body');
this.body = getValue(response.body);
if (response.cookies) {
const cookie = lc.serialize(response.cookies);
const cookie = cl.serialize(response.cookies);
if (!this.headers) {
this.headers = {};
}
Expand Down
4 changes: 2 additions & 2 deletions src/models/Spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const lc = require('lightcookie');
const cl = require('cookie-lite');
const override = require('deep-override');
const path = require('path');
const Tosser = require('./Tosser');
Expand Down Expand Up @@ -244,7 +244,7 @@ class Spec {
}
let cookie;
if (typeof key === 'object') {
cookie = lc.serialize(key);
cookie = cl.serialize(key);
} else {
if (value) {
cookie = `${key}=${value}`;
Expand Down
6 changes: 3 additions & 3 deletions src/models/expect.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const jqy = require('json-query');
const lc = require('lightcookie');
const cl = require('cookie-lite');

const config = require('../config');
const utils = require('../helpers/utils');
Expand Down Expand Up @@ -115,7 +115,7 @@ class Expect {
if (!actualCookie) {
this.fail(`'set-cookie' key not found in response headers`);
}
actualCookie = lc.parse(actualCookie);
actualCookie = cl.parse(actualCookie);
assert.deepStrictEqual(actualCookie, expectedCookie);
}
}
Expand All @@ -131,7 +131,7 @@ class Expect {
if (Array.isArray(actualCookie) && actualCookie.length > 1) {
actualCookie = actualCookie.join('; ') + ';';
}
actualCookie = lc.parse(actualCookie);
actualCookie = cl.parse(actualCookie);
const msg = jlv.validate(actualCookie, expectedCookie, { target: 'Cookie' });
if (msg) this.fail(msg);
}
Expand Down

0 comments on commit e4802e5

Please sign in to comment.