Skip to content

Commit ff283fa

Browse files
Test session recording strip-plus-sanitize value keys
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 25beba2 commit ff283fa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_session_recording_utils.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,30 @@ def __getitem__(self, key: str) -> object:
297297
assert exc_info.value.original_error is not None
298298

299299

300+
def test_parse_session_recordings_response_data_strips_and_sanitizes_value_keys():
301+
class _BrokenValueLookupMapping(Mapping[str, object]):
302+
def __iter__(self) -> Iterator[str]:
303+
yield " bad\tkey "
304+
305+
def __len__(self) -> int:
306+
return 1
307+
308+
def __getitem__(self, key: str) -> object:
309+
_ = key
310+
raise RuntimeError("cannot read recording value")
311+
312+
with pytest.raises(
313+
HyperbrowserError,
314+
match=(
315+
"Failed to read session recording object value "
316+
"for key 'bad\\?key' at index 0"
317+
),
318+
) as exc_info:
319+
parse_session_recordings_response_data([_BrokenValueLookupMapping()])
320+
321+
assert exc_info.value.original_error is not None
322+
323+
300324
def test_parse_session_recordings_response_data_strips_surrounding_whitespace_in_value_keys():
301325
class _BrokenValueLookupMapping(Mapping[str, object]):
302326
def __iter__(self) -> Iterator[str]:

0 commit comments

Comments
 (0)