Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Add same_site attribute and tests #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

p
Copy link

@p p commented Dec 23, 2019

The commit adb79c0 has as its message "add support for samesite cookie". It actually only makes the validator recognize the samesite attribute, but does not expose the value via the cookie object and does not add any tests.

This PR adds the same_site attribute (note that the instance variable name was changed to @same_site from @samesite to be consistent with http_only/httponly) and adds tests.

@@ -74,6 +74,10 @@
higher = Cookie.from_set_cookie 'http://foo.com/bar/baz/', 'foo=bar;path=/bar/'
CookieValidation.validate_cookie('http://foo.com/bar/baz/', higher)
end
it 'should accept SameSite attribute' do
cookie = Cookie.from_set_cookie 'http://127.0.0.1/', 'foo=bar;samesite=strict'
expect(CookieValidation.validate_cookie('http://127.0.0.1/', cookie)).to be_truthy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Metrics/LineLength: Line is too long. [88/80]

@@ -74,6 +74,10 @@
higher = Cookie.from_set_cookie 'http://foo.com/bar/baz/', 'foo=bar;path=/bar/'
CookieValidation.validate_cookie('http://foo.com/bar/baz/', higher)
end
it 'should accept SameSite attribute' do
cookie = Cookie.from_set_cookie 'http://127.0.0.1/', 'foo=bar;samesite=strict'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Metrics/LineLength: Line is too long. [84/80]

@@ -74,6 +74,10 @@
higher = Cookie.from_set_cookie 'http://foo.com/bar/baz/', 'foo=bar;path=/bar/'
CookieValidation.validate_cookie('http://foo.com/bar/baz/', higher)
end
it 'should accept SameSite attribute' do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -43,6 +43,10 @@
expect(cookie.name).to eq 'GALX'
expect(cookie.secure).to be_truthy
end
it 'should accept SameSite attribute' do
cookie = Cookie.from_set_cookie 'https://www.google.com/a/blah', 'GALX=RgmSftjnbPM;samesite=strict'
expect(cookie.same_site).to eq 'strict'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -43,6 +43,10 @@
expect(cookie.name).to eq 'GALX'
expect(cookie.secure).to be_truthy
end
it 'should accept SameSite attribute' do
cookie = Cookie.from_set_cookie 'https://www.google.com/a/blah', 'GALX=RgmSftjnbPM;samesite=strict'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Metrics/LineLength: Line is too long. [105/80]

@@ -43,6 +43,10 @@
expect(cookie.name).to eq 'GALX'
expect(cookie.secure).to be_truthy
end
it 'should accept SameSite attribute' do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@joeldodge79 joeldodge79 mentioned this pull request Sep 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants