Commit Graph

186 Commits

Author SHA1 Message Date
Maik Hoepfel
708b3c0179 Check order of header values
I'm in the process of updating the ASGI spec to require that the order
of header values is kept. To match that work, I'm adding matching
assertions to the tests.

The code unfortunately is not as elegant as I'd like, but then it's only
a result of the underlying HTTP spec.
2017-03-08 11:28:11 +08:00
Maik Hoepfel
57051a48cd Fix byte string issue in Python 2
Twisted seems to return a byte string for the client and server IP
address. It is easily rectified by casting to the required unicode
string. Also added a test to ensure this is also handled correctly in
the X-Forwarded-For header parsing.
2017-03-07 13:40:23 +08:00
Maik Hoepfel
549df9d3ec Add and convert tests for HTTP requests
This commit introduces a few Hypothesis tests to test the HTTP request
part of the specification. To keep things organized, I split the
existing tests module into two: one concerned with requests, and one
concerned with responses. I anticipate that we'll also add modules for
chunks and server push later.

daphne already had tests for the HTTP protocol. Some of them I converted
to Hypothesis tests to increase what was tested. Some were also
concerned with HTTP responses, so they were moved to the new response
module. And three tests were concerned with proxy behaviour, which I
wasn't sure about, and I just kept them as-is, but also moved them
to the request tests.
2017-03-07 13:22:16 +08:00
Maik Hoepfel
bcd7015844 Add Hypothesis strategies for generating HTTP requests
Hypothesis, our framework for test data generation, contains only
general so-called strategies for generating data. This commit adds a few
which will be useful for generating the data for our tests.

Alos see http://hypothesis.readthedocs.io/en/latest/data.html.
2017-03-07 12:26:27 +08:00
Maik Hoepfel
7be54eb59d ASGITestCase - checking channel messages for spec conformance
This commit introduces a new test case class, with it's main method
assert_valid_http_request_message. The idea is
that this method is a translation of the ASGI spec to code, and can be
used to check channel messages for conformance with that part of the
spec.

I plan to add further methods for other parts of the spec.
2017-03-07 12:24:59 +08:00
Maik Hoepfel
a3944eff5e Fix accidental cast to byte string under Python 2
While grepping for calls to str(), I found this bit which looks like a
cast to unicode was intended under Python 2.
2017-02-09 15:28:58 +01:00
Maik Hoepfel
c2baa32a9c Add Hypothesis for property-based tests
Hypothesis:
"It works by letting you write tests that assert that
something should be true for every case, not just the ones you happen to
think of."

I think it's well suited for the task of ensuring Daphne conforms to the
ASGI specification.
2017-02-09 13:21:41 +01:00
Andrew Godwin
60952b34bf Releasing version 1.0.2 2017-02-01 12:09:21 -08:00
Maik Hoepfel
cf94ec01fa Test against Python 3.4 and multiple Twisted versions (#75)
* Test against Python 3.4 and multiple Twisted versions

This commit adds tox to be able to test against different dependencies
locally. We agreed that Python 3.4 should be supported across all Channels
projects, so it is also added with this commit.

Furthermore, I think it makes sense to support a broad range of Twisted
releases, as users of daphne are not unlikely to have other Twisted code
running. It's not feasible to test against all releases since 16.0, and
it would require constant maintenance to add new releases as they come
out. So I opted to keep things simple for now, and only test against the
oldest supported and the current Twisted release.

I did consider @jpic's great idea from
https://github.com/django/daphne/pull/19 to just use tox to avoid having
to duplicate the dependency matrix. But it does lead to slower test runs
as it bypasses Travis' caching, and is slightly more verbose.

* Require asgiref 1.0 and use receive instead of receive_many

As both daphne and asgiref had a 1.0 release, I think it makes sense to
require the presumably more stable asgiref 1.0. It's also a good
occasion to fix the deprecation warnings when running the tests by
switching to receive instead of receive_many.

* Document supported Python and Twisted versions
2017-01-30 17:24:17 -08:00
David Marquis
07dd777ef1 Fix #72: Allowing null origins for Cordova/PhoneGap WS clients (#73)
* Fix #72: Configuring the underlying Autobahn Websocket connection factory so that 'null' origins are accepted, effectively allowing connections from Cordova/PhoneGap clients

* Fix #72: Adding test for no origin header use case
2017-01-30 10:18:11 -08:00
David Marquis
ccc804fd6a Tweaked TestWebSocketProtocol class documentation (copy/paste typo) (#74) 2017-01-30 10:17:49 -08:00
Хасанов Булат
71f6052fb3 Remove domain from file descriptor in serverFromString (#68) 2017-01-23 11:22:10 -08:00
Andrew Godwin
7597576db2 Add License 2017-01-23 10:09:15 -08:00
Andrew Godwin
c69bf09b7c Releasing 1.0.1 2017-01-09 18:28:52 -08:00
Andrew Godwin
3d628ba941 Fixed channels/#470: Bad python 2 handling of endpoint string 2017-01-09 18:27:37 -08:00
Andrew Godwin
aa5e7dd48f Releasing 1.0.0 2017-01-08 17:14:28 -08:00
Andrew Godwin
fd83678276 Merge pull request #37 from mcallistersean/ticket_10
use twisted endpoint description strings to bind to ports and sockets
2016-11-14 09:29:32 -08:00
Sean Mc Allister
b1c238d377 fix tests 2016-11-14 11:04:09 +01:00
Sean Mc Allister
5ea0749c5f build_endpoint_description_string is now a normal function 2016-11-14 10:59:15 +01:00
Andrew Godwin
c6e9b5a3a1 Merge pull request #60 from hackedd/ws-tests
Add test for WebSocket connection.
2016-11-06 15:15:06 +01:00
Paul Hooijenga
b8c1fe54eb Add test for WebSocket connection. 2016-11-05 17:16:43 +01:00
Andrew Godwin
3e65675f78 Merge pull request #59 from raphaelm/patch-1
Fixed a regression introduced in fixing #55
2016-11-05 14:26:35 +01:00
Raphael Michel
2ffed27a77 Fixed a regression introduced in fixing #55 2016-11-05 14:18:54 +01:00
Sean Mc Allister
76b441ecdf Merge branch 'master' into ticket_10 2016-11-05 14:07:49 +01:00
Sean Mc Allister
a2458ac47c test mixed endpoints and some cleanup 2016-11-05 13:48:24 +01:00
Andrew Godwin
a672da7b21 Merge pull request #58 from rixx/
Respond with a code when closing a connection
2016-11-05 13:38:25 +01:00
Sean Mc Allister
f115f808c3 Merge branch 'master' into ticket_10 2016-11-05 12:38:03 +01:00
Tobias Kunze
c6e4ea25d1 Respond with a code when closing a connection
Regards django/channels#414
2016-11-05 12:27:16 +01:00
Andrew Godwin
dc98b09dfd Merge pull request #57 from raphaelm/issue55
Fix #55 -- Optionally parse X-Forwarded-For header
2016-11-05 12:06:44 +01:00
Raphael Michel
61ed32d500 Fix #55 -- Optionally parse X-Forwarded-For header 2016-11-05 11:45:48 +01:00
Sean Mc Allister
f9f799f75f Merge branch 'master' into ticket_10 2016-11-04 14:40:40 +01:00
Andrew Godwin
3c8c21b352 Merge pull request #54 from indevgr/access-log-buffering
Access log buffering
2016-10-25 09:16:23 -07:00
Stratos Moros
bd0530d147 make access log line buffered
fixes #53
2016-10-25 15:43:44 +03:00
Stratos Moros
cd8b709ce8 fix variable name 2016-10-25 15:43:38 +03:00
Sean Mc Allister
e38c7541da Merge remote-tracking branch 'upstream/master' into ticket_10 2016-10-21 17:51:52 +02:00
Andrew Godwin
5f6f14a8d1 Merge pull request #51 from mcallistersean/issue/50
log full uri for http response
2016-10-11 13:21:07 -07:00
Sean Mc Allister
3e2370b5f1 log full uri for http response 2016-10-11 17:09:34 +02:00
Andrew Godwin
b537bed180 Make accept silently pass if already accepted 2016-10-05 16:00:11 -07:00
Andrew Godwin
8c637ff728 Fix default verbosity 2016-10-05 14:46:54 -07:00
Andrew Godwin
685f3aed1e Switch to new explicit WebSocket acceptance 2016-10-05 13:45:12 -07:00
Andrew Godwin
1bdf2a7518 Merge pull request #48 from adamchainz/setup.py
Tidy up setup.py a bit
2016-09-22 14:30:40 -07:00
Adam Chainz
5a5fd08633 Tidy up setup.py a bit
* Remove unused import 'sys'
* Github is HTTPS
* Add some trove classifiers based upon Django's
2016-09-22 22:28:55 +01:00
Andrew Godwin
6df13290b2 Merge pull request #47 from Krukov/fix-285-channels-issue
Catching error at receive_many form channel layer
2016-09-22 14:27:20 -07:00
Andrew Godwin
bfce80a062 Merge pull request #45 from Krukov/patch-add-verbosity
Verbosity
2016-09-22 14:23:25 -07:00
Andrew Godwin
a83d2f41bd Merge pull request #46 from adamchainz/readthedocs.io
Convert readthedocs links for their .org -> .io migration for hosted projects
2016-09-22 14:04:36 -07:00
Krukov Dima
790c482cb6 Catching error at receive_many form channel layer 2016-09-21 18:24:05 +00:00
Krukov Dima
cf096bab5c Logging to the python standard library 2016-09-21 18:12:35 +00:00
Adam Chainz
bcaf1de155 Convert readthedocs links for their .org -> .io migration for hosted projects
As per [their blog post of the 27th April](https://blog.readthedocs.com/securing-subdomains/) ‘Securing subdomains’:

> Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard.

Test Plan: Manually visited all the links I’ve modified.
2016-09-21 08:43:24 +01:00
Krukov Dima
0844061296 Add verbosity to log twisted log 2016-09-16 20:36:31 +00:00
Krukov Dima
c6270e7e4e Pep8 2016-09-16 20:34:20 +00:00