Fix: correct regex for file-preview URL re-signing (#25620)
Fixes #25619 The regex patterns for file-preview and image-preview contained an unescaped `?`, which caused incorrect matches such as `file-previe` or `image-previw`. This led to malformed URLs being incorrectly re-signed. Changes: - Escape `?` in both file-preview and image-preview regex patterns. - Ensure only valid URLs are re-signed. Added unit tests to cover: - Valid file-preview and image-preview URLs (correctly re-signed). - Misspelled file/image preview URLs (no longer incorrectly matched). Other: - Fix a deprecated function `datetime.utcnow()` Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
This commit is contained in:
parent
68076f2e22
commit
5bc6e8a433
4 changed files with 92 additions and 9 deletions
|
|
@ -1,6 +1,5 @@
|
|||
"""Unit tests for workflow node execution conflict handling."""
|
||||
|
||||
from datetime import datetime
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
import psycopg2.errors
|
||||
|
|
@ -16,6 +15,7 @@ from core.workflow.entities.workflow_node_execution import (
|
|||
WorkflowNodeExecutionStatus,
|
||||
)
|
||||
from core.workflow.enums import NodeType
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
from models import Account, WorkflowNodeExecutionTriggeredFrom
|
||||
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ class TestWorkflowNodeExecutionConflictHandling:
|
|||
title="Test Node",
|
||||
index=1,
|
||||
status=WorkflowNodeExecutionStatus.RUNNING,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=naive_utc_now(),
|
||||
)
|
||||
|
||||
original_id = execution.id
|
||||
|
|
@ -112,7 +112,7 @@ class TestWorkflowNodeExecutionConflictHandling:
|
|||
title="Test Node",
|
||||
index=1,
|
||||
status=WorkflowNodeExecutionStatus.SUCCEEDED,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=naive_utc_now(),
|
||||
)
|
||||
|
||||
# Save should update existing record
|
||||
|
|
@ -157,7 +157,7 @@ class TestWorkflowNodeExecutionConflictHandling:
|
|||
title="Test Node",
|
||||
index=1,
|
||||
status=WorkflowNodeExecutionStatus.RUNNING,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=naive_utc_now(),
|
||||
)
|
||||
|
||||
# Save should raise IntegrityError after max retries
|
||||
|
|
@ -199,7 +199,7 @@ class TestWorkflowNodeExecutionConflictHandling:
|
|||
title="Test Node",
|
||||
index=1,
|
||||
status=WorkflowNodeExecutionStatus.RUNNING,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=naive_utc_now(),
|
||||
)
|
||||
|
||||
# Save should raise error immediately
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue