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

249 saas connector zendesk ticket erasure #775

Merged
merged 13 commits into from
Jul 6, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jul 1, 2022

Purpose

Purpose of this PR is to add Zendesk User and Ticket Erasure endpoints.

Changes

  • Added config for Zendesk User and Ticket Erasure Endpoints
  • Associated tests and fixtures to validate above functionality

Checklist

  • Update CHANGELOG.md file
    • Merge in main so the most recent CHANGELOG.md file is being appended to
    • Add description within the Unreleased section in an appropriate category. Add a new category from the list at the top of the file if the needed one isn't already there.
    • Add a link to this PR at the end of the description with the PR number as the text. example: #1
  • Good unit test/integration test coverage
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #648

@ghost ghost requested a review from galvana July 1, 2022 16:37
@@ -25,7 +25,7 @@ services:
- /fidesops/src/fidesops.egg-info
environment:
- FIDESOPS__DEV_MODE=True
- FIDESOPS__LOG_PII=${FIDESOPS__LOG_PII}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert this back to ${FIDESOPS__LOG_PII}.

pytest.ini Outdated
@@ -1,7 +1,8 @@
[pytest]
env =
TESTING=True
log_cli=False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also set log_cli back to True and get rid of the log_level line.

method=HTTPMethod.POST,
path=f"/api/v2/users",
headers=headers,
body=body,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just use json=body so we don't have to pass in the Content-Type header.

}
}
)
updated_headers, formatted_body = format_body({}, body)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to call json.dumps or format_body we can just use the user dict directly like you did on line 150-161.

base_url = f"https://{zendesk_secrets['domain']}"
headers = {
"Content-Type": "application/json",
"Authorization": "Basic {}".format(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requests library has a shorthand for this
https://requests.readthedocs.io/en/latest/user/authentication/

you should just able to define the auth then use it in your request

auth = zendesk_secrets['username'], zendesk_secrets['api_key']
...
requests.post(url=..., auth=auth, json=...)

),
}

connector = SaaSConnector(zendesk_connection_config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rewrite this call to use requests instead of creating a SaaSConnector. I'd like to stay away from using SaaS connector logic to create test data.

base_url = f"https://{zendesk_secrets['domain']}"
headers = {
"Content-Type": "application/json",
"Authorization": "Basic {}".format(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the previous comment.

# Since user is deleted, it won't be available so response is 404
assert response.status_code == 404

tickets = x[f"{dataset_name}:tickets"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're reading how many tickets were deleted and not doing anything with the value.

assert response.status_code == 404

tickets = x[f"{dataset_name}:tickets"]
ticket_id = v[f"{dataset_name}:tickets"][0]["id"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better approach would be to iterate through all the tickets in v[f"{dataset_name}:tickets"] and make sure they're all deleted.

tickets = x[f"{dataset_name}:tickets"]
ticket_id = v[f"{dataset_name}:tickets"][0]["id"]
response = requests.get(
url=f"{base_url}/v2/tickets/f{ticket_id}.json",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you have an extra character f before the {ticket_id}, this is most likely returning a 404 because it's an invalid path and not because it's actually checking the ticket. Make sure you have the correct path.

Copy link
Collaborator

@galvana galvana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on this first pass, you have the high-level approach correct but just need to clean up some code and make it more consistent.

@galvana galvana added the run unsafe ci checks Triggers running of unsafe CI checks label Jul 5, 2022
Copy link
Collaborator

@galvana galvana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the recommended changes, approved!

@galvana galvana added run unsafe ci checks Triggers running of unsafe CI checks and removed run unsafe ci checks Triggers running of unsafe CI checks labels Jul 5, 2022
@galvana galvana removed the run unsafe ci checks Triggers running of unsafe CI checks label Jul 5, 2022
@galvana galvana added the run unsafe ci checks Triggers running of unsafe CI checks label Jul 5, 2022
@galvana galvana merged commit e6a23d5 into main Jul 6, 2022
@galvana galvana deleted the 249-saas-connector-zendesk-ticket-erasure branch July 6, 2022 00:02
sanders41 pushed a commit that referenced this pull request Sep 22, 2022
Co-authored-by: Hamza W <hamza@Hamzas-MacBook-Pro.local>
Co-authored-by: Adrian Galvan <adriang430@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
run unsafe ci checks Triggers running of unsafe CI checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SaaS Connector] Zendesk - ERASURE (TICKETING endpoints)
1 participant