fix: improve maintenance and synchronize live conversations
This commit is contained in:
1 parent
bb541bd212
commit
ef86a5d3af
297 files changed
+2983
-1274
No files matched your search
@@ -15,7 +15,7 @@ limitations under the License.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock, AsyncMock
|
||||
from unittest.mock import patch, MagicMock
|
||||
from app.core.auth_utils import (
|
||||
refresh_access_token,
|
||||
authenticate_socket,
|
||||
@@ -26,8 +26,7 @@ from app.models.user import User
|
||||
from app.models.widget import Widget
|
||||
from uuid import uuid4
|
||||
import http.cookies
|
||||
from datetime import datetime, timezone
|
||||
from app.core.security import verify_token, verify_conversation_token, create_access_token, create_refresh_token, create_conversation_token
|
||||
from app.core.security import verify_token, create_access_token, create_refresh_token
|
||||
from app.models.auth_session import AuthSession
|
||||
from app.services.auth_sessions import issue_tokens, revoke_session
|
||||
|
||||
@@ -297,13 +296,13 @@ async def test_authenticate_socket_conversation_token_missing_widget(mock_db):
|
||||
mock_db.query.return_value.filter.return_value.first.return_value = None
|
||||
|
||||
with patch('app.core.auth_utils.verify_conversation_token') as mock_verify, \
|
||||
patch('app.core.auth_utils.get_db') as mock_get_db:
|
||||
patch('app.core.auth_utils.SessionLocal') as mock_session_local:
|
||||
mock_verify.return_value = {
|
||||
"widget_id": widget_id,
|
||||
"sub": customer_id,
|
||||
"type": "conversation"
|
||||
}
|
||||
mock_get_db.return_value.__next__.return_value = mock_db
|
||||
mock_session_local.return_value.__enter__.return_value = mock_db
|
||||
|
||||
# Execute
|
||||
result = await authenticate_socket_conversation_token(sid, auth)
|
||||
@@ -325,13 +324,13 @@ async def test_authenticate_socket_conversation_token_wrong_type(mock_db, mock_w
|
||||
mock_db.query.return_value.filter.return_value.first.return_value = mock_widget
|
||||
|
||||
with patch('app.core.auth_utils.verify_conversation_token') as mock_verify, \
|
||||
patch('app.core.auth_utils.get_db') as mock_get_db:
|
||||
patch('app.core.auth_utils.SessionLocal') as mock_session_local:
|
||||
mock_verify.return_value = {
|
||||
"widget_id": str(mock_widget.id),
|
||||
"sub": customer_id,
|
||||
"type": "access" # Wrong token type
|
||||
}
|
||||
mock_get_db.return_value.__next__.return_value = mock_db
|
||||
mock_session_local.return_value.__enter__.return_value = mock_db
|
||||
|
||||
# Execute
|
||||
result = await authenticate_socket_conversation_token(sid, auth)
|
||||
|
||||
Reference in new issue
Block a user