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

Add Cookies Schema #115

Merged
merged 12 commits into from
Jun 19, 2023
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ The types of changes are:

## [Unreleased](https://github.com/ethyca/fideslang/compare/1.4.1...main)


### Changed

- Add `cookies` property to `PrivacyDeclaration` and `System` [#115](https://github.com/ethyca/fideslang/pull/115)

### Fixed

- Fix Fideslang visual explorer on docs site [#123](https://github.com/ethyca/fideslang/pull/123)
Expand Down
2 changes: 1 addition & 1 deletion src/fideslang/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"""Git implementation of _version.py."""

import errno
import functools
import os
import re
import subprocess
import sys
from typing import Callable, Dict
import functools


def get_keywords():
Expand Down
17 changes: 16 additions & 1 deletion src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ class DataQualifier(FidesModel):
_no_self_reference: classmethod = no_self_reference_validator


class Cookies(BaseModel):
"""The Cookies resource model"""

name: str
path: Optional[str]
domain: Optional[str]

class Config:
"""Config for the cookies"""

orm_mode = True


class DataSubjectRights(BaseModel):
"""
The DataSubjectRights resource model.
Expand Down Expand Up @@ -819,6 +832,9 @@ class PrivacyDeclaration(BaseModel):
ingress: Optional[List[FidesKey]] = Field(
description="The resources from which data is received. Any `fides_key`s included in this list reference `DataFlow` entries in the `ingress` array of any `System` resources to which this `PrivacyDeclaration` is applied."
)
cookies: Optional[List[Cookies]] = Field(
description="Cookies associated with this data use to deliver services and functionality",
)

@validator("dataset_references")
@classmethod
Expand Down Expand Up @@ -960,7 +976,6 @@ class System(FidesModel):
default=DataProtectionImpactAssessment(),
description=DataProtectionImpactAssessment.__doc__,
)

_sort_privacy_declarations: classmethod = validator(
"privacy_declarations", allow_reuse=True
)(sort_list_objects_by_name)
Expand Down
2 changes: 1 addition & 1 deletion src/fideslang/relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import inspect
from enum import Enum
from functools import reduce
from typing import Optional, List, Set
from typing import List, Optional, Set

from fideslang.models import BaseModel, FidesKey, Taxonomy
from fideslang.utils import get_resource_by_fides_key
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Common fixtures to be used across tests."""
import os
from typing import Any, Dict

import os
import pytest
import yaml

Expand Down
4 changes: 4 additions & 0 deletions tests/fideslang/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_system_valid(self) -> None:
meta={"some": "meta stuff"},
name="Test System",
organization_fides_key=1,
cookies=[{"name": "test_cookie"}],
privacy_declarations=[
PrivacyDeclaration(
data_categories=[],
Expand All @@ -84,6 +85,9 @@ def test_system_valid(self) -> None:
egress=["test_system_2"],
ingress=["test_system_3"],
name="declaration-name",
cookies=[
{"name": "test_cookie", "path": "/", "domain": "example.com"}
],
)
],
registry_id=1,
Expand Down
10 changes: 8 additions & 2 deletions tests/fideslang/test_relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def test_find_referenced_fides_keys_2():
name="test_dc",
fides_key="test_dc",
description="test description",
egress=[DataFlow(fides_key="key_1", type="system", data_categories=None), DataFlow(fides_key="key_2", type="system", data_categories=None)],
egress=[
DataFlow(fides_key="key_1", type="system", data_categories=None),
DataFlow(fides_key="key_2", type="system", data_categories=None),
],
system_type="test",
privacy_declarations=None,
)
Expand Down Expand Up @@ -66,7 +69,10 @@ def test_get_referenced_missing_keys():
name="test_system",
fides_key="test_system",
description="test description",
egress=[DataFlow(fides_key="key_3", type="system", data_categories=None), DataFlow(fides_key="key_4", type="system", data_categories=None)],
egress=[
DataFlow(fides_key="key_3", type="system", data_categories=None),
DataFlow(fides_key="key_4", type="system", data_categories=None),
],
system_type="test",
privacy_declarations=None,
)
Expand Down
7 changes: 6 additions & 1 deletion tests/fideslang/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ def test_create_valid_system():
dataset_references=[],
)
],
egress=[DataFlow(fides_key="another_system", type="system", data_categories=None), DataFlow(fides_key="yet_another_system", type="system", data_categories=None)],
egress=[
DataFlow(fides_key="another_system", type="system", data_categories=None),
DataFlow(
fides_key="yet_another_system", type="system", data_categories=None
),
],
)
assert True

Expand Down