Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zendesk request override get tasks #5429

Merged
merged 14 commits into from
Nov 6, 2024
Merged

Conversation

Vagoasdf
Copy link
Contributor

@Vagoasdf Vagoasdf commented Oct 29, 2024

Closes LA#32

Pairs With FidesPlus#1685

Description Of Changes

Creating a new Request Override that would check for the status of the ticket on a delete request and halt it if there is an open ticket

Currently we are using a default list to determine if a ticket is open. Basically, anything that its not "closed" its open. The list is ["new", "open", "pending", "hold", "solved"]

It could be a parametrized list on the future, but the current fides iteration does not support indicating a multi-select field from the config.yml file

Code Changes

  • Creating new Request Override
  • Creating tests for the new functionality
  • Adding fixtures that manage the new state

Steps to Confirm

  • Create a new user with a known email on Zendesk via Postman
  • Create a few new tickets for that username via Postman.
  • Set up the Zendesk Integration (This can be done copying the relevant config.yml on the paired PR)
  • Try to make a Delete request through the test site with the known email
  • Check the Status of the request. It should fail with the message ""User still has open tickets, halting request"
  • Update the tickets status to closed via Postman
  • Try to make a Delete Request through the test site with the known email
  • Check the status of the request. It should've succesed
  • Check on Postman and/or Zendesk if the user still exists. It should not

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md

Adding an override that checks on the status of  the tickets, and skips the delete in case the user still has open tickets
@Vagoasdf Vagoasdf requested a review from a team as a code owner October 29, 2024 13:52
Copy link

vercel bot commented Oct 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fides-plus-nightly ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 0:46am

@Vagoasdf
Copy link
Contributor Author

Vagoasdf commented Oct 29, 2024

I'm not sure on which of the Two PR's the Changelog should be updated. Putting them here for now

Copy link

cypress bot commented Oct 29, 2024

fides    Run #10820

Run Properties:  status check passed Passed #10820  •  git commit 1a059d2868 ℹ️: Merge 161a7f13e6544dbe9ad966d16374605b12a6e694 into c11da91030fa3d057c1706d14ea7...
Project fides
Branch Review refs/pull/5429/merge
Run status status check passed Passed #10820
Run duration 00m 38s
Commit git commit 1a059d2868 ℹ️: Merge 161a7f13e6544dbe9ad966d16374605b12a6e694 into c11da91030fa3d057c1706d14ea7...
Committer Bruno Gutierrez Rios
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
View all changes introduced in this branch ↗︎

@Vagoasdf Vagoasdf requested review from galvana and Roger-Ethyca and removed request for a team, galvana and Roger-Ethyca October 29, 2024 15:06
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 48.48485% with 17 lines in your changes missing coverage. Please review.

Project coverage is 85.41%. Comparing base (c11da91) to head (161a7f1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rride_implementations/zendesk_request_overrides.py 48.48% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5429      +/-   ##
==========================================
- Coverage   85.47%   85.41%   -0.06%     
==========================================
  Files         384      385       +1     
  Lines       24119    24152      +33     
  Branches     2625     2630       +5     
==========================================
+ Hits        20615    20630      +15     
- Misses       2950     2967      +17     
- Partials      554      555       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Vagoasdf
Copy link
Contributor Author

Is it possible that Codecov is missing the test coverage because we are missing the Zendesk_config.yml file?

Comment on lines 20 to 21
## Uplifted from Connectors-logitech
## See https://github.com/ethyca/connectors-logitech/blob/main/connectors/zendesk/zendesk_request_overrides.py#L95
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to mention customer's names in this public repo



@register("zendesk_logitech_tickets_read", [SaaSRequestType.READ])
def zendesk_logitech_tickets_read(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, let's just call it zendesk_tickets_read

Suggested change
def zendesk_logitech_tickets_read(
def zendesk_tickets_read(

@@ -40,7 +40,7 @@ def zendesk_erasure_identity_email() -> str:
class ZendeskClient:
def __init__(self, secrets: Dict[str, Any]):
self.base_url = f"https://{secrets['domain']}"
self.auth = secrets["username"], secrets["api_key"]
self.auth = secrets["username"] + "/token", secrets["api_key"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I commented on this somewhere else too, but if we don't have a migration in place to migrate the username, we should just leave things as they are. I agree this is cleaner, but we would break existing integrations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case, i think we should add it to the hoverable description on the config. Something that points to the user that they hadd to add the "/token" at the end without lookinv over the Zendesk Docs

CHANGELOG.md Outdated
@@ -21,6 +21,9 @@ The types of changes are:
- Added DataHub integration config [#5401](https://github.com/ethyca/fides/pull/5401)
- Added keepalive settings to the Redshift integration [#5433](https://github.com/ethyca/fides/pull/5433)

### Changed
- Adding a Request Override on Zendesk Ticket's that checks for the tickets statuses on a Delete Request
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Adding a Request Override on Zendesk Ticket's that checks for the tickets statuses on a Delete Request
- Preventing erasures for the Zendesk integration if there are any open tickets [#5429](https://github.com/ethyca/fides/pull/5429)

"""
if policy.get_rules_for_action(action_type=ActionType.erasure):
for ticket in tickets:
## TODO: Check with Ramp that the Statuses list is the expected one
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, let's avoid putting customer names in the comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Once we move to fidesplus, we're ok 😄

Comment on lines 106 to 113
(
access_results,
erasure_results,
) = await zendesk_runner.non_strict_erasure_request(
access_policy=policy,
erasure_policy=erasure_policy_string_rewrite,
identities={"email": zendesk_erasure_identity_email},
)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can simplify this since we're not using the results

Suggested change
(
access_results,
erasure_results,
) = await zendesk_runner.non_strict_erasure_request(
access_policy=policy,
erasure_policy=erasure_policy_string_rewrite,
identities={"email": zendesk_erasure_identity_email},
)
await zendesk_runner.non_strict_erasure_request(
access_policy=policy,
erasure_policy=erasure_policy_string_rewrite,
identities={"email": zendesk_erasure_identity_email},
)

Copy link
Contributor

@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.

Just one small change and we're good to go!

"""
if policy.get_rules_for_action(action_type=ActionType.erasure):
for ticket in tickets:
if ticket["status"] in ["new", "open", "pending", "hold", "solved"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I gave this some more thought, we can be a bit safer about this. Let's just halt the request if any ticket is not set to "closed". It's better to check for an explicit "closed" than to try to enumerate over all statuses that can be considered open.

Suggested change
if ticket["status"] in ["new", "open", "pending", "hold", "solved"]:
if ticket["status"] != "closed":

@Vagoasdf Vagoasdf requested a review from galvana November 5, 2024 16:01
@Vagoasdf Vagoasdf merged commit 5ca600a into main Nov 6, 2024
12 of 14 checks passed
@Vagoasdf Vagoasdf deleted the zendesk_request_override_get_tasks branch November 6, 2024 12:43
Copy link

cypress bot commented Nov 6, 2024

fides    Run #10821

Run Properties:  status check passed Passed #10821  •  git commit 5ca600a13c: Zendesk request override get tasks (#5429)
Project fides
Branch Review main
Run status status check passed Passed #10821
Run duration 00m 38s
Commit git commit 5ca600a13c: Zendesk request override get tasks (#5429)
Committer Bruno Gutierrez Rios
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
View all changes introduced in this branch ↗︎

@Vagoasdf Vagoasdf mentioned this pull request Nov 6, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants