Added HTTP_COOKIE and test cases.

Added WSF_COOKIE class, inherit from HTTP_COOKIE.
This commit is contained in:
jvelilla
2015-03-13 15:28:38 -03:00
parent 5f4ab50bf9
commit 871e9792a5
3 changed files with 475 additions and 0 deletions

View File

@@ -0,0 +1,130 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
testing: "type/manual"
class
HTTP_COOKIE_TEST_SET
inherit
EQA_TEST_SET
feature -- Test routines
test_cookie_expected_header
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Max-Age=-1"))
end
test_cookie_value_with_illegal_characters
-- values (cookie name and value)
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
assert ("Not valid space", not l_cookie.has_valid_characters ("Use! 12"))
assert ("Not valid comma", not l_cookie.has_valid_characters ("Use!,12"))
assert ("Not valid semicolon", not l_cookie.has_valid_characters ("Use!;12"))
assert ("Not valid backslash", not l_cookie.has_valid_characters ("Use!\12"))
assert ("Not valid Dquote", not l_cookie.has_valid_characters ("Use!%"12"))
end
test_cookie_full_attributes
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_domain ("www.example.com")
l_cookie.set_expiration ("Sat, 18 Apr 2015 21:22:05 GMT")
l_cookie.set_path ("/")
l_cookie.set_secure (True)
l_cookie.set_http_only (True)
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Domain=www.example.com; Path=/; Expires=Sat, 18 Apr 2015 21:22:05 GMT; Max-Age=-1; Secure; HttpOnly"))
end
test_cookie_include_expires
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_domain ("www.example.com")
l_cookie.set_expiration ("Sat, 18 Apr 2015 21:22:05 GMT")
l_cookie.set_path ("/")
l_cookie.set_secure (True)
l_cookie.set_http_only (True)
l_cookie.mark_expires
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Domain=www.example.com; Path=/; Expires=Sat, 18 Apr 2015 21:22:05 GMT; Secure; HttpOnly"))
end
test_cookie_full_include_max_age
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_domain ("www.example.com")
l_cookie.set_expiration ("Sat, 18 Apr 2015 21:22:05 GMT")
l_cookie.set_path ("/")
l_cookie.set_secure (True)
l_cookie.set_http_only (True)
l_cookie.mark_max_age
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Domain=www.example.com; Path=/; Max-Age=-1; Secure; HttpOnly"))
end
test_cookie_defaults_and_http_only
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_http_only (True)
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Max-Age=-1; HttpOnly"))
end
test_cookie_defaults_and_secure
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_secure (True)
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Max-Age=-1; Secure"))
end
test_cookie_default_and_domain
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_domain ("www.example.com")
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Domain=www.example.com; Max-Age=-1"))
end
test_cookie_default_and_path
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_path ("/")
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Path=/; Max-Age=-1"))
end
test_cookie_default_and_custom_max_age
local
l_cookie: HTTP_COOKIE
do
create l_cookie.make ("user_id", "u12345")
l_cookie.set_max_age (120)
assert("Expected", l_cookie.cookie_header.same_string ("Set-Cookie: user_id=u12345; Max-Age=120"))
end
end