test_workflow_repository.py 833 B

123456789101112131415161718
  1. def test_workflow_hash_is_canonical_and_credentials_are_redacted():
  2. from app.core.data_flow.workflow_repository import safe_workflow_snapshot, workflow_hash
  3. first = {"nodes": [{"id": "1", "credentials": {"postgres": {"id": "secret"}}}], "name": "flow", "updatedAt": "today"}
  4. second = {"name": "flow", "nodes": [{"credentials": {"postgres": {"id": "changed"}}, "id": "1"}], "updatedAt": "tomorrow"}
  5. assert workflow_hash(first) == workflow_hash(second)
  6. snapshot = safe_workflow_snapshot(first)
  7. assert snapshot["nodes"][0]["credentials"] == "[redacted]"
  8. assert "updatedAt" not in snapshot
  9. def test_numeric_dataflow_ids_are_rejected():
  10. import pytest
  11. from app.core.data_flow.workflow_repository import validate_dataflow_uid
  12. with pytest.raises(ValueError):
  13. validate_dataflow_uid("123")