Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HJ-87 and HJ-88: model changes #5600

Merged
merged 51 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
bc0a5a5
migration and model methods only
thingscouldbeworse Dec 12, 2024
8099de7
black tests
thingscouldbeworse Dec 12, 2024
0a60fcf
data_use added to taxonomy
thingscouldbeworse Dec 12, 2024
204d957
more taxonomy
thingscouldbeworse Dec 12, 2024
3e78a4f
remove unneeded .fides files
thingscouldbeworse Dec 13, 2024
899a20a
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 13, 2024
703ace0
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 13, 2024
833874e
patch on system hidden and test
thingscouldbeworse Dec 16, 2024
0832e24
remove hidden column from stagedresource
thingscouldbeworse Dec 16, 2024
c1eafb8
stagedresource no hidden column, use diff_status == 'muted'
thingscouldbeworse Dec 17, 2024
084c2a1
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 17, 2024
c5e24e1
merge main
thingscouldbeworse Dec 18, 2024
e200e7b
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 18, 2024
df8e884
change downrev on migration after main merge
thingscouldbeworse Dec 18, 2024
e167770
add a ConnectionConfigResponse that contains the monitor configs
thingscouldbeworse Dec 18, 2024
5da33c8
optional
thingscouldbeworse Dec 18, 2024
7181a02
Revert "add a ConnectionConfigResponse that contains the monitor conf…
thingscouldbeworse Dec 18, 2024
61f38a4
PR feedback and reset system endpoint to exactly what it was before
thingscouldbeworse Dec 19, 2024
88314a8
pylint
thingscouldbeworse Dec 19, 2024
1962341
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 19, 2024
b152e93
downrev
thingscouldbeworse Dec 19, 2024
5f88545
fix tests
thingscouldbeworse Dec 19, 2024
3d636cb
erge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 19, 2024
36b9915
yet another downrev
thingscouldbeworse Dec 19, 2024
aa4689c
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 19, 2024
63564b7
downrev
thingscouldbeworse Dec 19, 2024
b6dbdd6
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 20, 2024
ef91b70
move test
thingscouldbeworse Dec 20, 2024
6e52636
try not doing a DB call and make test run first
thingscouldbeworse Dec 20, 2024
4437235
sync endpoint
thingscouldbeworse Dec 20, 2024
820c58d
static checks
thingscouldbeworse Dec 20, 2024
b00e706
rename back test file
thingscouldbeworse Dec 20, 2024
0932586
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Dec 20, 2024
ff7fd8c
add back in tests
thingscouldbeworse Dec 20, 2024
408beb5
reset
thingscouldbeworse Dec 20, 2024
5e0afc1
add logic back
thingscouldbeworse Dec 20, 2024
639cee9
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Jan 17, 2025
a3c6541
add test coverage
thingscouldbeworse Jan 17, 2025
2ccf462
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Jan 17, 2025
0090733
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Jan 20, 2025
9de0b65
try skipping the test
thingscouldbeworse Jan 20, 2025
f53d280
argh
thingscouldbeworse Jan 20, 2025
6efc31b
unskip
thingscouldbeworse Jan 20, 2025
1743104
move line to proper part of changelog
thingscouldbeworse Jan 20, 2025
65c81eb
merge main
thingscouldbeworse Jan 20, 2025
cbf8f50
Adding hard timeout
galvana Jan 20, 2025
42b76e9
Adding full trace
galvana Jan 20, 2025
9719d7d
skip time out test
thingscouldbeworse Jan 22, 2025
7bde4a7
Merge branch 'main' into HJ-88-87_model-changes
thingscouldbeworse Jan 22, 2025
e64eeab
increase timeout
thingscouldbeworse Jan 22, 2025
8ef1582
6min timeout
thingscouldbeworse Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
thingscouldbeworse committed Dec 19, 2024
commit 5f885453d723bf5c7e56abffbf3a470dd815aa42
9 changes: 8 additions & 1 deletion src/fides/api/models/detection_discovery.py
Original file line number Diff line number Diff line change
@@ -364,6 +364,13 @@ def fetch_staged_resources_by_type_query(
if monitor_config_ids:
query = query.filter(StagedResource.monitor_config_id.in_(monitor_config_ids))
if not show_hidden:
query = query.filter(StagedResource.diff_status != DiffStatus.MUTED.value)
from sqlalchemy import or_

query = query.filter(
or_(
StagedResource.diff_status != DiffStatus.MUTED.value,
StagedResource.diff_status.is_(None),
)
)

return query
11 changes: 7 additions & 4 deletions tests/ops/api/v1/endpoints/test_system.py
Original file line number Diff line number Diff line change
@@ -279,9 +279,12 @@ def test_system_patch_hidden(
system,
api_client: TestClient,
generate_auth_header,
db: Session,
):
url = V1_URL_PREFIX + f"/system/hidden"
auth_header = generate_auth_header(scopes=[SYSTEM_UPDATE])
auth_header = generate_auth_header(
scopes=[SYSTEM_UPDATE, SYSTEM_MANAGER_UPDATE]
)

result = api_client.patch(
url=f"{url}?hidden=true",
@@ -294,9 +297,9 @@ def test_system_patch_hidden(
"updated": 1,
}

# fetch the system row from db
system = System.filter(system.id)
assert system.hidden is True
query = "SELECT hidden FROM ctl_systems WHERE fides_key = :fides_key"
result = db.execute(query, {"fides_key": system.fides_key}).fetchone()
assert result[0] is True


class TestGetConnections:
111 changes: 111 additions & 0 deletions tests/ops/models/test_detection_discovery.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
MonitorConfig,
MonitorFrequency,
StagedResource,
fetch_staged_resources_by_type_query,
)


@@ -63,6 +64,84 @@ def create_staged_resource(self, db: Session):
)
return resource

