Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Preserving headers in SaaSRequestParams during pagination #1069

Merged
merged 6 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ The types of changes are:

## [Unreleased](https://github.com/ethyca/fidesops/compare/1.7.0...main)

### Fixed

* HTTP headers are now preserved in requests generated from SaaS connector pagination [#1069](https://github.com/ethyca/fidesops/pull/1069)

## [1.7.0](https://github.com/ethyca/fidesops/compare/1.6.3...1.7.0)

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_next_request(

return SaaSRequestParams(
method=request_params.method,
headers=request_params.headers,
path=request_params.path,
query_params=request_params.query_params,
body=request_params.body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def get_next_request(
)
return SaaSRequestParams(
method=request_params.method,
headers=request_params.headers,
path=updated_path,
query_params=updated_query_params,
body=request_params.body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def get_next_request(
request_params.query_params[self.incremental_param] = param_value
return SaaSRequestParams(
method=request_params.method,
headers=request_params.headers,
path=request_params.path,
query_params=request_params.query_params,
body=request_params.body,
Expand Down
14 changes: 14 additions & 0 deletions tests/ops/service/pagination/test_pagination_strategy_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,17 @@ def test_cursor_with_empty_list(response_with_empty_list):
request_params, {}, response_with_empty_list, "conversations"
)
assert next_request is None


def test_headers_present_in_paginated_request(response_with_body):
config = CursorPaginationConfiguration(cursor_param="after", field="id")
request_params: SaaSRequestParams = SaaSRequestParams(
method=HTTPMethod.GET,
headers={"X-Fides-Token": "token"},
path="/conversations",
)
paginator = CursorPaginationStrategy(config)
next_request: SaaSRequestParams = paginator.get_next_request(
request_params, {}, response_with_body, "conversations"
)
assert next_request.headers == request_params.headers
16 changes: 16 additions & 0 deletions tests/ops/service/pagination/test_pagination_strategy_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,19 @@ def test_config_mismatch():
"The 'path' value must be specified when accessing the link from the body"
in str(exc.value)
)


def test_headers_present_in_paginated_request(response_with_body_link):
config = LinkPaginationConfiguration(source="body", path="links.next")
request_params: SaaSRequestParams = SaaSRequestParams(
method=HTTPMethod.GET,
headers={"x-custom-header": "abc"},
path="/customers",
query_params={"page": "abc"},
)

paginator = LinkPaginationStrategy(config)
next_request: Optional[SaaSRequestParams] = paginator.get_next_request(
request_params, {}, response_with_body_link, "customers"
)
assert next_request.headers == request_params.headers
18 changes: 18 additions & 0 deletions tests/ops/service/pagination/test_pagination_strategy_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,21 @@ def test_validate_request_missing_param():
method="GET", path="/test", query_params=query_params, pagination=pagination
)
assert "Query param 'page' not found." in str(exc.value)


def test_headers_present_in_paginated_request(response_with_body):
config = OffsetPaginationConfiguration(
incremental_param="page", increment_by=1, limit=10
)
request_params: SaaSRequestParams = SaaSRequestParams(
method=HTTPMethod.GET,
headers={"X-Fides-Token": "token"},
path="/conversations",
query_params={"page": 1},
)

paginator = OffsetPaginationStrategy(config)
next_request: Optional[SaaSRequestParams] = paginator.get_next_request(
request_params, {}, response_with_body, "conversations"
)
assert next_request.headers == request_params.headers