mirror of
https://github.com/httpie/cli.git
synced 2024-11-28 18:53:21 +01:00
parent
f849bb4c64
commit
d242e21bce
@ -190,32 +190,10 @@ class TestSession(SessionTestBase):
|
|||||||
|
|
||||||
def test_expired_cookies(self, httpbin):
|
def test_expired_cookies(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
orig_session = {
|
session_path = self.config_dir / 'session-by-path.json'
|
||||||
'cookies': {
|
http('--session', str(session_path), httpbin.url + '/cookies/set?hello=100')
|
||||||
'to_expire': {
|
r1 = http('--session', str(session_path), httpbin.url + '/cookies/delete?hello=100')
|
||||||
'value': 'foo'
|
with open(self.config_dir / 'session-by-path.json', 'r') as myfile:
|
||||||
},
|
data=myfile.read()
|
||||||
'to_stay': {
|
obj = json.loads(data)
|
||||||
'value': 'foo'
|
assert len(obj['cookies']) == 0
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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']
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user