Skip to content

Commit

Permalink
Bugfix/page tokens allow none (#363)
Browse files Browse the repository at this point in the history
* Don't try to pattern match non-strings

* add test

* CHANGELOG

* style

* rename test
  • Loading branch information
timabrmsn committed Aug 27, 2021
1 parent bc8a188 commit 4846a91
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
The intended audience of this file is for py42 consumers -- as such, changes that don't affect
how a consumer would use the library (e.g. adding unit tests, updating documentation, etc) are not captured here.

## Unreleased

### Fixed

- Bug where `sdk.securitydata.search_all_file_events()` errored when `page_token` param was `None`.

## 1.18.0 - 2021-08-19

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/py42/services/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def escape_quote_chars(token):
of the last event returned in the response. Some eventIds have double-quote chars in
them, which need to be escaped when passing the token in the next search request.
"""
if not isinstance(token, (str, bytes)):
return token

unescaped_quote_pattern = r'[^\\]"'

return re.sub(
Expand Down
16 changes: 16 additions & 0 deletions tests/clients/test_securitydata.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,3 +828,19 @@ def test_search_all_file_events_handles_escaped_quote_chars_in_token(
"pgSize": 10000,
}
connection.post.assert_called_once_with(FILE_EVENT_URI, json=expected)

def test_search_all_file_events_when_token_is_none_succeeds(
self,
connection,
preservation_data_service,
saved_search_service,
storage_service_factory,
):
file_event_service = FileEventService(connection)
security_client = SecurityDataClient(
file_event_service,
preservation_data_service,
saved_search_service,
storage_service_factory,
)
security_client.search_all_file_events(FileEventQuery.all(), page_token=None)

0 comments on commit 4846a91

Please sign in to comment.