-
Notifications
You must be signed in to change notification settings - Fork 9
Fix authentication event loop corruption by converting get_current_user to async #40
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Redis Agent Memory Server - A memory system for conversational AI.""" | ||
|
||
__version__ = "0.9.2" | ||
__version__ = "0.9.3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -685,7 +685,7 @@ async def test_get_current_user_disabled_auth(self, mock_settings): | |
"""Test get_current_user when authentication is disabled""" | ||
mock_settings.disable_auth = True | ||
|
||
result = get_current_user(None) | ||
result = await get_current_user(None) | ||
|
||
assert isinstance(result, UserInfo) | ||
assert result.sub == "local-dev-user" | ||
|
@@ -700,7 +700,7 @@ async def test_get_current_user_missing_credentials(self, mock_settings): | |
mock_settings.auth_mode = "oauth2" | ||
|
||
with pytest.raises(HTTPException) as exc_info: | ||
get_current_user(None) | ||
await get_current_user(None) | ||
|
||
assert exc_info.value.status_code == status.HTTP_401_UNAUTHORIZED | ||
assert "Missing authorization header" in str(exc_info.value.detail) | ||
|
@@ -717,7 +717,7 @@ async def test_get_current_user_empty_credentials(self, mock_settings): | |
empty_creds = HTTPAuthorizationCredentials(scheme="Bearer", credentials="") | ||
|
||
with pytest.raises(HTTPException) as exc_info: | ||
get_current_user(empty_creds) | ||
await get_current_user(empty_creds) | ||
|
||
assert exc_info.value.status_code == status.HTTP_401_UNAUTHORIZED | ||
assert "Missing bearer token" in str(exc_info.value.detail) | ||
|
@@ -736,7 +736,7 @@ async def test_get_current_user_valid_token(self, mock_settings, valid_token): | |
expected_user = UserInfo(sub="test-user", email="[email protected]") | ||
mock_verify.return_value = expected_user | ||
|
||
result = get_current_user(creds) | ||
result = await get_current_user(creds) | ||
|
||
assert result == expected_user | ||
mock_verify.assert_called_once_with(valid_token) | ||
|
@@ -753,7 +753,7 @@ async def test_require_scope_success(self, mock_settings): | |
user = UserInfo(sub="test-user", scope="read write admin") | ||
scope_dependency = require_scope("read") | ||
|
||
result = scope_dependency(user) | ||
result = await scope_dependency(user) | ||
assert result == user | ||
|
||
@pytest.mark.asyncio | ||
|
@@ -765,7 +765,7 @@ async def test_require_scope_failure(self, mock_settings): | |
scope_dependency = require_scope("admin") | ||
|
||
with pytest.raises(HTTPException) as exc_info: | ||
scope_dependency(user) | ||
await scope_dependency(user) | ||
|
||
assert exc_info.value.status_code == status.HTTP_403_FORBIDDEN | ||
assert "Insufficient permissions" in str(exc_info.value.detail) | ||
|
@@ -780,7 +780,7 @@ async def test_require_scope_no_scope(self, mock_settings): | |
scope_dependency = require_scope("read") | ||
|
||
with pytest.raises(HTTPException) as exc_info: | ||
scope_dependency(user) | ||
await scope_dependency(user) | ||
|
||
assert exc_info.value.status_code == status.HTTP_403_FORBIDDEN | ||
|
||
|
@@ -792,7 +792,7 @@ async def test_require_scope_disabled_auth(self, mock_settings): | |
user = UserInfo(sub="test-user", scope=None) | ||
scope_dependency = require_scope("admin") | ||
|
||
result = scope_dependency(user) | ||
result = await scope_dependency(user) | ||
assert result == user | ||
|
||
@pytest.mark.asyncio | ||
|
@@ -803,7 +803,7 @@ async def test_require_role_success(self, mock_settings): | |
user = UserInfo(sub="test-user", roles=["user", "admin"]) | ||
role_dependency = require_role("admin") | ||
|
||
result = role_dependency(user) | ||
result = await role_dependency(user) | ||
assert result == user | ||
|
||
@pytest.mark.asyncio | ||
|
@@ -815,7 +815,7 @@ async def test_require_role_failure(self, mock_settings): | |
role_dependency = require_role("admin") | ||
|
||
with pytest.raises(HTTPException) as exc_info: | ||
role_dependency(user) | ||
await role_dependency(user) | ||
|
||
assert exc_info.value.status_code == status.HTTP_403_FORBIDDEN | ||
assert "Insufficient permissions" in str(exc_info.value.detail) | ||
|
@@ -830,7 +830,7 @@ async def test_require_role_no_roles(self, mock_settings): | |
role_dependency = require_role("admin") | ||
|
||
with pytest.raises(HTTPException) as exc_info: | ||
role_dependency(user) | ||
await role_dependency(user) | ||
|
||
assert exc_info.value.status_code == status.HTTP_403_FORBIDDEN | ||
|
||
|
@@ -842,7 +842,7 @@ async def test_require_role_disabled_auth(self, mock_settings): | |
user = UserInfo(sub="test-user", roles=None) | ||
role_dependency = require_role("admin") | ||
|
||
result = role_dependency(user) | ||
result = await role_dependency(user) | ||
assert result == user | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.