MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / test_refresh

Method test_refresh

test/mitmproxy/test_http.py:611–638  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

609 assert list(resp.cookies.keys()) == ["one", "two"]
610
611 def test_refresh(self):
612 r = tresp()
613 n = time.time()
614 r.headers["date"] = email.utils.formatdate(n, usegmt=True)
615 pre = r.headers["date"]
616 r.refresh(946681202)
617 assert pre == r.headers["date"]
618
619 r.refresh(946681262)
620 d = email.utils.parsedate_tz(r.headers["date"])
621 d = email.utils.mktime_tz(d)
622 # Weird that this is not exact...
623 assert abs(60 - (d - n)) <= 1
624
625 cookie = "MOO=BAR; Expires=Tue, 08-Mar-2011 00:20:38 GMT; Path=foo.com; Secure"
626 r.headers["set-cookie"] = cookie
627 r.refresh()
628 # Cookie refreshing is tested in test_cookies, we just make sure that it's triggered here.
629 assert cookie != r.headers["set-cookie"]
630
631 with mock.patch("mitmproxy.net.http.cookies.refresh_set_cookie_header") as m:
632 m.side_effect = ValueError
633 r.refresh(n)
634
635 # Test negative unixtime, which raises on at least Windows.
636 r.headers["date"] = pre = "Mon, 01 Jan 1601 00:00:00 GMT"
637 r.refresh(946681202)
638 assert r.headers["date"] == pre
639
640
641class TestHTTPFlow:

Callers

nothing calls this directly

Calls 2

trespFunction · 0.90
refreshMethod · 0.45

Tested by

no test coverage detected