@pytest.fixture
def create_staged_database(self, db: Session):
urn = "bq_monitor_1.prj-bigquery-418515.test_dataset_1"
resource = StagedResource.create(
db=db,
data={
"urn": urn,
"user_assigned_data_categories": ["user.contact.email"],
"name": "test_dataset_1",
"resource_type": "Database",
"description": "test description",
"monitor_config_id": "bq_monitor_1",
"source_modified": "2024-03-27T21:47:09.915000+00:00",
"classifications": [
{
"label": "user.authorization.credentials",
"score": 0.4247,
"aggregated_score": 0.2336,
"classification_paradigm": "context",
},
{
"label": "system",
"score": 0.4,
"aggregated_score": 0.18,
"classification_paradigm": "content",
},
],
"diff_status": DiffStatus.MONITORED.value,
"child_diff_statuses": {DiffStatus.CLASSIFICATION_ADDITION.value: 9},
"children": [
"bq_monitor_1.prj-bigquery-418515.test_dataset_1.consent-reports-20",
"bq_monitor_1.prj-bigquery-418515.test_dataset_1.consent-reports-21",
],
"parent": "bq_monitor_1.prj-bigquery-418515",
"meta": {"num_rows": 19},
},
)
return resource

@pytest.fixture
def create_staged_schema(self, db: Session):
urn = "bq_monitor_1.prj-bigquery-418515"
resource = StagedResource.create(
db=db,
data={
"urn": urn,
"user_assigned_data_categories": ["user.contact.email"],
"name": "prj-bigquery-418515",
"resource_type": "Schema",
"description": "test description",
"monitor_config_id": "bq_monitor_1",
"source_modified": "2024-03-27T21:47:09.915000+00:00",
"classifications": [
{
"label": "user.authorization.credentials",
"score": 0.4247,
"aggregated_score": 0.2336,
"classification_paradigm": "context",
},
{
"label": "system",
"score": 0.4,
"aggregated_score": 0.18,
"classification_paradigm": "content",
},
],
"diff_status": DiffStatus.MONITORED.value,
"child_diff_statuses": {DiffStatus.CLASSIFICATION_ADDITION.value: 9},
"children": [
"bq_monitor_1.prj-bigquery-418515.test_dataset_1",
"bq_monitor_1.prj-bigquery-418515.test_dataset_2",
],
"parent": "bq_monitor_1",
"meta": {"num_rows": 19},
},
)
return resource

def test_get_urn(self, db: Session, create_staged_resource) -> None:
urn_list = [create_staged_resource.urn]
from_db = StagedResource.get_urn_list(db, urn_list)
@@ -185,6 +264,38 @@ def test_staged_resource_helpers(self, db: Session, create_staged_resource):
DiffStatus.CLASSIFICATION_ADDITION.value: 10,
}

def test_fetch_staged_resources_by_type_query(
self,
db: Session,
create_staged_resource,
create_staged_database,
create_staged_schema,
) -> None:
"""
Tests that the fetch_staged_resources_by_type_query works as expected
"""
query = fetch_staged_resources_by_type_query("Table")
resources = db.execute(query).all()
assert len(resources) == 1
assert resources[0][0].resource_type == "Table"
assert resources[0][0].urn == create_staged_resource.urn

query = fetch_staged_resources_by_type_query("Schema")
resources = db.execute(query).all()
assert len(resources) == 1

query = fetch_staged_resources_by_type_query("Database")
resources = db.execute(query).all()
assert len(resources) == 1
assert resources[0][0].urn == create_staged_database.urn

database = StagedResource.get_urn(db, create_staged_database.urn)
database.diff_status = None
database.save(db)
query = fetch_staged_resources_by_type_query("Database")
resources = db.execute(query).all()
assert len(resources) == 1


SAMPLE_START_DATE = datetime(2024, 5, 20, 0, 42, 5, 17137, tzinfo=timezone.utc)