-
Notifications
You must be signed in to change notification settings - Fork 78
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
Support for consent management report #4452
Changes from all commits
131d017
004cd61
b101d78
63a6475
a92564a
6c2a546
ad7800f
69a7450
79487f6
8e359c2
8f3cbb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""add indexes to ctl_systems and privacydeclaration | ||
|
||
Revision ID: 7f7c2b098f5d | ||
Revises: 1af6950f4625 | ||
Create Date: 2023-11-21 18:52:34.508076 | ||
|
||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7f7c2b098f5d" | ||
down_revision = "1af6950f4625" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm;") | ||
op.create_index( | ||
"ix_ctl_systems_name", | ||
"ctl_systems", | ||
[sa.text("name gin_trgm_ops")], | ||
postgresql_using="gin", | ||
Comment on lines
+20
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adds a GIN index to be able to do a partial search on system name (%name%) |
||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_index("ix_ctl_systems_name", table_name="ctl_systems") | ||
op.execute("DROP EXTENSION IF EXISTS pg_trgm;") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from fastapi import Depends, Security | ||
from fideslang.gvl import MAPPED_PURPOSES, MAPPED_SPECIAL_PURPOSES | ||
from sqlalchemy.orm import Session | ||
from starlette.status import HTTP_200_OK | ||
|
||
from fides.api.api import deps | ||
from fides.api.oauth.utils import verify_oauth_client | ||
from fides.api.schemas.tcf import PurposesResponse | ||
from fides.api.util.api_router import APIRouter | ||
from fides.common.api.v1 import urn_registry as urls | ||
|
||
router = APIRouter(tags=["Purposes"], prefix=urls.V1_URL_PREFIX) | ||
|
||
|
||
@router.get( | ||
"/purposes", | ||
dependencies=[Security(verify_oauth_client)], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not tied to any scope, this is available for any authenticated user |
||
status_code=HTTP_200_OK, | ||
response_model=PurposesResponse, | ||
) | ||
def get_purposes( | ||
db: Session = Depends(deps.get_db), | ||
) -> PurposesResponse: | ||
""" | ||
Return a map of purpose and special purpose IDs to mapped purposes which include data uses. | ||
""" | ||
|
||
purposes = {} | ||
special_purposes = {} | ||
for purpose in MAPPED_PURPOSES.values(): | ||
purposes[purpose.id] = purpose | ||
for special_purpose in MAPPED_SPECIAL_PURPOSES.values(): | ||
special_purposes[special_purpose.id] = special_purpose | ||
return PurposesResponse(purposes=purposes, special_purposes=special_purposes) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,9 @@ | |
"/privacy-request/transfer/{privacy_request_id}/{rule_key}" | ||
) | ||
|
||
# Purpose URLs | ||
PURPOSES = "/purposes" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it's best to make this its own URL or if it should go under an existing path |
||
|
||
|
||
# Identity Verification URLs | ||
ID_VERIFICATION_CONFIG = "/id-verification/config" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pytest | ||
from starlette.status import HTTP_200_OK, HTTP_401_UNAUTHORIZED | ||
|
||
from fides.common.api.v1.urn_registry import PURPOSES, V1_URL_PREFIX | ||
|
||
|
||
class TestGetPurposes: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simple test that just checks access based on auth header |
||
@pytest.fixture(scope="function") | ||
def url(self) -> str: | ||
return V1_URL_PREFIX + PURPOSES | ||
|
||
def test_get_purposes_unauthenticated(self, url, api_client): | ||
response = api_client.get(url) | ||
assert response.status_code == HTTP_401_UNAUTHORIZED | ||
|
||
def test_get_purposes(self, url, api_client, generate_auth_header): | ||
auth_header = generate_auth_header([]) | ||
response = api_client.get(url, headers=auth_header) | ||
assert response.status_code == HTTP_200_OK | ||
|
||
data = response.json() | ||
assert "purposes" in data | ||
assert "special_purposes" in data | ||
assert len(data["purposes"]) == 11 | ||
assert len(data["special_purposes"]) == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
pg_trgm
extension has been available since Postgres 8.3 so we should be ok to enable it