-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from jquast/0.4.0
Prepare 0.4.0 release
- Loading branch information
Showing
8 changed files
with
201 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ addons: | |
packages: | ||
# on ubuntu 12.04 this is linux debian 'netkit-telnet' package renamed, | ||
- telnet | ||
- curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
TelnetStream | ||
------------ | ||
|
||
feed_byte called by telnet server should be a coroutine | ||
receiving data by send. It should yield 'is_oob', or 'slc_received', | ||
etc.? We're still considering ... the state still requires tracking, | ||
but this would turn multiple function calls into a single call as a | ||
generator, probably preferred for bandwidth. | ||
|
||
handle_xon resumes writing in a way that is not obvious -- we should | ||
be using the true 'pause_writing' and 'resume_writing' methods of our | ||
base protocol. The given code was written before these methods became | ||
available in asyncio (then, tulip). We need to accommodate the new | ||
availabilities. | ||
|
||
On Encoding | ||
----------- | ||
|
||
currently we determine 'CHARSET': 'utf8' because we cannot correctly | ||
determine the first part of LANG (en_us.UTF-8, for example). It should | ||
be possible, in a derived (demo) application, to determine the region | ||
code by geoip (maxmind database, etc). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""Functionally tests telnetlib3 Client against its own Server.""" | ||
|
||
# std imports | ||
import asyncio | ||
|
||
# local imports | ||
from .accessories import ( | ||
TestTelnetServer, | ||
TestTelnetClient, | ||
unused_tcp_port, | ||
event_loop, | ||
bind_host, | ||
log | ||
) | ||
|
||
# 3rd party | ||
import pytest | ||
|
||
@pytest.mark.asyncio | ||
def test_telnet_coupled(event_loop, bind_host, unused_tcp_port, log): | ||
|
||
waiter_server_connected = asyncio.Future() | ||
waiter_client_connected = asyncio.Future() | ||
waiter_server_closed = asyncio.Future() | ||
waiter_client_closed = asyncio.Future() | ||
|
||
server = yield from event_loop.create_server( | ||
protocol_factory=lambda: TestTelnetServer( | ||
waiter_connected=waiter_server_connected, | ||
waiter_closed=waiter_server_closed, | ||
log=log), | ||
host=bind_host, port=unused_tcp_port) | ||
|
||
log.info('Listening on {0}'.format(server.sockets[0].getsockname())) | ||
|
||
_transport, client_protocol = yield from event_loop.create_connection( | ||
protocol_factory=lambda: TestTelnetClient( | ||
waiter_connected=waiter_client_connected, | ||
waiter_closed=waiter_client_closed, | ||
encoding='utf8', log=log), | ||
host=bind_host, port=unused_tcp_port) | ||
|
||
done, pending = yield from asyncio.wait( | ||
[waiter_client_connected, waiter_server_connected], | ||
loop=event_loop, timeout=1) | ||
|
||
assert not pending, (done, | ||
pending, | ||
waiter_client_connected, | ||
waiter_server_connected) | ||
|
||
client_protocol.stream.write(u'quit\r'.encode('ascii')) | ||
|
||
done, pending = yield from asyncio.wait( | ||
[waiter_client_closed, waiter_server_closed], | ||
loop=event_loop, timeout=1) | ||
|
||
assert not pending, (done, | ||
pending, | ||
waiter_client_connected, | ||
waiter_server_connected) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Functionally tests telnetlib3 as a server using curl(1).""" | ||
# std imports | ||
import subprocess | ||
import asyncio | ||
import locale | ||
import codecs | ||
|
||
# local imports | ||
from .accessories import ( | ||
TestTelnetServer, | ||
unused_tcp_port, | ||
event_loop, | ||
bind_host, | ||
log | ||
) | ||
|
||
# local | ||
import telnetlib3 | ||
|
||
# 3rd party imports | ||
import pytest | ||
import pexpect | ||
|
||
|
||
@pytest.mark.skipif(pexpect.which('curl') is None, | ||
reason="Requires curl(1)") | ||
@pytest.mark.asyncio | ||
def test_curltelnet(event_loop, bind_host, unused_tcp_port, log): | ||
|
||
waiter_closed = asyncio.Future() | ||
waiter_connected = asyncio.Future() | ||
|
||
server = yield from event_loop.create_server( | ||
protocol_factory=lambda: TestTelnetServer( | ||
waiter_closed=waiter_closed, | ||
waiter_connected=waiter_connected, | ||
log=log), | ||
host=bind_host, port=unused_tcp_port) | ||
|
||
log.info('Listening on {0}'.format(server.sockets[0].getsockname())) | ||
|
||
curl = yield from asyncio.create_subprocess_exec( | ||
'curl', '--verbose', '--progress-bar', | ||
'telnet://{0}:{1}'.format(bind_host, unused_tcp_port), | ||
stdin=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE | ||
) | ||
|
||
stdout, stderr = yield from curl.communicate(input=b'quit\r\n') | ||
|
||
server = yield from waiter_closed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version": "0.3.0"} | ||
{"version": "0.4.0"} |