Commit Graph
106 Commits
Author SHA1 Message Date
epenetandGitHub 30bf0634fe Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
Joakim PlateandGitHub c576a68d33 Upgrade pytest-aiohttp (#82475)
* Upgrade pytest-aiohttp

* Make sure executors, tasks and timers are closed

Some test will trigger warnings on garbage collect, these warnings
spills over into next test.

Some test trigger tasks that raise errors on shutdown, these spill
over into next test.

This is to mimic older pytest-aiohttp and it's behaviour on test
cleanup.

Discussions on similar changes for pytest-aiohttp are here:
https://github.com/pytest-dev/pytest-asyncio/pull/309

* Replace loop with event_loop

* Make sure time is frozen for tests

* Make sure the ConditionType is not async

  /home-assistant/homeassistant/helpers/template.py:2082: RuntimeWarning: coroutine 'AsyncMockMixin._execute_mock_call' was never awaited
    def wrapper(*args, **kwargs):
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

* Increase litejet press tests with a factor 10

The times are simulated anyway, and we can't stop the normal
event from occuring.

* Use async handlers for aiohttp

tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_still_image_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_get_stream_from_camera
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
tests/components/motioneye/test_camera.py::test_camera_option_stream_url_template
  /Users/joakim/src/hass/home-assistant/venv/lib/python3.9/site-packages/aiohttp/web_urldispatcher.py:189: DeprecationWarning: Bare functions are deprecated, use async ones
    warnings.warn(

* Switch to freezegun in modbus tests

The tests allowed clock to tick in between steps

* Make sure skybell object are fully mocked

Old tests would trigger attempts to post to could services:

```
DEBUG:aioskybell:HTTP post https://cloud.myskybell.com/api/v3/login/ Request with headers: {'content-type': 'application/json', 'accept': '*/*', 'x-skybell-app-id': 'd2b542c7-a7e4-4e1e-b77d-2b76911c7c46', 'x-skybell-client-id': '1f36a3c0-6dee-4997-a6db-4e1c67338e57'}
```

* Fix sorting that broke after rebase
2022-11-29 22:36:36 +01:00
Mike DegatanoandGitHub 82151bfd40 Create repairs for unsupported and unhealthy (#80747) 2022-10-31 09:57:54 -04:00
Franck NijhofandGitHub 9a4a7e2f4d Extend failed login message with the request URL (#75218) 2022-07-14 21:43:14 +02:00
J. Nick KostonandGitHub 0c29b68cf8 Switch linear search to a dict lookup for ip bans (#74482) 2022-07-07 10:57:44 +02:00
J. Nick KostonandGitHub 8b067e83f7 Initial orjson support take 3 (#73849)
* Initial orjson support take 2

Still need to work out problem building wheels

--

Redux of #72754 / #32153 Now possible since the following is solved:
ijl/orjson#220 (comment)

This implements orjson where we use our default encoder.  This does not implement orjson where `ExtendedJSONEncoder` is used as these areas tend to be called far less frequently.  If its desired, this could be done in a followup, but it seemed like a case of diminishing returns (except maybe for large diagnostics files, or traces, but those are not expected to be downloaded frequently).

Areas where this makes a perceptible difference:
- Anything that subscribes to entities (Initial subscribe_entities payload)
- Initial download of registries on first connection / restore
- History queries
- Saving states to the database
- Large logbook queries
- Anything that subscribes to events (appdaemon)

Cavets:
orjson supports serializing dataclasses natively (and much faster) which
eliminates the need to implement `as_dict` in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized. I audited all places where we have an `as_dict`
for a dataclass and found only backups needs to be adjusted (support for `Path` needed to be added for backups).  I was a little bit worried about `SensorExtraStoredData` with `Decimal` but it all seems to work out from since it converts it before it gets to the json encoding cc @dgomes

If it turns out to be a problem we can disable this
with option |= [orjson.OPT_PASSTHROUGH_DATACLASS](https://github.com/ijl/orjson#opt_passthrough_dataclass) and it
will fallback to `as_dict`

Its quite impressive for history queries
<img width="1271" alt="Screen_Shot_2022-05-30_at_23_46_30" src="https://user-images.githubusercontent.com/663432/171145699-661ad9db-d91d-4b2d-9c1a-9d7866c03a73.png">

* use for views as well

* handle UnicodeEncodeError

* tweak

* DRY

* DRY

* not needed

* fix tests

* Update tests/components/http/test_view.py

* Update tests/components/http/test_view.py

* black

* templates
2022-06-22 21:59:51 +02:00
Christopher BaileyandGitHub 0461ec1566 Fix auth_sign_path with query params (take 2) (#73829) 2022-06-22 10:09:21 -05:00
J. Nick KostonandGitHub 1e0a3246f4 Revert "Fix auth_sign_path with query params (#73240)" (#73808) 2022-06-21 22:45:16 -05:00
67618311fa Fix auth_sign_path with query params (#73240)
Co-authored-by: J. Nick Koston <[email protected]>
2022-06-21 14:21:47 -05:00
Joakim SørensenandGitHub 3a0111e65d Use supervisor envs instead of hassio (#72601) 2022-05-30 12:00:13 +02:00
Franck NijhofandGitHub 3afadf8adb Revert "Block peer certs on supervisor" (#67104) 2022-02-23 12:32:07 +01:00
938b64081b Block peer certs on supervisor (#66837)
Co-authored-by: Pascal Vizeli <[email protected]>
Co-authored-by: Mike Degatano <[email protected]>
2022-02-22 13:59:40 -08:00
J. Nick KostonandGitHub 3bf2be1765 Startup with an emergency self signed cert if the ssl certificate cannot be loaded (#66707) 2022-02-18 16:08:26 -08:00
Paulus SchoutsenandGitHub 63f8e437ed Add Home Assistant Content user (#64337) 2022-01-21 10:06:39 -08:00
Paulus SchoutsenandGitHub 914f7f85ec Add local only users (#57598) 2021-11-29 14:01:03 -08:00
Bram KragtenandGitHub 28c07f5c43 Fix CORS (#59360)
* Fix CORS

* rename

* Update view.py
2021-11-09 18:30:51 +01:00
Ville SkyttäandGitHub b52c5c82b1 Use http.HTTPStatus in components/[gh]* (#58246) 2021-10-23 20:34:53 +02:00
a4d9019ffc Refactor persistent notification to no longer route all data via a service (#57157)
* Convert persistent notification tests to async

* Create/dismiss persistent notifications in exposed functions, not service calls

* Fix notify persistent_notification

* Remove setting up persistent_notification

* Drop more setups

* Empty methods

* Undeprecate sync methods because too big task

* Fix setup clearing notifications

* Fix a bunch of tests

* Fix more tests

* Uno mas

* Test persistent notification events

* Clean up stale comment

Co-authored-by: Martin Hjelmare <[email protected]>
2021-10-07 12:58:00 +02:00
Erik MontnemeryandGitHub f6682ba99d Block tests from opening sockets (#55516) 2021-10-05 14:46:09 -10:00
Ville SkyttäandGitHub 1aa7c87151 Remove redundant aiohttp response status=200 kwargs (#56417)
* Remove redundant aiohttp response status=200 kwargs

* Remove some more in h.c.auth

* Restore explicit status=HTTP_OK for auth and webhook per review request
2021-09-21 10:51:12 -07:00
Erik MontnemeryandGitHub acdddabe1f Use hass_client_no_auth test fixture in integrations h-p (#55583) 2021-09-02 14:49:40 +02:00
Paulus SchoutsenandGitHub 38a7bdbcf3 Do not process forwarded for headers for cloud requests (#54364) 2021-08-10 01:45:56 +02:00
Marc MuellerandGitHub 10bfc78365 Fix missing encoding with open() (#53593)
* Fix missing encoding with open()

* Fix tests

* Improve open - frontend
2021-07-28 09:41:45 +02:00
Joakim PlateandGitHub d339e3bd8c Reject trusted network access from proxies (#52388) 2021-07-02 11:49:42 +02:00
Joakim PlateandGitHub eedf1c3ebe Reject requests from the proxy itself (#52073)
* Reject requests from the proxy itself

* Adjust tests
2021-06-27 19:02:51 +02:00
Franck NijhofandGitHub 33e08f38da Raise bad request when receiving HTTP request from untrusted proxy (#51839)
* Raise bad request when receiving HTTP request from untrusted proxy

* Fix code comment
2021-06-17 04:41:19 +02:00
Franck NijhofandGitHub cdd1f6b2f0 Always load middle to handle forwarded proxy data (#51332) 2021-06-01 09:38:55 -07:00
J. Nick KostonandGitHub a4432557d3 Defer writing http config until after startup has calmed down (#50000) 2021-05-02 19:48:49 -10:00
Bram KragtenandGitHub e3105c7eb1 Revert CORS changes for my home assistant (#47064)
* Revert CORS changes for my home assistant

* Update test_init.py

* Update test_init.py
2021-02-25 15:28:22 -08:00
Franck NijhofandGitHub 22389043eb Remove base_url fallback (#46316) 2021-02-10 14:31:11 +01:00
6f446cf627 Add my component (#46058)
Co-authored-by: Franck Nijhof <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>
2021-02-08 14:44:46 +01:00
gregodandGitHub cf9ea6f82d Sanitize user-agent in wrong_login message (#45251) 2021-01-18 09:21:30 +01:00
Pascal VizeliandGitHub e1427c45f2 Bump aioHTTP 3.7.3 - YARL 1.6.3 (#45180) 2021-01-15 13:19:22 +01:00
Franck NijhofandGitHub dee0f887de Extend filter and filter tests (#45179) 2021-01-15 10:30:29 +01:00
Franck Nijhof f047d04882 Add filtering 2021-01-14 20:02:01 +01:00
Franck NijhofandGitHub 65cf2fcb6f Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Franck NijhofandGitHub 1c2ebdf307 Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
Franck NijhofandGitHub 475e70986b Extend IP ban / failed login notification information (#39020) 2020-08-18 23:32:19 +02:00
cc4ebc925c Improve X-Forwarded-* request headers handling (#38696)
Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>
Co-authored-by: Franck Nijhof <[email protected]>
Co-authored-by: Pascal Vizeli <[email protected]>
2020-08-11 22:57:50 +02:00
Franck NijhofandGitHub 20710d8605 Add current request context to get_url helper (#38602) 2020-08-09 14:07:31 +02:00
J. Nick KostonandGitHub 578d4a9b6a Make the frontend available sooner (Part 1 of 2) (#36263)
* Part 1 of 2 (no breaking changes in part 1).

When integrations configured via the UI block startup or fail to start,
the webserver can remain offline which make it is impossible
to recover without manually changing files in
.storage since the UI is not available.

This change is the foundation that part 2 will build on
and enable a listener to start the webserver when the frontend
is finished loading.

Frontend Changes (home-assistant/frontend#6068)

* Address review comments

* bump timeout to 1800s, adjust comment

* bump timeout to 4h

* remove timeout failsafe

* and the test
2020-06-02 13:54:11 -05:00
Paulus SchoutsenandGitHub acbffb511d Fix base_url extract stack (#36331)
* Fix base_url extract stack

* Fix tests
2020-06-01 11:44:45 -07:00
Pascal VizeliandGitHub ed014e3c96 Revert "Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)" (#36251)
This reverts commit fbe7b4ddfa.
2020-05-29 10:18:39 +02:00
fbe7b4ddfa Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)
Co-authored-by: Paulus Schoutsen <[email protected]>
2020-05-28 21:09:07 -07:00
Franck NijhofandGitHub e3e3a113e9 async_get_url -> get_url (#35382) 2020-05-08 21:53:28 +02:00
Franck NijhofandGitHub e56dd8ed50 Detect use of deprecated base_url (#35353)
* Detect use of deprecated base_url

* Update get_url helper

* Update core migration

* Migrate all tests
2020-05-08 17:52:32 +02:00
Franck NijhofandGitHub 2223592486 Add get_url helper, deprecate base_url (#35224) 2020-05-08 02:29:47 +02:00
Paulus SchoutsenandGitHub 2af984917e Use asynctest-mock in most places (#35109)
* Use asynctest-mock in most places

* Fix broken patch in pilight
2020-05-03 11:27:19 -07:00
Paulus SchoutsenandGitHub 76f392476b Use a future for mock coro (#34989) 2020-04-30 16:31:00 -07:00
Paulus SchoutsenandGitHub ec47216388 Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00