-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix step.invoke data is not encrypted (#187)
- Loading branch information
Showing
6 changed files
with
175 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
73 changes: 73 additions & 0 deletions
73
tests/test_experimental/test_encryption_middleware/test_fast_api.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import threading | ||
import unittest | ||
|
||
import fastapi | ||
import uvicorn | ||
|
||
import inngest | ||
import inngest.fast_api | ||
from inngest._internal import server_lib | ||
from inngest.experimental import dev_server | ||
from tests import base, net | ||
|
||
from . import cases | ||
|
||
_framework = server_lib.Framework.FAST_API | ||
_app_id = f"{_framework.value}-encryption-middleware" | ||
|
||
_client = inngest.Inngest( | ||
api_base_url=dev_server.server.origin, | ||
app_id=_app_id, | ||
event_api_base_url=dev_server.server.origin, | ||
is_production=False, | ||
) | ||
|
||
_cases = cases.create_async_cases(_client, _framework) | ||
_fns: list[inngest.Function] = [] | ||
for case in _cases: | ||
if isinstance(case.fn, list): | ||
_fns.extend(case.fn) | ||
else: | ||
_fns.append(case.fn) | ||
|
||
|
||
class TestEncryptionMiddleware(unittest.IsolatedAsyncioTestCase): | ||
client = _client | ||
app_thread: threading.Thread | ||
|
||
@classmethod | ||
def setUpClass(cls) -> None: | ||
super().setUpClass() | ||
|
||
port = net.get_available_port() | ||
|
||
def start_app() -> None: | ||
app = fastapi.FastAPI() | ||
inngest.fast_api.serve( | ||
app, | ||
_client, | ||
_fns, | ||
) | ||
uvicorn.run(app, host="0.0.0.0", port=port, log_level="warning") | ||
|
||
# Start FastAPI in a thread instead of using their test client, since | ||
# their test client doesn't seem to actually run requests in parallel | ||
# (this is evident in the flakiness of our asyncio race test). If we fix | ||
# this issue, we can go back to their test client | ||
cls.app_thread = threading.Thread(daemon=True, target=start_app) | ||
cls.app_thread.start() | ||
base.register(port) | ||
|
||
@classmethod | ||
def tearDownClass(cls) -> None: | ||
super().tearDownClass() | ||
cls.app_thread.join(timeout=1) | ||
|
||
|
||
for case in _cases: | ||
test_name = f"test_{case.name}" | ||
setattr(TestEncryptionMiddleware, test_name, case.run_test) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains 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