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

416 Adds DRP exercise endpoint #496

Merged
merged 9 commits into from
May 12, 2022
Merged

416 Adds DRP exercise endpoint #496

merged 9 commits into from
May 12, 2022

Conversation

eastandwestwind
Copy link
Contributor

@eastandwestwind eastandwestwind commented May 11, 2022

Purpose

Adds DRP exercise endpoint

Changes

  • Adds endpoint for DRP exercise
  • Refactors DRP status endpoint into DRP-specific endpoint file
  • Adds unit tests for DRP exercise
  • Adds DRP folder to postman collection
  • Additionally, removes ignore_missing_imports flag for mypy

Checklist

  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #416

multidimensional_urlencode==0.0.4
pyjwt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is also a dep of fidesctl, so I've kept version out here to let package manager handle it. Maybe there's a better way to avoid package conflicts?

value,
)
# handle nested dict/objects
if not isinstance(value, (bytes, str, int, float)):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cache doesn't handle vals as bytes/str/int/float. Perhaps we should instead cache the whole req body as a str (json.loads()) instead of separating the top level props as cache keys. But this works as far as caching for debugging purposes only.

@@ -22,7 +24,7 @@ class DrpPrivacyRequestCreate(BaseSchema):

meta: DrpMeta
regime: Optional[DrpRegime]
exercise: DrpAction
exercise: List[DrpAction]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DRP spec dictates that this is a list. So we'll take in a list even though we don't support > 1 item

@seanpreston seanpreston self-assigned this May 11, 2022
@eastandwestwind
Copy link
Contributor Author

eastandwestwind commented May 11, 2022

Verified both endpoints manually in postman:

Screen Shot 2022-05-11 at 2 31 03 PM

Screen Shot 2022-05-11 at 2 27 03 PM

status_code=HTTP_424_FAILED_DEPENDENCY,
detail=exc.args[0],
)
except Exception as exc:
Copy link
Contributor

@seanpreston seanpreston May 11, 2022

Choose a reason for hiding this comment

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

These except blocks should surround only the minimal code, and we should avoid using broad excepts — unless there's a specific reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was to be consistent with what we have for POST "/privacy-request". But I can remove it, just lemme know your preference

"email": drp_identity.email,
"phone_number": drp_identity.phone_number,
}
return PrivacyRequestIdentity(**identity_kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to discard any extra attributes on DrpIdentity silently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll surface a warning log message using a validator or a check within this mapper

if not isinstance(value, (bytes, str, int, float)):
cache.set_with_autoexpire(
get_drp_request_body_cache_key(self.id, key),
repr(value),
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this probably feels hacky but good choice in effort/reward trade-off if this is only for debug purposes as you say.

Looks like value can only ever be a key from this schema, which should be just fine.

If we want to do more with this data though let's make sure we're breaking it down and storing it by key. We could write a util method to handle that automatically for Pydantic schemas for instance.

Copy link
Contributor

@seanpreston seanpreston left a comment

Choose a reason for hiding this comment

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

LGTM — would be nice if we could address the URL nit and JWT config var before merging!

@eastandwestwind
Copy link
Contributor Author

Thanks for the review @seanpreston! This is good to go.

I've added a warning message in case we don't support the specific identity props passed in: https://github.com/ethyca/fidesops/pull/496/files#diff-e2fc0ccbfb0913f3f97fd1f425377e29beb158ea9581cc5e171e044b8927c4a4R30

@seanpreston seanpreston merged commit 7633ee8 into main May 12, 2022
@seanpreston seanpreston deleted the 416-drp-exercise branch May 12, 2022 13:12
adamsachs pushed a commit to adamsachs/fidesops_forked_test that referenced this pull request May 17, 2022
* initial infra for drp exercise endpoint

* formatting, refactoring out drp status endpoint into drp-specific endpoint

* gets tests passing

* formatting

* removes ignore_missing_imports

* adds back import checks to mypy.ini

* adds postman collection

* cr comments

* fix test
sanders41 pushed a commit that referenced this pull request Sep 22, 2022
* initial infra for drp exercise endpoint

* formatting, refactoring out drp status endpoint into drp-specific endpoint

* gets tests passing

* formatting

* removes ignore_missing_imports

* adds back import checks to mypy.ini

* adds postman collection

* cr comments

* fix test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DRP] Add support for POST /exercise endpoint
2 participants