mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Add some tests that fail to spot bugs.
This commit is contained in:
parent
c787b0b9dc
commit
c5252649c8
1 changed files with 27 additions and 0 deletions
|
|
@ -177,6 +177,22 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
assert_equal '.example.com', cookie.dot_domain
|
||||
end
|
||||
|
||||
def test_parse_public_suffix
|
||||
cookie_str = 'a=b; domain=com'
|
||||
|
||||
cookie = HTTP::Cookie.parse(cookie_str).first
|
||||
assert_equal('com', cookie.domain)
|
||||
assert_equal(false, cookie.for_domain?)
|
||||
|
||||
cookie.origin = 'http://com/'
|
||||
assert_equal('com', cookie.domain)
|
||||
assert_equal(false, cookie.for_domain?)
|
||||
|
||||
assert_raises(ArgumentError) {
|
||||
cookie.origin = 'http://example.com/'
|
||||
}
|
||||
end
|
||||
|
||||
def test_parse_domain_none
|
||||
url = URI.parse('http://example.com/')
|
||||
|
||||
|
|
@ -664,6 +680,17 @@ class TestHTTPCookie < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_acceptable_from_uri?
|
||||
cookie = HTTP::Cookie.new(cookie_values(
|
||||
:domain => 'uk',
|
||||
:for_domain => true,
|
||||
:origin => nil))
|
||||
assert_equal true, cookie.for_domain?
|
||||
assert_equal true, cookie.acceptable_from_uri?('http://uk/')
|
||||
assert_equal true, cookie.for_domain? # bug: acceptable_from_uri? changed it to false
|
||||
assert_equal false, cookie.acceptable_from_uri?('http://foo.uk/')
|
||||
end
|
||||
|
||||
def test_valid_for_uri?
|
||||
{
|
||||
HTTP::Cookie.parse('a1=b',
|
||||
|
|
|
|||
Loading…
Reference in a new issue