(self)
| 1584 | "http://acme.example.com/protected") |
| 1585 | |
| 1586 | def test_basic_auth(self): |
| 1587 | realm = "realm2@example.com" |
| 1588 | realm2 = "realm2@example.com" |
| 1589 | basic = f'Basic realm="{realm}"' |
| 1590 | basic2 = f'Basic realm="{realm2}"' |
| 1591 | other_no_realm = 'Otherscheme xxx' |
| 1592 | digest = (f'Digest realm="{realm2}", ' |
| 1593 | f'qop="auth, auth-int", ' |
| 1594 | f'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", ' |
| 1595 | f'opaque="5ccc069c403ebaf9f0171e9517f40e41"') |
| 1596 | for realm_str in ( |
| 1597 | # test "quote" and 'quote' |
| 1598 | f'Basic realm="{realm}"', |
| 1599 | f"Basic realm='{realm}'", |
| 1600 | |
| 1601 | # charset is ignored |
| 1602 | f'Basic realm="{realm}", charset="UTF-8"', |
| 1603 | |
| 1604 | # Multiple challenges per header |
| 1605 | f'{basic}, {basic2}', |
| 1606 | f'{basic}, {other_no_realm}', |
| 1607 | f'{other_no_realm}, {basic}', |
| 1608 | f'{basic}, {digest}', |
| 1609 | f'{digest}, {basic}', |
| 1610 | ): |
| 1611 | headers = [f'WWW-Authenticate: {realm_str}'] |
| 1612 | self.check_basic_auth(headers, realm) |
| 1613 | |
| 1614 | # no quote: expect a warning |
| 1615 | with warnings_helper.check_warnings(("Basic Auth Realm was unquoted", |
| 1616 | UserWarning)): |
| 1617 | headers = [f'WWW-Authenticate: Basic realm={realm}'] |
| 1618 | self.check_basic_auth(headers, realm) |
| 1619 | |
| 1620 | # Multiple headers: one challenge per header. |
| 1621 | # Use the first Basic realm. |
| 1622 | for challenges in ( |
| 1623 | [basic, basic2], |
| 1624 | [basic, digest], |
| 1625 | [digest, basic], |
| 1626 | ): |
| 1627 | headers = [f'WWW-Authenticate: {challenge}' |
| 1628 | for challenge in challenges] |
| 1629 | self.check_basic_auth(headers, realm) |
| 1630 | |
| 1631 | def test_proxy_basic_auth(self): |
| 1632 | opener = OpenerDirector() |
nothing calls this directly
no test coverage detected