Skip to content

Commit

Permalink
To keep work scoped, add masking strategy override to CollectionMeta,…
Browse files Browse the repository at this point in the history
… removing it from field and dataset level meta.

- Constrain the masking strategies into an enum.
  • Loading branch information
pattisdr committed Sep 17, 2024
1 parent 27f65ec commit cd49d65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@
)


class MaskingStrategy(BaseModel):
strategy: str
class MaskingStrategies(str, Enum):
delete = "delete"


class MaskingStrategyOverride(BaseModel):
strategy: MaskingStrategies


class FidesModel(BaseModel):
Expand Down Expand Up @@ -410,7 +414,6 @@ class FidesMeta(BaseModel):
default=None,
description="Optionally specify that a field may be used as a custom request field in DSRs. The value is the name of the field in the DSR.",
)
masking_strategy_override: Optional[MaskingStrategy] = None

@field_validator("data_type")
@classmethod
Expand Down Expand Up @@ -521,7 +524,7 @@ class CollectionMeta(BaseModel):

after: Optional[List[FidesCollectionKey]] = None
skip_processing: Optional[bool] = False
masking_strategy_override: Optional[MaskingStrategy] = None
masking_strategy_override: Optional[MaskingStrategyOverride] = None


class DatasetCollection(FidesopsMetaBackwardsCompat):
Expand Down Expand Up @@ -585,7 +588,6 @@ class DatasetMetadata(BaseModel):

resource_id: Optional[str] = None
after: Optional[List[FidesKey]] = None
masking_strategy_override: Optional[MaskingStrategy] = None


class Dataset(FidesModel, FidesopsMetaBackwardsCompat):
Expand Down
11 changes: 10 additions & 1 deletion tests/fideslang/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
FidesDatasetReference,
FidesMeta,
FidesModel,
MaskingStrategies,
MaskingStrategyOverride,
Policy,
PolicyRule,
PrivacyDeclaration,
Expand Down Expand Up @@ -642,7 +644,7 @@ def test_specify_fides_meta_with_custom_request_field(self):
length=None,
return_all_elements=None,
read_only=None,
custom_request_field="site_id"
custom_request_field="site_id",
)

def test_specify_both_fidesops_meta_and_fides_meta(self):
Expand Down Expand Up @@ -789,6 +791,13 @@ def test_collection_key_has_too_many_components(self):
def test_valid_collection_key(self):
CollectionMeta(after=[FidesCollectionKey("test_dataset.test_collection")])

def test_(self):
meta = CollectionMeta(masking_strategy_override={"strategy": "delete"})

assert meta.masking_strategy_override == MaskingStrategyOverride(
strategy=MaskingStrategies.delete
)


class TestAnyUrlString:
def test_valid_url(self):
Expand Down

0 comments on commit cd49d65

Please sign in to comment.