Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
62629413
Unverified
Commit
62629413
authored
Aug 03, 2020
by
picklesrus
Committed by
GitHub
Aug 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Make the cookie library set the SameSite cookie value to strict by default"
parent
5cdc191b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
55 deletions
+1
-55
src/lib/jar.js
src/lib/jar.js
+1
-2
test/unit/lib/jar.test.js
test/unit/lib/jar.test.js
+0
-53
No files found.
src/lib/jar.js
View file @
62629413
...
...
@@ -78,8 +78,7 @@ const Jar = {
set
:
(
name
,
value
,
opts
)
=>
{
opts
=
opts
||
{};
defaults
(
opts
,
{
expires
:
new
Date
(
new
Date
().
setYear
(
new
Date
().
getFullYear
()
+
1
)),
sameSite
:
'
Strict
'
// cookie library requires this capitialization of sameSite
expires
:
new
Date
(
new
Date
().
setYear
(
new
Date
().
getFullYear
()
+
1
))
});
opts
.
path
=
'
/
'
;
const
obj
=
cookie
.
serialize
(
name
,
value
,
opts
);
...
...
test/unit/lib/jar.test.js
deleted
100644 → 0
View file @
5cdc191b
const
jar
=
require
(
'
../../../src/lib/jar
'
);
const
cookie
=
require
(
'
cookie
'
);
jest
.
mock
(
'
cookie
'
,
()
=>
({
serialize
:
jest
.
fn
()}));
describe
(
'
unit test lib/jar.js
'
,
()
=>
{
test
(
'
simple set test with no opts
'
,
()
=>
{
jar
.
set
(
'
name
'
,
'
value
'
);
expect
(
cookie
.
serialize
).
toHaveBeenCalled
();
expect
(
cookie
.
serialize
).
toHaveBeenCalledWith
(
'
name
'
,
'
value
'
,
expect
.
objectContaining
({
path
:
'
/
'
,
sameSite
:
'
Strict
'
,
expires
:
expect
.
anything
()
// not specifically matching the date because it is hard to mock
}));
});
test
(
'
test with opts
'
,
()
=>
{
jar
.
set
(
'
a
'
,
'
b
'
,
{
option
:
'
one
'
});
expect
(
cookie
.
serialize
).
toHaveBeenCalled
();
expect
(
cookie
.
serialize
).
toHaveBeenCalledWith
(
'
a
'
,
'
b
'
,
expect
.
objectContaining
({
option
:
'
one
'
,
path
:
'
/
'
,
sameSite
:
'
Strict
'
,
expires
:
expect
.
anything
()
// not specifically matching the date because it is hard to mock
}));
});
test
(
'
expires opts overrides default
'
,
()
=>
{
jar
.
set
(
'
a
'
,
'
b
'
,
{
option
:
'
one
'
,
expires
:
'
someday
'
});
expect
(
cookie
.
serialize
).
toHaveBeenCalled
();
expect
(
cookie
.
serialize
).
toHaveBeenCalledWith
(
'
a
'
,
'
b
'
,
expect
.
objectContaining
({
option
:
'
one
'
,
path
:
'
/
'
,
expires
:
'
someday
'
}));
});
test
(
'
sameSite opts overrides default
'
,
()
=>
{
jar
.
set
(
'
a
'
,
'
b
'
,
{
option
:
'
one
'
,
sameSite
:
'
override
'
});
expect
(
cookie
.
serialize
).
toHaveBeenCalled
();
expect
(
cookie
.
serialize
).
toHaveBeenCalledWith
(
'
a
'
,
'
b
'
,
expect
.
objectContaining
({
option
:
'
one
'
,
sameSite
:
'
override
'
}));
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment