remove FPE from anonymizer since we do not support it. (#552)

Co-authored-by: Nava Vaisman Levy <navalev@users.noreply.github.com>
This commit is contained in:
Shiran Rubin 2021-02-24 19:54:43 +02:00 коммит произвёл GitHub
Родитель a229ec79da
Коммит a3eb6e09db
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 7 добавлений и 40 удалений

Просмотреть файл

@ -193,7 +193,7 @@ paths:
type: string
example: "mask"
example:
["fpe", "hash", "mask", "redact", "replace"]
["hash", "mask", "redact", "replace"]
/health:

Просмотреть файл

@ -101,7 +101,7 @@ def test_given_anonymizers_called_then_expected_anonymizers_list_returned():
response_status, response_content = anonymizers()
expected_response = """
["fpe", "hash", "mask", "redact", "replace"]
["hash", "mask", "redact", "replace"]
"""
assert response_status == 200

Просмотреть файл

@ -176,5 +176,5 @@ No paramaters are required.
Response sample:
```json
["fpe", "hash", "mask", "redact", "replace"]
["hash", "mask", "redact", "replace"]
```

Просмотреть файл

@ -1,6 +1,5 @@
"""Initializing all the existing anonymizers."""
from .anonymizer import Anonymizer
from .fpe import FPE
from .hash import Hash
from .mask import Mask
from .redact import Redact
@ -8,7 +7,6 @@ from .replace import Replace
__all__ = [
"Anonymizer",
"FPE",
"Hash",
"Mask",
"Redact",

Просмотреть файл

@ -1,31 +0,0 @@
"""
Format Preserving encryption for PII text entities.
Uses FF1 algorithm for the encryption.
"""
from presidio_anonymizer.anonymizers import Anonymizer
# TODO implement + test
class FPE(Anonymizer):
"""
FPE - Format Preserving Encryption.
PII text will be replaced with a format preserving encryption using FF1 algorithm.
"""
def anonymize(self, text: str = None, params: dict = None) -> str:
"""Return anonymized text using FF1 algorithm."""
old_text = params.get("old_text")
decrypt = params.get("decrypt")
tweak = params.get("tweak")
key = params.get("key")
return old_text + decrypt + tweak + key
def validate(self, params: dict = None) -> None:
"""TODO: [ADO-2547] docstring."""
pass
def anonymizer_name(self) -> str:
"""Return anonymizer name."""
return "fpe"

Просмотреть файл

@ -3,6 +3,6 @@ from presidio_anonymizer.anonymizers import Anonymizer
def test_given_anonymizers_list_then_all_classes_are_there():
anonymizers = Anonymizer.get_anonymizers()
assert len(anonymizers) >= 5
for class_name in ["hash", "mask", "redact", "replace", "fpe"]:
assert len(anonymizers) >= 4
for class_name in ["hash", "mask", "redact", "replace"]:
assert anonymizers.get(class_name)

Просмотреть файл

@ -7,7 +7,7 @@ from presidio_anonymizer.entities import AnonymizerConfig, InvalidParamException
# fmt: off
"class_name",
[
"fpe", "hash", "mask", "redact", "replace"
"hash", "mask", "redact", "replace"
],
# fmt: on
)

Просмотреть файл

@ -9,7 +9,7 @@ from presidio_anonymizer.entities import AnonymizerConfig, InvalidParamException
def test_given_request_anonymizers_return_list():
engine = AnonymizerEngine()
expected_list = ["fpe", "hash", "mask", "redact", "replace"]
expected_list = ["hash", "mask", "redact", "replace"]
anon_list = engine.get_anonymizers()
assert anon_list == expected_list