Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Adds AuditLog and ExecutionLogs to seed_test_data command (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Preston authored Aug 17, 2022
1 parent f7011e1 commit cef5901
Showing 1 changed file with 64 additions and 1 deletion.
65 changes: 64 additions & 1 deletion scripts/create_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from uuid import uuid4

from fideslib.db.session import get_db_session
from fideslib.models.audit_log import AuditLog, AuditLogAction
from fideslib.models.client import ClientDetail
from fideslib.models.fides_user import FidesUser
from sqlalchemy import orm
Expand All @@ -17,7 +18,12 @@
ConnectionType,
)
from fidesops.ops.models.policy import ActionType, Policy, Rule, RuleTarget
from fidesops.ops.models.privacy_request import PrivacyRequest, PrivacyRequestStatus
from fidesops.ops.models.privacy_request import (
ExecutionLog,
ExecutionLogStatus,
PrivacyRequest,
PrivacyRequestStatus,
)
from fidesops.ops.models.storage import ResponseFormat, StorageConfig
from fidesops.ops.schemas.redis_cache import PrivacyRequestIdentity
from fidesops.ops.schemas.storage.storage import FileNaming, StorageDetails, StorageType
Expand Down Expand Up @@ -194,6 +200,63 @@ def create_test_data(db: orm.Session) -> FidesUser:
phone_number="+1 234 567 8910",
),
)
for action_type in [
AuditLogAction.denied, # Run denied before approved to simulate a realistic order
AuditLogAction.approved,
AuditLogAction.finished,
]:
AuditLog.create(
db=session,
data={
"user_id": "system",
"privacy_request_id": pr.id,
"action": action_type,
"message": f"Audit log for request with id {pr.id} and action_type {action_type}",
},
)

for action_type in [
ActionType.access.value,
ActionType.erasure.value,
]:
for exl_status in [
ExecutionLogStatus.in_processing,
ExecutionLogStatus.pending,
ExecutionLogStatus.complete,
ExecutionLogStatus.error,
ExecutionLogStatus.paused,
ExecutionLogStatus.retrying,
ExecutionLogStatus.skipped,
]:
ExecutionLog.create(
db=db,
data={
"dataset_name": "dummy_dataset",
"collection_name": "dummy_collection",
"fields_affected": [
{
"path": "dummy_dataset:dummy_collection:dummy_field_1",
"field_name": "dummy_field",
"data_categories": [
"data_category_1",
"data_category_2",
],
},
{
"path": "dummy_dataset:dummy_collection:dummy_field_2",
"field_name": "dummy_field_2",
"data_categories": [
"data_category_2",
"data_category_3",
],
},
],
"action_type": action_type,
"status": exl_status,
"privacy_request_id": pr.id,
"message": f"Execution log for request id {pr.id} status {status} and action_type {action_type}",
},
)

print("Adding connection configs")
_create_connection_configs(db)
Expand Down

0 comments on commit cef5901

Please sign in to comment.