-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/AG-27340-didomi-loader
- Loading branch information
Showing
8 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { concatCookieNameValuePath } from '../../src/helpers/cookie-utils'; | ||
|
||
describe('concatCookieNameValuePath', () => { | ||
describe('encode cookie value', () => { | ||
test.each([ | ||
{ | ||
actual: ['name', 'value', ''], | ||
expected: 'name=value', | ||
}, | ||
{ | ||
actual: ['name', 'value', '/'], | ||
expected: 'name=value; path=/', | ||
}, | ||
{ | ||
actual: ['pop::138', '138', ''], | ||
// do not encode cookie name | ||
// https://github.com/AdguardTeam/Scriptlets/issues/408 | ||
expected: 'pop::138=138', | ||
}, | ||
{ | ||
actual: ['aa::bb::cc', '1', ''], | ||
expected: 'aa::bb::cc=1', | ||
}, | ||
// invalid path | ||
{ | ||
actual: ['name', 'value', '/docs'], | ||
// no path is set if unsupported path values passed | ||
expected: 'name=value', | ||
}, | ||
// invalid name because of ';' | ||
{ | ||
actual: ['a;bc', 'def', ''], | ||
expected: null, | ||
}, | ||
// value with ';' but it should be encoded so its ok | ||
{ | ||
actual: ['abc', 'de;f', ''], | ||
expected: 'abc=de%3Bf', | ||
}, | ||
])('$actual -> $expected', ({ actual, expected }) => { | ||
expect(concatCookieNameValuePath(...actual)).toBe(expected); | ||
}); | ||
}); | ||
|
||
describe('no cookie value encoding', () => { | ||
test.each([ | ||
{ | ||
actual: ['name', 'value', ''], | ||
expected: 'name=value', | ||
}, | ||
{ | ||
actual: ['__test-cookie_expires', 'expires', '/'], | ||
expected: '__test-cookie_expires=expires; path=/', | ||
}, | ||
{ | ||
actual: ['aa::bb::cc', '1', ''], | ||
expected: 'aa::bb::cc=1', | ||
}, | ||
{ | ||
actual: ['__w_cc11', '{%22cookies_statistical%22:false%2C%22cookies_ad%22:true}', ''], | ||
// do not encode cookie value | ||
// https://github.com/AdguardTeam/Scriptlets/issues/311 | ||
expected: '__w_cc11={%22cookies_statistical%22:false%2C%22cookies_ad%22:true}', | ||
}, | ||
// invalid name because of ';' | ||
{ | ||
actual: ['a;bc', 'def', ''], | ||
expected: null, | ||
}, | ||
// invalid value because of ';' and it is not being encoded | ||
{ | ||
actual: ['abc', 'de;f', ''], | ||
expected: null, | ||
}, | ||
])('$actual -> $expected', ({ actual, expected }) => { | ||
// explicit 'false' to disable encoding | ||
expect(concatCookieNameValuePath(...actual, false)).toBe(expected); | ||
}); | ||
}); | ||
}); |