updated tests

This commit is contained in:
Eyitayo Ogunbiyi
2020-06-10 19:33:20 +01:00
parent ce466434ba
commit a4eb5c4498

View File

@ -190,10 +190,32 @@ class TestSession(SessionTestBase):
def test_expired_cookies(self, httpbin): def test_expired_cookies(self, httpbin):
self.start_session(httpbin) self.start_session(httpbin)
session_path = self.config_dir / 'session-by-path.json' orig_session = {
http('--session', str(session_path), httpbin.url + '/cookies/set?hello=100') 'cookies': {
r1 = http('--session', str(session_path), httpbin.url + '/cookies/delete?hello=100') 'to_expire': {
with open(self.config_dir / 'session-by-path.json', 'r') as myfile: 'value': 'foo'
data=myfile.read() },
obj = json.loads(data) 'to_stay': {
assert len(obj['cookies']) == 0 'value': 'foo'
},
}
}
session_path = mk_config_dir() / 'test-session.json'
session_path.write_text(json.dumps(orig_session))
r = http(
'--session', str(session_path),
'--print=H',
httpbin.url + '/cookies/delete?to_expire',
)
assert 'Cookie: to_expire=foo; to_stay=foo' in r
updated_session = json.loads(session_path.read_text())
assert 'to_stay' in updated_session['cookies']
# Verify `to_expire` is gone
assert 'to_expire' not in updated_session['cookies']