(self)
| 1770 | self.assertFalse(http_handler.requests[0].has_header(auth_header)) |
| 1771 | |
| 1772 | def test_basic_prior_auth_auto_send(self): |
| 1773 | # Assume already authenticated if is_authenticated=True |
| 1774 | # for APIs like Github that don't return 401 |
| 1775 | |
| 1776 | user, password = "wile", "coyote" |
| 1777 | request_url = "http://acme.example.com/protected" |
| 1778 | |
| 1779 | http_handler = MockHTTPHandlerCheckAuth(200) |
| 1780 | |
| 1781 | pwd_manager = HTTPPasswordMgrWithPriorAuth() |
| 1782 | auth_prior_handler = HTTPBasicAuthHandler(pwd_manager) |
| 1783 | auth_prior_handler.add_password( |
| 1784 | None, request_url, user, password, is_authenticated=True) |
| 1785 | |
| 1786 | self.assertTrue(pwd_manager.is_authenticated(request_url)) |
| 1787 | self.assertTrue(pwd_manager.is_authenticated(request_url + '/nested')) |
| 1788 | self.assertFalse(pwd_manager.is_authenticated(request_url + 'plain')) |
| 1789 | |
| 1790 | opener = OpenerDirector() |
| 1791 | opener.add_handler(auth_prior_handler) |
| 1792 | opener.add_handler(http_handler) |
| 1793 | |
| 1794 | opener.open(request_url) |
| 1795 | |
| 1796 | # expect request to be sent with auth header |
| 1797 | self.assertTrue(http_handler.has_auth_header) |
| 1798 | |
| 1799 | def test_basic_prior_auth_send_after_first_success(self): |
| 1800 | # Auto send auth header after authentication is successful once |
nothing calls this directly
no test coverage detected