Skip to content

Commit

Permalink
SonarCloud fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
AvnerCohen committed Nov 22, 2021
1 parent 98a56e5 commit 4e65c58
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions spec/http_headers_verifier/naive_cookie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

SAME_SITE_CONFIG = 'test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT; Secure; HttpOnly; SameSite=Lax'

BASE_COOKIE_STR = "test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT"

describe NaiveCookie do

Expand All @@ -14,13 +15,13 @@
expect(parsed_cookie.secure?).to eq(false)
end
it "should mark cookie as secure if secure is present" do
cookie_str = SAME_SITE_CONFIG
cookie_str = "test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT; Secure; HttpOnly; SameSite=Lax"
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.secure?).to eq(true)

end
it "should mark cookie as secure ignoring case" do
cookie_str = SAME_SITE_CONFIG
cookie_str = "test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT; secure; HttpOnly; SameSite=Lax"
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.secure?).to eq(true)

Expand Down Expand Up @@ -49,7 +50,7 @@

describe "NaiveCookie.same_site" do
it "should return nil if samesite is missing" do
cookie_str = "test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT"
cookie_str = BASE_COOKIE_STR
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.same_site).to eq(nil)
end
Expand All @@ -69,21 +70,21 @@

describe "NaiveCookie.name" do
it "should return cookiename" do
cookie_str = "test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT"
cookie_str = BASE_COOKIE_STR
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.name).to eq("test_cookie_name")
end
end

describe "NaiveCookie.path" do
it "should return cookie path" do
cookie_str = "test_cookie_name=session_value_here; Path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT"
cookie_str = BASE_COOKIE_STR
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.path).to eq("/")
end

it "should return cookie path, ignore case" do
cookie_str = "test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT"
cookie_str = BASE_COOKIE_STR
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.path).to eq("/")
end
Expand All @@ -92,12 +93,12 @@

describe "NaiveCookie.expires" do
it "should return cookie expires" do
cookie_str = "test_cookie_name=session_value_here; path=/; Expires=Tue, 11 Aug 2020 07:17:12 GMT"
cookie_str = BASE_COOKIE_STR
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.expires).to eq("Tue, 11 Aug 2020 07:17:12 GMT")
end
it "should return cookie expires, ignoring case" do
cookie_str = "test_cookie_name=session_value_here; path=/; expires=Tue, 11 Aug 2020 07:17:12 GMT"
cookie_str = BASE_COOKIE_STR
parsed_cookie = NaiveCookie.new(cookie_str)
expect(parsed_cookie.expires).to eq("Tue, 11 Aug 2020 07:17:12 GMT")
end
Expand All @@ -106,7 +107,7 @@

describe "NaiveCookie.validate!" do
it "should fail if non secure required to be secure" do
cookie_str = "test_cookie_name=session_value_here; path=/; Expires=Tue, 11 Aug 2020 07:17:12 GMT"
cookie_str = BASE_COOKIE_STR
rules = {"Secure" => true}
parsed_cookie = NaiveCookie.new(cookie_str)
validation_results = parsed_cookie.validate!(rules)
Expand Down

0 comments on commit 4e65c58

Please sign in to comment.