Commit graph

148 commits

Author SHA1 Message Date
Robert Resch
bcc2dd99b2
Rename strict connection static page to guard page (#116085) 2024-04-24 10:29:59 +02:00
Sid
3799d20d43
Enable Ruff B905 (#114197) 2024-04-14 00:14:26 -05:00
Robert Resch
348e1df949
Add strict connection (#112387)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-12 14:47:46 +02:00
Sid
0d66d298ec
Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
Sid
d5f883fbf0
Unignore Ruff PLR in tests (#114470)
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Joost Lekkerkerker
6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Jan-Philipp Benecke
f96bb6754b
Remove deprecated hass.components from http test (#113823) 2024-03-19 22:32:27 +02:00
Sid
00ec7f11f0
Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
Sid
ccd2e989c3
Enable ruff RUF005 and fix occurrences (#113589) 2024-03-16 07:37:20 -10:00
Marc Mueller
aa16a9d707
Add empty line after module docstring (3) (#112750) 2024-03-08 20:38:34 +01:00
Marc Mueller
32f3f46542
Add empty line after module docstring (2) [tests.components] (#112737) 2024-03-08 19:16:21 +01:00
Marc Mueller
c88b337600
Add empty line after module docstring [tests f-k] (#112709) 2024-03-08 14:50:04 +01:00
Marc Mueller
2d701d5a7d
Use aiohttp.AppKey for http cors keys (#112658) 2024-03-08 11:51:59 +01:00
Marc Mueller
eb8f8e1ae4
Use aiohttp.AppKey for http ban keys (#112657) 2024-03-08 11:13:24 +01:00
Marc Mueller
8ca127df2a
Use KEY_HASS [h-z] (#112610) 2024-03-07 18:03:44 +01:00
Marc Mueller
531e25cbc6
Change KEY_HASS to be an aiohttp AppKey (#111954) 2024-03-07 13:37:48 +01:00
Marc Mueller
030727b078
Remove deprecated event_loop fixtures in tests (#109048) 2024-01-29 14:24:58 +01:00
J. Nick Koston
b54e282801
Remove follow symlinks support from CachingStaticResource (#109015) 2024-01-28 10:07:12 -10:00
J. Nick Koston
2eea658fd8
Convert getting and removing access tokens to normal functions (#108670) 2024-01-22 20:51:33 -10:00
J. Nick Koston
1b048ff388
Remove HomeAssistantAccessLogger (#104173) 2023-11-29 10:40:19 -07:00
Robert Resch
852fb58ca8
Extend auth/providers endpoint and add /api/person/list endpoint for local ip requests (#103906)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-11-24 17:11:54 +01:00
Chuck Foster
aca48b5e45
Fix duplicate Ban file entries (#103953) 2023-11-14 17:13:14 +01:00
J. Nick Koston
da1780f9ec
Small cleanups to process_success_login (#103282) 2023-11-07 10:48:34 +01:00
J. Nick Koston
8eb7766f30
Avoid path construction for static files cache hit (#102882) 2023-10-31 14:31:58 -05:00
Erik Montnemery
c481fdb7d0
Rename safe mode to recovery mode (#102580) 2023-10-23 20:33:08 +02:00
Franck Nijhof
85c2216cd7
Ensure headers middleware handles errors too (#98397) 2023-08-14 17:48:11 +02:00
Franck Nijhof
369a484a78
Add default headers to webserver responses (#97784)
* Add default headers to webserver responses

* Set default server header

* Fix other tests
2023-08-06 23:25:13 -04:00
Marc Mueller
b23b2ac2e8
Fix http test DeprecationWarnings (#97737) 2023-08-04 11:32:23 +02:00
Marc Mueller
887e48c440
Replace deprecated aiohttp_unused_port fixture (#97626) 2023-08-02 20:30:13 +02:00
J. Nick Koston
48485fc2bf
Complete persistent notifications migration (#92828)
* Complete migration of persistent notifications

Persistent notifications are no longer stored in
the state machine and no longer fire events

* Complete migration of persistent notifications

Persistent notifications are no longer stored in
the state machine and no longer fire events

* fixes

* fixes

* fixes

* ws test

* update tests

* update tests

* fix more tests

* fix more tests

* more fixes

* fix

* fix person

* fix person

* keep whitelist

* use singleton
2023-05-25 23:09:13 -04:00
J. Nick Koston
e27554f7a6
Improve http handler performance (#93324) 2023-05-21 13:36:03 -05:00
epenet
e277bbb513
Use tmp_path in tests (#91203)
* Use tmp_path in tests

* Use joinpath

* Prefer / operator

* Cleanup
2023-04-12 08:19:01 +02:00
Franck Nijhof
b033232b06
Filter out ASCII tab or newline from input URLs (#90348) 2023-03-27 13:49:40 -04:00
J. Nick Koston
dd0f05b980
Avoid calling the http access logging when logging is disabled (#90152) 2023-03-23 09:55:02 -10:00
Paulus Schoutsen
12352b2ce1
Always enforce URL param ordering for signed URLs (#90148)
Always enforce URL param ordering
2023-03-22 22:54:09 -04:00
epenet
ab4a726e6c
Add tmpdir to known fixtures in pylint (#89844) 2023-03-17 10:22:02 +01:00
Franck Nijhof
95ed6fbc08
Small improvements to middleware filter (#88921)
Small improvements middleware filter
2023-02-28 12:07:17 -05:00
Franck Nijhof
ed79265843
Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet
9404a107b2
Add type hints to integration tests (part 10) (#87985) 2023-02-13 10:25:26 +01:00
epenet
37a2040d7b
Add type hints to integration tests (h-i) (#87703) 2023-02-08 18:12:56 +01:00
epenet
aa00114c2f
Add return type to async tests without arguments (#87612) 2023-02-07 10:26:56 +01:00
Paulus Schoutsen
9c0856787d
Improve JSON errors from HTTP view (#87042) 2023-01-31 20:37:26 +01:00
epenet
30bf0634fe
Add per-file-ignore to pylint (#86289) 2023-01-22 17:26:24 +01:00
Joakim Plate
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 Degatano
82151bfd40
Create repairs for unsupported and unhealthy (#80747) 2022-10-31 09:57:54 -04:00
Franck Nijhof
9a4a7e2f4d
Extend failed login message with the request URL (#75218) 2022-07-14 21:43:14 +02:00
J. Nick Koston
0c29b68cf8
Switch linear search to a dict lookup for ip bans (#74482) 2022-07-07 10:57:44 +02:00
J. Nick Koston
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 Bailey
0461ec1566
Fix auth_sign_path with query params (take 2) (#73829) 2022-06-22 10:09:21 -05:00
J. Nick Koston
1e0a3246f4
Revert "Fix auth_sign_path with query params (#73240)" (#73808) 2022-06-21 22:45:16 -05:00