Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
400e761b
Commit
400e761b
authored
Sep 09, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use transient_internet() where appropriate in test_ssl
(svn.python.org is sometimes unavailable)
parent
90886a7b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
130 deletions
+131
-130
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+131
-130
No files found.
Lib/test/test_ssl.py
View file @
400e761b
...
@@ -305,14 +305,9 @@ class ContextTests(unittest.TestCase):
...
@@ -305,14 +305,9 @@ class ContextTests(unittest.TestCase):
class
NetworkedTests
(
unittest
.
TestCase
):
class
NetworkedTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
old_timeout
=
socket
.
getdefaulttimeout
()
socket
.
setdefaulttimeout
(
30
)
def
tearDown
(
self
):
socket
.
setdefaulttimeout
(
self
.
old_timeout
)
def
test_connect
(
self
):
def
test_connect
(
self
):
with
support
.
transient_internet
(
"svn.python.org"
):
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_NONE
)
cert_reqs
=
ssl
.
CERT_NONE
)
try
:
try
:
...
@@ -339,6 +334,7 @@ class NetworkedTests(unittest.TestCase):
...
@@ -339,6 +334,7 @@ class NetworkedTests(unittest.TestCase):
s
.
close
()
s
.
close
()
def
test_connect_with_context
(
self
):
def
test_connect_with_context
(
self
):
with
support
.
transient_internet
(
"svn.python.org"
):
# Same as test_connect, but with a separately created context
# Same as test_connect, but with a separately created context
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
s
=
ctx
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
...
@@ -369,6 +365,7 @@ class NetworkedTests(unittest.TestCase):
...
@@ -369,6 +365,7 @@ class NetworkedTests(unittest.TestCase):
# OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must
# OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must
# contain both versions of each certificate (same content, different
# contain both versions of each certificate (same content, different
# filename) for this test to be portable across OpenSSL releases.
# filename) for this test to be portable across OpenSSL releases.
with
support
.
transient_internet
(
"svn.python.org"
):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_SSLv23
)
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
verify_mode
=
ssl
.
CERT_REQUIRED
ctx
.
load_verify_locations
(
capath
=
CAPATH
)
ctx
.
load_verify_locations
(
capath
=
CAPATH
)
...
@@ -396,6 +393,7 @@ class NetworkedTests(unittest.TestCase):
...
@@ -396,6 +393,7 @@ class NetworkedTests(unittest.TestCase):
# Issue #5238: creating a file-like object with makefile() shouldn't
# Issue #5238: creating a file-like object with makefile() shouldn't
# delay closing the underlying "real socket" (here tested with its
# delay closing the underlying "real socket" (here tested with its
# file descriptor, hence skipping the test under Windows).
# file descriptor, hence skipping the test under Windows).
with
support
.
transient_internet
(
"svn.python.org"
):
ss
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
ss
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
))
ss
.
connect
((
"svn.python.org"
,
443
))
ss
.
connect
((
"svn.python.org"
,
443
))
fd
=
ss
.
fileno
()
fd
=
ss
.
fileno
()
...
@@ -411,6 +409,7 @@ class NetworkedTests(unittest.TestCase):
...
@@ -411,6 +409,7 @@ class NetworkedTests(unittest.TestCase):
self
.
assertEqual
(
e
.
exception
.
errno
,
errno
.
EBADF
)
self
.
assertEqual
(
e
.
exception
.
errno
,
errno
.
EBADF
)
def
test_non_blocking_handshake
(
self
):
def
test_non_blocking_handshake
(
self
):
with
support
.
transient_internet
(
"svn.python.org"
):
s
=
socket
.
socket
(
socket
.
AF_INET
)
s
=
socket
.
socket
(
socket
.
AF_INET
)
s
.
connect
((
"svn.python.org"
,
443
))
s
.
connect
((
"svn.python.org"
,
443
))
s
.
setblocking
(
False
)
s
.
setblocking
(
False
)
...
@@ -435,6 +434,7 @@ class NetworkedTests(unittest.TestCase):
...
@@ -435,6 +434,7 @@ class NetworkedTests(unittest.TestCase):
sys
.
stdout
.
write
(
"
\
n
Needed %d calls to do_handshake() to establish session.
\
n
"
%
count
)
sys
.
stdout
.
write
(
"
\
n
Needed %d calls to do_handshake() to establish session.
\
n
"
%
count
)
def
test_get_server_certificate
(
self
):
def
test_get_server_certificate
(
self
):
with
support
.
transient_internet
(
"svn.python.org"
):
pem
=
ssl
.
get_server_certificate
((
"svn.python.org"
,
443
))
pem
=
ssl
.
get_server_certificate
((
"svn.python.org"
,
443
))
if
not
pem
:
if
not
pem
:
self
.
fail
(
"No server certificate on svn.python.org:443!"
)
self
.
fail
(
"No server certificate on svn.python.org:443!"
)
...
@@ -456,6 +456,7 @@ class NetworkedTests(unittest.TestCase):
...
@@ -456,6 +456,7 @@ class NetworkedTests(unittest.TestCase):
def
test_ciphers
(
self
):
def
test_ciphers
(
self
):
remote
=
(
"svn.python.org"
,
443
)
remote
=
(
"svn.python.org"
,
443
)
with
support
.
transient_internet
(
remote
[
0
]):
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
s
=
ssl
.
wrap_socket
(
socket
.
socket
(
socket
.
AF_INET
),
cert_reqs
=
ssl
.
CERT_NONE
,
ciphers
=
"ALL"
)
cert_reqs
=
ssl
.
CERT_NONE
,
ciphers
=
"ALL"
)
s
.
connect
(
remote
)
s
.
connect
(
remote
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment