2630 Commits

Author SHA1 Message Date
prryplatypus
12ecf52878
Merge branch 'main' of github.com:sanic-org/sanic into feat/optional-uvloop-use 2021-11-18 20:06:49 +01:00
Adam Hopkins
523db190a7
Add contextual exceptions (#2290) 2021-11-18 17:47:27 +02:00
Adam Hopkins
95631b9686
Coffee please (#2316)
* Coffee please

* Add unit tests
2021-11-18 14:53:06 +02:00
Adam Hopkins
0860bfe1f1
Merge release 21.9.2 (#2313) 2021-11-17 19:36:36 +02:00
Adam Hopkins
85e7b712b9
Allow early Blueprint registrations to still apply later added objects (#2260) 2021-11-17 17:29:41 +02:00
L. Kärkkäinen
b731a6b48c
Make HTTP connections start in IDLE stage, avoiding delays and error messages (#2268)
* Make all new connections start in IDLE stage, and switch to REQUEST stage only once any bytes are received from client. This makes new connections without any request obey keepalive timeout rather than request timeout like they currently do.

* Revert typo

* Remove request timeout endpoint test which is no longer working (still tested by mocking). Fix mock timeout test setup.

Co-authored-by: L. Karkkainen <tronic@users.noreply.github.com>
2021-11-16 23:03:27 +02:00
Adam Hopkins
cde02b5936
More consistent config setting with post-FALLBACK_ERROR_FORMAT apply (#2310)
* Update unit testing and add more consistent config

* Change init and app values to private

* Cleanup line lengths
2021-11-16 13:07:33 +02:00
Adam Hopkins
abeb8d0bc0
Provide list of reloaded files (#2307)
* Allow access to reloaded files

* Return to simple boolean values

* Resolve before adding to changed files
2021-11-16 10:16:32 +02:00
Adam Hopkins
9a9f72ad64
Move builtin signals to enum (#2309)
* Move builtin signals to enum

* Fix annotations
2021-11-14 23:21:14 +02:00
Néstor Pérez
355a9e2dae
Fix broken test from merge 2021-11-07 21:11:08 +01:00
Néstor Pérez
a7a8624245
Merge branch 'main' into feat/optional-uvloop-use 2021-11-07 21:05:49 +01:00
Adam Hopkins
392a497366
Restructure of CLI and application state (#2295)
* Initial work on restructure of application state

* Updated MOTD with more flexible input and add basic version

* Remove unnecessary type ignores

* Add wrapping and smarter output per process type

* Add support for ASGI MOTD

* Add Windows color support ernable

* Refactor __main__ into submodule

* Renest arguments

* Passing unit tests

* Passing unit tests

* Typing

* Fix num worker test

* Add context to assert failure

* Add some type annotations

* Some linting

* Line aware searching in test

* Test abstractions

* Fix some flappy tests

* Bump up timeout on CLI tests

* Change test for no access logs on gunicornworker

* Add some basic test converage

* Some new tests, and disallow workers and fast on app.run
2021-11-07 21:39:03 +02:00
Néstor Pérez
934d737a92
Move loop setup to after startup debug messages 2021-11-02 16:22:29 +01:00
prryplatypus
5ca22d7a40
Fix some tests 2021-11-01 21:21:02 +01:00
prryplatypus
e6a195b61f
Move loop setup to after logo 2021-11-01 21:07:47 +01:00
prryplatypus
9de0e341e9
Split create_server tests so loop isn't closed prematurely 2021-11-01 19:57:50 +01:00
prryplatypus
0dbf1b2504
Added first tests 2021-11-01 19:29:58 +01:00
Néstor Pérez
471a42b66a
Merge branch 'main' into feat/optional-uvloop-use 2021-10-31 12:47:22 +01:00
Adam Hopkins
36e6a6c506
Increase join concat performance (#2291) 2021-10-29 12:55:09 +03:00
Stephen Sadowski
a361b345ad
Py310 loop fixup (#2294)
* Fixup for 3.8+; Sanic still supports 3.7 where loop is required

* Added branching statement to hanle asyncio.Event() loop parameter removal in 3.10, and optional supply in 3.9
2021-10-28 17:16:23 -05:00
Adam Hopkins
f5bd6e3b2f
Add Python 3.10 testing (and support) (#2257)
Administratively merging because @vltr and @ahopkins are the release managers, and @ahopkins is originator of the PR

* Add Python 3.10 testing (and support)

* fixed py310 tox environment for windows, quoted '3.10' in python-310 tests to avoid numeric compression

* updated tox.ini for py310

* quoted the rest of the bare 3.10 references in the workflows

* Issue with pytest requires version bump to 6.2.5 for python 3.10

Co-authored-by: Stephen Sadowski <stephen.sadowski@sjsadowski.com>
2021-10-28 13:41:57 -05:00
L. Kärkkäinen
6c7df68c7c
Vhost support using multiple TLS certificates (#2270)
* Initial support for using multiple SSL certificates.

* Also list IP address subjectAltNames on log.

* Use Python 3.7+ way of specifying TLSv1.2 as the minimum version. Linter fixes.

* isort

* Cleanup, store server name for later use. Add RSA ciphers. Log rejected SNIs.

* Cleanup, linter.

* Alter the order of initial log messages and handling. In particular, enable debug mode early so that debug messages during init can be shown.

* Store server name (SNI) to conn_info.

* Update test with new error message.

* Refactor for readability.

* Cleanup

* Replace old expired test cert with new ones and a script for regenerating them as needed.

* Refactor TLS tests to a separate file.

* Add cryptography to dev deps for rebuilding TLS certs.

* Minor adjustment to messages.

* Tests added for new TLS code.

* Find the correct log row before testing for message. The order was different on CI.

* More log message order fixup. The tests do not account for the logo being printed first.

* Another attempt at log message indexing fixup.

* Major TLS refactoring.

CertSelector now allows dicts and SSLContext within its list.
Server names are stored even when no list is used.
SSLContext.sanic now contains a dict with any setting passed and information extracted from cert.
That information is available on request.conn_info.cert.
Type annotations added.
More tests incl. a handler for faking hostname in tests.

* Remove a problematic logger test that apparently was not adding any coverage or value to anything.

* Revert accidental commit of uvloop disable.

* Typing fixes / refactoring.

* Additional test for cert selection. Certs recreated without DNS:localhost on sanic.example cert.

* Add tests for single certificate path shorthand and SNI information.

* Move TLS dict processing to CertSimple, make the names field optional and use names from the cert if absent.

* Sanic CLI options --tls and --tls-strict-host to use the new features.

* SSL argument typing updated

* Use ValueError for internal message passing to avoid CertificateError's odd message formatting.

* Linter

* Test CLI TLS options.

* Maybe the right codeclimate option now...

* Improved TLS argument help, removed support for combining --cert/--key with --tls.

* Removed support for strict checking without any certs, black forced fscked up formatting.

* Update CLI tests for stricter TLS options.

Co-authored-by: L. Karkkainen <tronic@users.noreply.github.com>
Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
2021-10-28 16:50:05 +03:00
Meysam
5b82884f8b
ci: fail on error 👷 (#2292)
Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
2021-10-27 11:55:34 +03:00
Néstor Pérez
f0f81ec458
Add ability to log all exceptions (#2262)
* Add ability to log all exceptions

* Fix linting 🙄

* Remove shorthand

* Make `ErrorHandler.log` backwards-compat

* Ignore mypy error

* Don't store `noisy_exceptions` attribute in app

* Added tests

* Store noisy exceptions setting in config

* Default to not-noisy if config key not available

* Add CLI tests for `noisy-exceptions`

* Remove debugging line I left in 😅

* Fix tests

Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
2021-10-27 10:43:58 +03:00
Cyril Nicodème
71cc30e5cd
Replacing assignation by typing for websocket_handshake (#2273)
* Replacing assignation by typing for `websocket_handshake`

Related to #2272

* Fix some type hinting issues

* Cleanup websocket handchake response concat

* Optimize concat encoding

Co-authored-by: Adam Hopkins <adam@amhopkins.com>
2021-10-27 10:00:04 +03:00
L. Kärkkäinen
645310cff6
Change codeclimate complexity threshold from 5 to 10. (#2286)
Co-authored-by: L. Karkkainen <tronic@users.noreply.github.com>
Co-authored-by: Stephen Sadowski <stephen.sadowski@sjsadowski.com>
2021-10-24 22:30:35 +03:00
prryplatypus
348c358d72
Merge branch 'main' of github.com:sanic-org/sanic into feat/optional-uvloop-use 2021-10-24 21:09:52 +02:00
prryplatypus
76492a7f88
Avoid unnecessary error log 2021-10-24 21:08:24 +02:00
prryplatypus
41454b2553
Fix linting errors 2021-10-24 20:51:05 +02:00
prryplatypus
6351753066
Fixes for gunicorn 2021-10-24 20:45:52 +02:00
Stephen Sadowski
2f30b5748a
Update host test function names so they are not overwritten (#2287)
Fix function name reuse in cli tests
2021-10-24 12:29:16 -05:00
prryplatypus
c008c343d9
Rename loop param 2021-10-24 19:27:43 +02:00
Stephen Sadowski
5e1ef96934
fix ipv6 display in startup info log (#2285)
* fix ipv6 display in startup info log

* refactored to oneliner by request

* Added test for passing ipv4 host

* Added test for passing ipv6 any host

* Added test for passing ipv6 loopback host
2021-10-24 11:14:00 -05:00
prryplatypus
0d1e591a9b
Fix logo tests? 2021-10-23 21:42:46 +02:00
prryplatypus
a1f36609b4
Fix logging 2021-10-23 21:40:57 +02:00
prryplatypus
6563ee28bf
Fix tests (hopefully?) 2021-10-23 21:16:49 +02:00
prryplatypus
250c5cf60d
Merge branch 'feat/optional-uvloop-use' of github.com:prryplatypus/sanic into tests/optional-uvloop-use 2021-10-23 21:02:20 +02:00
prryplatypus
1908eb5a02
Fix linting... *sigh* 2021-10-23 21:02:03 +02:00
prryplatypus
3e14dee8b4
Merge branch 'feat/optional-uvloop-use' of github.com:prryplatypus/sanic into tests/optional-uvloop-use 2021-10-23 20:50:33 +02:00
prryplatypus
2ff45ccfb1
Fix typing 2021-10-23 20:50:13 +02:00
prryplatypus
48b0158cd7
Merge changes into tests branch 2021-10-23 20:42:21 +02:00
prryplatypus
2e492f94e6
Create UVLOOP_INSTALLED constant 2021-10-23 20:39:57 +02:00
Ryu juheon
57e98b62b3
style: add some type hints (#2279)
* style: add some type hints

* fix: *args is a tuple, but overridden as a list

* fix: if touch this, it will be a maybe breaking change

* fix: remove unused import

* style(app): more correct type
2021-10-20 15:15:39 +03:00
prryplatypus
9a9a1ea5d6
Reattempt testing number 1 2021-10-18 21:33:05 +02:00
prryplatypus
eb2a264404
Remove failed tests 2021-10-11 20:57:26 +02:00
prryplatypus
cb791aa8b7
Fix error message 2021-10-11 20:34:34 +02:00
prryplatypus
0ab7f5ff6b
Attempt #2 at tests 2021-10-11 20:23:28 +02:00
prryplatypus
575837d5ef
Merge branch 'feat/optional-uvloop-use' of github.com:prryplatypus/sanic into feat/optional-uvloop-use 2021-10-11 20:23:10 +02:00
Néstor Pérez
cab4d59fef
First attempt tests (#1) 2021-10-11 20:02:00 +02:00
prryplatypus
4bfc09f3bd
Default USE_UVLOOP to True 2021-10-11 19:00:43 +02:00