-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SaaS connector test refactoring (#1795)
- Loading branch information
Showing
18 changed files
with
808 additions
and
1,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from typing import Any, Dict, Generator | ||
|
||
import pydash | ||
import pytest | ||
|
||
from tests.ops.integration_tests.saas.connector_runner import ( | ||
ConnectorRunner, | ||
generate_random_email, | ||
) | ||
from tests.ops.test_helpers.vault_client import get_secrets | ||
|
||
secrets = get_secrets("{{ connector_id }}") | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def {{ connector_id }}_secrets(saas_config) -> Dict[str, Any]: | ||
return { | ||
"domain": pydash.get(saas_config, "{{ connector_id }}.domain") | ||
or secrets["domain"] | ||
# add the rest of your secrets here | ||
} | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def {{ connector_id }}_identity_email(saas_config) -> str: | ||
return ( | ||
pydash.get(saas_config, "{{ connector_id }}.identity_email") or secrets["identity_email"] | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def {{ connector_id }}_erasure_identity_email() -> str: | ||
return generate_random_email() | ||
|
||
|
||
@pytest.fixture | ||
def {{ connector_id }}_external_references() -> Dict[str, Any]: | ||
return {} | ||
|
||
|
||
@pytest.fixture | ||
def {{ connector_id }}_erasure_external_references() -> Dict[str, Any]: | ||
return {} | ||
|
||
|
||
@pytest.fixture | ||
def {{ connector_id }}_erasure_data( | ||
{{ connector_id }}_erasure_identity_email: str, | ||
) -> Generator: | ||
# create the data needed for erasure tests here | ||
yield {} | ||
|
||
|
||
@pytest.fixture | ||
def {{ connector_id }}_runner( | ||
db, | ||
cache, | ||
{{ connector_id }}_secrets, | ||
{{ connector_id }}_external_references, | ||
{{ connector_id }}_erasure_external_references, | ||
) -> ConnectorRunner: | ||
return ConnectorRunner( | ||
db, | ||
cache, | ||
"{{ connector_id }}", | ||
{{ connector_id }}_secrets, | ||
external_references={{ connector_id }}_external_references, | ||
erasure_external_references={{ connector_id }}_erasure_external_references, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pytest | ||
|
||
from fides.api.ops.models.policy import Policy | ||
from tests.ops.integration_tests.saas.connector_runner import ConnectorRunner | ||
|
||
|
||
@pytest.mark.integration_saas | ||
class Test{{ connector_name }}Connector: | ||
def test_connection(self, {{ connector_id }}_runner: ConnectorRunner): | ||
{{ connector_id }}_runner.test_connection() | ||
|
||
async def test_access_request( | ||
self, {{ connector_id }}_runner: ConnectorRunner, policy, {{ connector_id }}_identity_email: str | ||
): | ||
access_results = await {{ connector_id }}_runner.access_request( | ||
access_policy=policy, identities={"email": {{ connector_id }}_identity_email} | ||
) | ||
|
||
async def test_strict_erasure_request( | ||
self, | ||
{{ connector_id }}_runner: ConnectorRunner, | ||
policy: Policy, | ||
erasure_policy_string_rewrite: Policy, | ||
{{ connector_id }}_erasure_identity_email: str, | ||
{{ connector_id }}_erasure_data, | ||
): | ||
( | ||
access_results, | ||
erasure_results, | ||
) = await {{ connector_id }}_runner.strict_erasure_request( | ||
access_policy=policy, | ||
erasure_policy=erasure_policy_string_rewrite, | ||
identities={"email": {{ connector_id }}_erasure_identity_email}, | ||
) | ||
|
||
async def test_non_strict_erasure_request( | ||
self, | ||
{{ connector_id }}_runner: ConnectorRunner, | ||
policy: Policy, | ||
erasure_policy_string_rewrite: Policy, | ||
{{ connector_id }}_erasure_identity_email: str, | ||
{{ connector_id }}_erasure_data, | ||
): | ||
( | ||
access_results, | ||
erasure_results, | ||
) = await {{ connector_id }}_runner.non_strict_erasure_request( | ||
access_policy=policy, | ||
erasure_policy=erasure_policy_string_rewrite, | ||
identities={"email": {{ connector_id }}_erasure_identity_email}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.