Skip to content

Commit

Permalink
Used new policy in the code, converted code flow from delete to update"
Browse files Browse the repository at this point in the history
  • Loading branch information
sadaqatullah committed Nov 22, 2022
1 parent a693aa1 commit 587cdbc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
16 changes: 12 additions & 4 deletions data/saas/config/recharge_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ saas_config:
- name: email
identity: email
data_path: customers
delete:
method: DELETE
update:
method: PUT
path: /customers/<customer_id>
body: |
{
<masked_object_fields>
}
param_values:
- name: customer_id
references:
Expand All @@ -62,9 +66,13 @@ saas_config:
field: customer.id
direction: from
data_path: addresses
delete:
method: DELETE
update:
method: PUT
path: /addresses/<address_id>
body: |
{
"address": {<masked_object_fields>}
}
param_values:
- name: address_id
references:
Expand Down
15 changes: 15 additions & 0 deletions tests/ops/fixtures/saas/recharge_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def get_customer(self, email):
assert customer_response.ok
return customer_response.json()

def delete_customer(self, customer_id):
customer_response: Response = requests.delete(
url=f"{self.base_url}/customers/{customer_id}", headers=self.headers
)
assert customer_response.ok

# 2: Creates, checks for existance and deletes address
def create_address(self, customer_id) -> Response:
address_body = {
Expand Down Expand Up @@ -187,6 +193,12 @@ def get_addresses(self, customer_id):
assert address_response.ok
return address_response.json()

def delete_address(self, address_id):
address_response: Response = requests.delete(
url=f"{self.base_url}/addresses/{address_id}", headers=self.headers
)
assert address_response.ok


@pytest.fixture(scope="function")
def recharge_test_client(recharge_connection_config: RechargeTestClient) -> Generator:
Expand Down Expand Up @@ -221,3 +233,6 @@ def recharge_erasure_data(
address_id = address_response.json()["address"]["id"]

yield customer_response, address_response

recharge_test_client.delete_address(address_id)
recharge_test_client.delete_customer(customer_id)
33 changes: 18 additions & 15 deletions tests/ops/integration_tests/saas/test_recharge_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_recharge_connection_test(recharge_connection_config) -> None:
@pytest.mark.integration_recharge
@pytest.mark.asyncio
async def test_recharge_access_request_task(
db,
policy,
recharge_connection_config,
recharge_dataset_config,
recharge_identity_email,
db,
policy,
recharge_connection_config,
recharge_dataset_config,
recharge_identity_email,
) -> None:
"""Full access request based on the Recharge SaaS config"""

Expand Down Expand Up @@ -129,14 +129,14 @@ async def test_recharge_access_request_task(
@pytest.mark.integration_recharge
@pytest.mark.asyncio
async def test_recharge_erasure_request_task(
db,
policy,
erasure_policy_string_rewrite,
recharge_connection_config,
recharge_dataset_config,
recharge_erasure_identity_email,
recharge_erasure_data,
recharge_test_client,
db,
policy,
erasure_policy_complete_mask,
recharge_connection_config,
recharge_dataset_config,
recharge_erasure_identity_email,
recharge_erasure_data,
recharge_test_client,
) -> None:
privacy_request = PrivacyRequest(
id=f"test_recharge_erasure_request_task_{random.randint(0, 1000)}"
Expand Down Expand Up @@ -235,15 +235,18 @@ async def test_recharge_erasure_request_task(

x = await graph_task.run_erasure(
privacy_request,
erasure_policy_string_rewrite,
erasure_policy_complete_mask,
graph,
[recharge_connection_config],
identity_kwargs,
get_cached_data_for_erasures(privacy_request.id),
db,
)

assert sum(x.values()) == len(x.values())
assert x == {
'recharge_instance:addresses': 1,
'recharge_instance:customers': 1
}

address = recharge_test_client.get_addresses(
recharge_erasure_data[1].json().get("address", {}).get("id")
Expand Down

0 comments on commit 587cdbc

Please sign in to comment.