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
f0749da9
Commit
f0749da9
authored
Jun 14, 2019
by
Andrew Svetlov
Committed by
Victor Stinner
Jun 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35998: Avoid TimeoutError in test_asyncio: test_start_tls_server_1() (GH-14080)
parent
431478d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
Lib/test/test_asyncio/test_sslproto.py
Lib/test/test_asyncio/test_sslproto.py
+19
-18
Misc/NEWS.d/next/Tests/2019-06-14-17-05-49.bpo-35998.yX82oD.rst
...EWS.d/next/Tests/2019-06-14-17-05-49.bpo-35998.yX82oD.rst
+1
-0
No files found.
Lib/test/test_asyncio/test_sslproto.py
View file @
f0749da9
...
...
@@ -494,17 +494,14 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
def
test_start_tls_server_1
(
self
):
HELLO_MSG
=
b'1'
*
self
.
PAYLOAD_SIZE
ANSWER
=
b'answer'
server_context
=
test_utils
.
simple_server_sslcontext
()
client_context
=
test_utils
.
simple_client_sslcontext
()
if
sys
.
platform
.
startswith
(
'freebsd'
)
or
sys
.
platform
.
startswith
(
'win'
):
# bpo-35031: Some FreeBSD and Windows buildbots fail to run this test
# as the eof was not being received by the server if the payload
# size is not big enough. This behaviour only appears if the
# client is using TLS1.3.
client_context
.
options
|=
ssl
.
OP_NO_TLSv1_3
answer
=
None
def
client
(
sock
,
addr
):
nonlocal
answer
sock
.
settimeout
(
self
.
TIMEOUT
)
sock
.
connect
(
addr
)
...
...
@@ -513,33 +510,36 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
sock
.
start_tls
(
client_context
)
sock
.
sendall
(
HELLO_MSG
)
sock
.
shutdown
(
socket
.
SHUT_RDWR
)
answer
=
sock
.
recv_all
(
len
(
ANSWER
))
sock
.
close
()
class
ServerProto
(
asyncio
.
Protocol
):
def
__init__
(
self
,
on_con
,
on_
eof
,
on_
con_lost
):
def
__init__
(
self
,
on_con
,
on_con_lost
):
self
.
on_con
=
on_con
self
.
on_eof
=
on_eof
self
.
on_con_lost
=
on_con_lost
self
.
data
=
b''
self
.
transport
=
None
def
connection_made
(
self
,
tr
):
self
.
transport
=
tr
self
.
on_con
.
set_result
(
tr
)
def
replace_transport
(
self
,
tr
):
self
.
transport
=
tr
def
data_received
(
self
,
data
):
self
.
data
+=
data
def
eof_received
(
self
):
self
.
on_eof
.
set_result
(
1
)
if
len
(
self
.
data
)
>=
len
(
HELLO_MSG
):
self
.
transport
.
write
(
ANSWER
)
def
connection_lost
(
self
,
exc
):
self
.
transport
=
None
if
exc
is
None
:
self
.
on_con_lost
.
set_result
(
None
)
else
:
self
.
on_con_lost
.
set_exception
(
exc
)
async
def
main
(
proto
,
on_con
,
on_
eof
,
on_
con_lost
):
async
def
main
(
proto
,
on_con
,
on_con_lost
):
tr
=
await
on_con
tr
.
write
(
HELLO_MSG
)
...
...
@@ -550,16 +550,16 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
server_side
=
True
,
ssl_handshake_timeout
=
self
.
TIMEOUT
)
await
on_eof
proto
.
replace_transport
(
new_tr
)
await
on_con_lost
self
.
assertEqual
(
proto
.
data
,
HELLO_MSG
)
new_tr
.
close
()
async
def
run_main
():
on_con
=
self
.
loop
.
create_future
()
on_eof
=
self
.
loop
.
create_future
()
on_con_lost
=
self
.
loop
.
create_future
()
proto
=
ServerProto
(
on_con
,
on_
eof
,
on_
con_lost
)
proto
=
ServerProto
(
on_con
,
on_con_lost
)
server
=
await
self
.
loop
.
create_server
(
lambda
:
proto
,
'127.0.0.1'
,
0
)
...
...
@@ -568,11 +568,12 @@ class BaseStartTLS(func_tests.FunctionalTestCaseMixin):
with
self
.
tcp_client
(
lambda
sock
:
client
(
sock
,
addr
),
timeout
=
self
.
TIMEOUT
):
await
asyncio
.
wait_for
(
main
(
proto
,
on_con
,
on_
eof
,
on_
con_lost
),
main
(
proto
,
on_con
,
on_con_lost
),
timeout
=
self
.
TIMEOUT
)
server
.
close
()
await
server
.
wait_closed
()
self
.
assertEqual
(
answer
,
ANSWER
)
self
.
loop
.
run_until_complete
(
run_main
())
...
...
Misc/NEWS.d/next/Tests/2019-06-14-17-05-49.bpo-35998.yX82oD.rst
0 → 100644
View file @
f0749da9
Avoid TimeoutError in test_asyncio: test_start_tls_server_1()
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