diff --git a/secureli/modules/pii_scanner/pii_scanner.py b/secureli/modules/pii_scanner/pii_scanner.py index b906017c..e488fe1b 100644 --- a/secureli/modules/pii_scanner/pii_scanner.py +++ b/secureli/modules/pii_scanner/pii_scanner.py @@ -40,7 +40,6 @@ def __init__( ): self.repo_files = repo_files - # TODO435: Need to update README / CONTRIBUTING with this info? ok def scan_repo( self, folder_path: Path, diff --git a/tests/modules/pii_scanner/test_pii_scanner_service.py b/tests/modules/pii_scanner/test_pii_scanner_service.py index 82e9e151..b4256b0a 100644 --- a/tests/modules/pii_scanner/test_pii_scanner_service.py +++ b/tests/modules/pii_scanner/test_pii_scanner_service.py @@ -1,21 +1,39 @@ import pytest +from pytest_mock import MockerFixture from unittest.mock import MagicMock +from pathlib import Path from secureli.modules.pii_scanner.pii_scanner import PiiScannerService +from secureli.modules.shared.models.scan import ScanMode + + +test_folder_path = Path(".") @pytest.fixture() def mock_repo_files_repository() -> MagicMock: mock_repo_files_repository = MagicMock() + mock_repo_files_repository.list_staged_files.return_value = [Path("fake_file_path")] + mock_repo_files_repository.list_repo_files.return_value = [Path("fake_file_path")] return mock_repo_files_repository +@pytest.fixture() +def mock_open_fn(mocker: MockerFixture) -> MagicMock: + mock_open = mocker.mock_open( + read_data="fake_email='pantsATpants.com'" # TODO: mock PII data here + ) + return mocker.patch("builtins.open", mock_open) + + @pytest.fixture() def pii_scanner_service(mock_repo_files_repository: MagicMock) -> PiiScannerService: return PiiScannerService(mock_repo_files_repository) -# dummy test below as placeholder -def test_that_pii_scanner_service_does_cool_things( +def test_that_pii_scanner_service_finds_potential_pii( pii_scanner_service: PiiScannerService, + mock_open_fn: MagicMock, ): - pass + scan_result = pii_scanner_service.scan_repo(test_folder_path, ScanMode.ALL_FILES) + + # assert not scan_result.successful # TODO: uncomment once dummy PII data available