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-338 added sorting for system.privacy_declarations and a test to verify #5683

Merged
merged 16 commits into from
Jan 23, 2025
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Changes can also be flagged with a GitHub label for tracking purposes. The URL o

### Changed
- Updated UI colors to new brand. Update logo, homepage cards. [#5668](https://github.com/ethyca/fides/pull/5668)
- The privacy declarations for a system are now sorted alphabetically by name. [#5683](https://github.com/ethyca/fides/pull/5683)

### Developer Experience
- Migrated radio buttons and groups to Ant Design [#5681](https://github.com/ethyca/fides/pull/5681)
Expand Down
1 change: 1 addition & 0 deletions src/fides/api/models/sql_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ class System(Base, FidesBase):
cascade="all, delete",
back_populates="system",
lazy="selectin",
order_by="PrivacyDeclaration.name",
)

data_stewards = relationship(
Expand Down
1 change: 1 addition & 0 deletions src/fides/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def get_auth_header(verbose: bool = True) -> Dict[str, str]:
Executes all of the logic required to form a valid auth header.
"""
credentials_path = get_credentials_path()
print(credentials_path)
JadeCara marked this conversation as resolved.
Show resolved Hide resolved
try:
credentials = read_credentials_file(credentials_path=credentials_path)
except FileNotFoundError:
Expand Down
34 changes: 34 additions & 0 deletions tests/ctl/models/test_sql_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from fides.api.db.system import get_system
from fides.api.models.sql_models import PrivacyDeclaration


def test_system_privacy_declarations_in_alphabetical_order(db, system):
"""
JadeCara marked this conversation as resolved.
Show resolved Hide resolved
Ensure that the system privacy declarations are in alphabetical order by name
"""
# Add more privacy declarations to the system
new_privacy_declarations = [
{
"data_use": "marketing.advertising.profiling",
"name": "Declaration Name",
"system_id": system.id,
},
{
"data_use": "essential",
"name": "Another Declaration Name",
"system_id": system.id,
},
]
for data in new_privacy_declarations:
PrivacyDeclaration.create(db=db, data=data)
db.commit()

db.refresh(system)
updated_system = get_system(db, system.fides_key)

privacy_declarations = updated_system.privacy_declarations
sorted_privacy_declarations = sorted(privacy_declarations, key=lambda x: x.name)

assert (
privacy_declarations == sorted_privacy_declarations
), "Privacy declarations are not in alphabetical order by name"
Loading