зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1456799 - [wdspec] Add cookie tests have to use a shared custom add_cookie command. r=maja_zf
MozReview-Commit-ID: 8t8iMByRjcQ --HG-- extra : rebase_source : 4887be3387e3c1497c1bfebfafca2f734885e882
This commit is contained in:
Родитель
78f239dadd
Коммит
1928e50fd5
|
@ -3,21 +3,26 @@ from tests.support.fixtures import clear_all_cookies
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
def add_cookie(session, cookie):
|
||||
return session.transport.send(
|
||||
"POST", "session/{session_id}/cookie".format(**vars(session)),
|
||||
{"cookie": cookie})
|
||||
|
||||
|
||||
def test_add_domain_cookie(session, url, server_config):
|
||||
new_cookie = {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"domain": server_config["browser_host"],
|
||||
"path": "/",
|
||||
"httpOnly": False,
|
||||
"secure": False
|
||||
}
|
||||
|
||||
session.url = url("/common/blank.html")
|
||||
clear_all_cookies(session)
|
||||
create_cookie_request = {
|
||||
"cookie": {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"domain": server_config["browser_host"],
|
||||
"path": "/",
|
||||
"httpOnly": False,
|
||||
"secure": False
|
||||
}
|
||||
}
|
||||
result = session.transport.send(
|
||||
"POST", "session/%s/cookie" % session.session_id, create_cookie_request)
|
||||
|
||||
result = add_cookie(session, new_cookie)
|
||||
assert_success(result)
|
||||
|
||||
result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
|
||||
|
@ -42,21 +47,19 @@ def test_add_domain_cookie(session, url, server_config):
|
|||
|
||||
|
||||
def test_add_cookie_for_ip(session, url, server_config, configuration):
|
||||
session.url = "http://127.0.0.1:%s/common/blank.html" % (server_config["ports"]["http"][0])
|
||||
clear_all_cookies(session)
|
||||
create_cookie_request = {
|
||||
"cookie": {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"domain": "127.0.0.1",
|
||||
"path": "/",
|
||||
"httpOnly": False,
|
||||
"secure": False
|
||||
}
|
||||
new_cookie = {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"domain": "127.0.0.1",
|
||||
"path": "/",
|
||||
"httpOnly": False,
|
||||
"secure": False
|
||||
}
|
||||
|
||||
result = session.transport.send(
|
||||
"POST", "session/%s/cookie" % session.session_id, create_cookie_request)
|
||||
session.url = "http://127.0.0.1:%s/common/blank.html" % (server_config["ports"]["http"][0])
|
||||
clear_all_cookies(session)
|
||||
|
||||
result = add_cookie(session, new_cookie)
|
||||
assert_success(result)
|
||||
|
||||
result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
|
||||
|
@ -80,19 +83,19 @@ def test_add_cookie_for_ip(session, url, server_config, configuration):
|
|||
|
||||
|
||||
def test_add_non_session_cookie(session, url):
|
||||
session.url = url("/common/blank.html")
|
||||
clear_all_cookies(session)
|
||||
a_year_from_now = int(
|
||||
(datetime.utcnow() + timedelta(days=365) - datetime.utcfromtimestamp(0)).total_seconds())
|
||||
create_cookie_request = {
|
||||
"cookie": {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"expiry": a_year_from_now
|
||||
}
|
||||
|
||||
new_cookie = {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"expiry": a_year_from_now
|
||||
}
|
||||
result = session.transport.send(
|
||||
"POST", "session/%s/cookie" % session.session_id, create_cookie_request)
|
||||
|
||||
session.url = url("/common/blank.html")
|
||||
clear_all_cookies(session)
|
||||
|
||||
result = add_cookie(session, new_cookie)
|
||||
assert_success(result)
|
||||
|
||||
result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
|
||||
|
@ -116,16 +119,15 @@ def test_add_non_session_cookie(session, url):
|
|||
|
||||
|
||||
def test_add_session_cookie(session, url):
|
||||
new_cookie = {
|
||||
"name": "hello",
|
||||
"value": "world"
|
||||
}
|
||||
|
||||
session.url = url("/common/blank.html")
|
||||
clear_all_cookies(session)
|
||||
create_cookie_request = {
|
||||
"cookie": {
|
||||
"name": "hello",
|
||||
"value": "world"
|
||||
}
|
||||
}
|
||||
result = session.transport.send(
|
||||
"POST", "session/%s/cookie" % session.session_id, create_cookie_request)
|
||||
|
||||
result = add_cookie(session, new_cookie)
|
||||
assert_success(result)
|
||||
|
||||
result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
|
||||
|
@ -148,17 +150,16 @@ def test_add_session_cookie(session, url):
|
|||
|
||||
|
||||
def test_add_session_cookie_with_leading_dot_character_in_domain(session, url, server_config):
|
||||
new_cookie = {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"domain": ".%s" % server_config["browser_host"]
|
||||
}
|
||||
|
||||
session.url = url("/common/blank.html")
|
||||
clear_all_cookies(session)
|
||||
create_cookie_request = {
|
||||
"cookie": {
|
||||
"name": "hello",
|
||||
"value": "world",
|
||||
"domain": ".%s" % server_config["browser_host"]
|
||||
}
|
||||
}
|
||||
result = session.transport.send(
|
||||
"POST", "session/%s/cookie" % session.session_id, create_cookie_request)
|
||||
|
||||
result = add_cookie(session, new_cookie)
|
||||
assert_success(result)
|
||||
|
||||
result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
|
||||
|
|
Загрузка…
Ссылка в новой задаче