MCPcopy Index your code
hub / github.com/python/cpython / test_ietf_example_1

Method test_ietf_example_1

Lib/test/test_http_cookiejar.py:1582–1692  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1580 "PART_NUMBER=ROCKET_LAUNCHER_0001")
1581
1582 def test_ietf_example_1(self):
1583 #-------------------------------------------------------------------
1584 # Then we test with the examples from draft-ietf-http-state-man-mec-03.txt
1585 #
1586 # 5. EXAMPLES
1587
1588 c = CookieJar(DefaultCookiePolicy(rfc2965=True))
1589
1590 #
1591 # 5.1 Example 1
1592 #
1593 # Most detail of request and response headers has been omitted. Assume
1594 # the user agent has no stored cookies.
1595 #
1596 # 1. User Agent -> Server
1597 #
1598 # POST /acme/login HTTP/1.1
1599 # [form data]
1600 #
1601 # User identifies self via a form.
1602 #
1603 # 2. Server -> User Agent
1604 #
1605 # HTTP/1.1 200 OK
1606 # Set-Cookie2: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"
1607 #
1608 # Cookie reflects user's identity.
1609
1610 cookie = interact_2965(
1611 c, 'http://www.acme.com/acme/login',
1612 'Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
1613 self.assertFalse(cookie)
1614
1615 #
1616 # 3. User Agent -> Server
1617 #
1618 # POST /acme/pickitem HTTP/1.1
1619 # Cookie: $Version="1"; Customer="WILE_E_COYOTE"; $Path="/acme"
1620 # [form data]
1621 #
1622 # User selects an item for ``shopping basket.''
1623 #
1624 # 4. Server -> User Agent
1625 #
1626 # HTTP/1.1 200 OK
1627 # Set-Cookie2: Part_Number="Rocket_Launcher_0001"; Version="1";
1628 # Path="/acme"
1629 #
1630 # Shopping basket contains an item.
1631
1632 cookie = interact_2965(c, 'http://www.acme.com/acme/pickitem',
1633 'Part_Number="Rocket_Launcher_0001"; '
1634 'Version="1"; Path="/acme"');
1635 self.assertRegex(cookie,
1636 r'^\$Version="?1"?; Customer="?WILE_E_COYOTE"?; \$Path="/acme"$')
1637
1638 #
1639 # 5. User Agent -> Server

Callers

nothing calls this directly

Calls 6

CookieJarClass · 0.90
DefaultCookiePolicyClass · 0.90
interact_2965Function · 0.85
assertFalseMethod · 0.80
assertRegexMethod · 0.80
assertInMethod · 0.80

Tested by

no test coverage detected