(self)
| 1745 | self.assertNotIn("Riding_Rocket_0023", cookie) |
| 1746 | |
| 1747 | def test_rejection(self): |
| 1748 | # Test rejection of Set-Cookie2 responses based on domain, path, port. |
| 1749 | pol = DefaultCookiePolicy(rfc2965=True) |
| 1750 | |
| 1751 | c = LWPCookieJar(policy=pol) |
| 1752 | |
| 1753 | max_age = "max-age=3600" |
| 1754 | |
| 1755 | # illegal domain (no embedded dots) |
| 1756 | cookie = interact_2965(c, "http://www.acme.com", |
| 1757 | 'foo=bar; domain=".com"; version=1') |
| 1758 | self.assertFalse(c) |
| 1759 | |
| 1760 | # legal domain |
| 1761 | cookie = interact_2965(c, "http://www.acme.com", |
| 1762 | 'ping=pong; domain="acme.com"; version=1') |
| 1763 | self.assertEqual(len(c), 1) |
| 1764 | |
| 1765 | # illegal domain (host prefix "www.a" contains a dot) |
| 1766 | cookie = interact_2965(c, "http://www.a.acme.com", |
| 1767 | 'whiz=bang; domain="acme.com"; version=1') |
| 1768 | self.assertEqual(len(c), 1) |
| 1769 | |
| 1770 | # legal domain |
| 1771 | cookie = interact_2965(c, "http://www.a.acme.com", |
| 1772 | 'wow=flutter; domain=".a.acme.com"; version=1') |
| 1773 | self.assertEqual(len(c), 2) |
| 1774 | |
| 1775 | # can't partially match an IP-address |
| 1776 | cookie = interact_2965(c, "http://125.125.125.125", |
| 1777 | 'zzzz=ping; domain="125.125.125"; version=1') |
| 1778 | self.assertEqual(len(c), 2) |
| 1779 | |
| 1780 | # illegal path (must be prefix of request path) |
| 1781 | cookie = interact_2965(c, "http://www.sol.no", |
| 1782 | 'blah=rhubarb; domain=".sol.no"; path="/foo"; ' |
| 1783 | 'version=1') |
| 1784 | self.assertEqual(len(c), 2) |
| 1785 | |
| 1786 | # legal path |
| 1787 | cookie = interact_2965(c, "http://www.sol.no/foo/bar", |
| 1788 | 'bing=bong; domain=".sol.no"; path="/foo"; ' |
| 1789 | 'version=1') |
| 1790 | self.assertEqual(len(c), 3) |
| 1791 | |
| 1792 | # illegal port (request-port not in list) |
| 1793 | cookie = interact_2965(c, "http://www.sol.no", |
| 1794 | 'whiz=ffft; domain=".sol.no"; port="90,100"; ' |
| 1795 | 'version=1') |
| 1796 | self.assertEqual(len(c), 3) |
| 1797 | |
| 1798 | # legal port |
| 1799 | cookie = interact_2965( |
| 1800 | c, "http://www.sol.no", |
| 1801 | r'bang=wallop; version=1; domain=".sol.no"; ' |
| 1802 | r'port="90,100, 80,8080"; ' |
| 1803 | r'max-age=100; Comment = "Just kidding! (\"|\\\\) "') |
| 1804 | self.assertEqual(len(c), 4) |
nothing calls this directly
no test coverage detected