-
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.
Provide test coverage for fides connector
Clean up for mypy and linting
- Loading branch information
Showing
21 changed files
with
906 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
dataset: | ||
- fides_key: fides_example_child_test_dataset | ||
name: Fides Child Example Test Dataset | ||
description: Example of a Remote Fides Child Dataset | ||
collections: | ||
- name: privacy_request | ||
fields: | ||
- name: placeholder | ||
data_categories: [system.operations] | ||
fidesops_meta: | ||
identity: email | ||
- name: id # this is intented to store the resulting privacy request ID | ||
data_categories: [user.contact.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
services: | ||
fides-child: | ||
image: ethyca/fides:local | ||
command: uvicorn --host 0.0.0.0 --port 8080 --reload --reload-dir src fides.api.main:app | ||
healthcheck: | ||
test: [ "CMD", "curl", "-f", "http://0.0.0.0:8080/health" ] | ||
interval: 20s | ||
timeout: 5s | ||
retries: 10 | ||
ports: | ||
- "8081:8080" | ||
depends_on: | ||
fides-child-db: | ||
condition: service_healthy | ||
redis-child: | ||
condition: service_started | ||
expose: | ||
- 8080 | ||
env_file: | ||
- .env | ||
environment: | ||
FIDES__CONFIG_PATH: ${FIDES__CONFIG_PATH:-/fides/.fides/fides.toml} | ||
FIDES__CLI__ANALYTICS_ID: ${FIDES__CLI__ANALYTICS_ID:-} | ||
FIDES__CLI__SERVER_HOST: "fides-child" | ||
FIDES__CLI__SERVER_PORT: "8080" | ||
FIDES__DATABASE__SERVER: "fides-child-db" | ||
FIDES__DEV_MODE: "True" | ||
FIDES__REDIS__ENABLED: "True" | ||
FIDES__REDIS__HOST: "redis-child" | ||
FIDES__TEST_MODE: "True" | ||
FIDES__USER__ANALYTICS_OPT_OUT: "True" | ||
VAULT_ADDR: ${VAULT_ADDR:-} | ||
VAULT_NAMESPACE: ${VAULT_NAMESPACE:-} | ||
VAULT_TOKEN: ${VAULT_TOKEN:-} | ||
FIDES__SECURITY__PARENT_SERVER_USERNAME: parent | ||
FIDES__SECURITY__PARENT_SERVER_PASSWORD: parentpassword1! | ||
volumes: | ||
- type: bind | ||
source: . | ||
target: /fides | ||
read_only: False | ||
|
||
fides-child-ui: | ||
image: ethyca/fides:local-ui | ||
command: npm run dev | ||
expose: | ||
- 3000 | ||
ports: | ||
- "3002:3000" | ||
volumes: | ||
- type: bind | ||
source: . | ||
target: /fides | ||
read_only: False | ||
# do not volume mount over the node_modules | ||
- /fides/clients/admin-ui/node_modules | ||
environment: | ||
- NEXT_PUBLIC_FIDESCTL_API_SERVER=http://fides-child:8080 | ||
- NEXT_PUBLIC_FIDESOPS_API=http://fides-child:8080 | ||
|
||
fides-child-db: | ||
image: postgres:12 | ||
healthcheck: | ||
test: [ "CMD-SHELL", "pg_isready -U postgres" ] | ||
interval: 15s | ||
timeout: 5s | ||
retries: 5 | ||
volumes: | ||
# TODO - can we update this to not share the volume mount with primary Fides? | ||
- postgres:/var/lib/postgresql/data | ||
expose: | ||
- 5432 | ||
ports: | ||
- "5433:5432" | ||
environment: | ||
POSTGRES_USER: "postgres" | ||
POSTGRES_PASSWORD: "fides" | ||
POSTGRES_DB: "fides" | ||
deploy: | ||
placement: | ||
constraints: | ||
- node.labels.fides.app-db-data == true | ||
|
||
redis-child: | ||
image: "redis:6.2.5-alpine" | ||
command: redis-server --requirepass testpassword | ||
environment: | ||
- REDIS_PASSWORD=testpassword | ||
expose: | ||
- 6379 | ||
ports: | ||
- "0.0.0.0:6380:6379" | ||
|
||
volumes: | ||
postgres: null | ||
|
||
networks: | ||
fides_network: |
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,37 @@ | ||
""" | ||
This script is used to seed the application database with example | ||
Fides connector configurations to integration test Fides parent-child interactions. | ||
This script is only designed to be run along with the `child` Nox flag. | ||
""" | ||
|
||
from setup import constants | ||
from setup.authentication import get_auth_header | ||
from setup.fides_connector import create_fides_connector | ||
from setup.healthcheck import check_health | ||
from setup.user import create_user | ||
|
||
print("Generating example data for local Fides - child test environment...") | ||
|
||
try: | ||
check_health() | ||
except RuntimeError: | ||
print( | ||
f"Connection error. Please ensure Fides is healthy and running at {constants.FIDES_URL}." | ||
) | ||
raise | ||
|
||
# Start by creating an OAuth client and user for testing | ||
auth_header = get_auth_header() | ||
create_user( | ||
auth_header=auth_header, | ||
) | ||
|
||
|
||
# Configure a connector to the example Postgres database | ||
create_fides_connector( | ||
auth_header=auth_header, | ||
) | ||
|
||
|
||
print("Examples loaded successfully!") |
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,38 @@ | ||
import logging | ||
from typing import Dict | ||
|
||
from setup.database_connector import ( | ||
create_database_connector, | ||
update_database_connector_secrets, | ||
) | ||
from setup.dataset import create_dataset | ||
|
||
logger = logging.getLogger(__name__) | ||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
def create_fides_connector( | ||
auth_header: Dict[str, str], | ||
key: str = "fides_connector", | ||
verify: bool = True, | ||
): | ||
create_database_connector( | ||
auth_header=auth_header, | ||
key=key, | ||
connection_type="fides", | ||
) | ||
update_database_connector_secrets( | ||
auth_header=auth_header, | ||
key=key, | ||
secrets={ | ||
"uri": "http://fides-child:8080", | ||
"username": "parent", | ||
"password": "parentpassword1!", | ||
}, | ||
verify=verify, | ||
) | ||
create_dataset( | ||
auth_header=auth_header, | ||
connection_key=key, | ||
yaml_path="data/dataset/remote_fides_example_test_dataset.yml", | ||
) |
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
Empty file.
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.