Skip to content

gh-131178: add E2E mockless tests for http.server command-line interface #134279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
early abort
  • Loading branch information
picnixz committed May 19, 2025
commit 5c136f3b44db3935ccdfb26acbefe525afb36050
16 changes: 7 additions & 9 deletions Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,14 +1472,6 @@ def setUp(self):
f.write(self.tls_password.encode())
self.addCleanup(os_helper.unlink, self.tls_password_file)

@unittest.skipIf(ssl is None, "requires ssl")
def get_ssl_context(self):
context = ssl.create_default_context()
# allow self-signed certificates
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
return context

def fetch_file(self, path, context=None):
req = urllib.request.Request(path, method='GET')
with urllib.request.urlopen(req, context=context) as res:
Expand Down Expand Up @@ -1515,7 +1507,13 @@ def test_http_client(self):
res = self.fetch_file(f'http://{bind}:{port}/{self.served_file_name}')
self.assertEqual(res, self.served_data)

@unittest.skipIf(ssl is None, "requires ssl")
def test_https_client(self):
context = ssl.create_default_context()
# allow self-signed certificates
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE

port = find_unused_port()
proc = spawn_python('-u', '-m', 'http.server', str(port),
'--tls-cert', self.tls_cert,
Expand All @@ -1527,7 +1525,7 @@ def test_https_client(self):
bind = self.wait_for_server(proc, 'https', port)
self.assertIsNotNone(bind)
url = f'https://{bind}:{port}/{self.served_file_name}'
res = self.fetch_file(url, context=self.get_ssl_context())
res = self.fetch_file(url, context=context)
self.assertEqual(res, self.served_data)


Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy