-
Notifications
You must be signed in to change notification settings - Fork 0
#194: improving auth user match checking #195
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
Changes from all commits
30cd075
f676d3b
ffb153b
cd2980b
502df7f
b34f3cd
bc324c0
405597c
50b7589
93519eb
5915141
1ef59b0
c4117b1
215137f
e1daf71
29d8b32
916fc3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,164 @@ | ||
| .ipynb_checkpoints | ||
| # =========================== | ||
| # OS files | ||
| # =========================== | ||
| .DS_Store | ||
| Thumbs.db | ||
| ehthumbs.db | ||
| Desktop.ini | ||
|
|
||
| # =========================== | ||
| # IDE and editors | ||
| # =========================== | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .spyderproject | ||
| .spyproject | ||
| .ropeproject | ||
|
|
||
| # =========================== | ||
| # Environment and secrets | ||
| # =========================== | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
|
|
||
| # =========================== | ||
| # Python – byte-compiled / optimized | ||
| # =========================== | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| cython_debug/ | ||
|
|
||
| # =========================== | ||
| # Python – packaging and distribution | ||
| # =========================== | ||
| .Python | ||
| build/ | ||
| dist/ | ||
| develop-eggs/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| share/python-wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
| MANIFEST | ||
|
|
||
| # =========================== | ||
| # Python – virtual environments | ||
| # =========================== | ||
| .venv | ||
| __pycache__ | ||
| /.idea/ | ||
| /dependencies | ||
| /lambda_function.zip | ||
| venv/ | ||
| env/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
| __pypackages__/ | ||
|
|
||
| # =========================== | ||
| # Python – tools and type checkers | ||
| # =========================== | ||
| .mypy_cache/ | ||
| .dmypy.json | ||
| dmypy.json | ||
| .pyre/ | ||
| .pytype/ | ||
| .pdm.toml | ||
| .pdm-python | ||
| .pdm-build/ | ||
| .ruff_cache/ | ||
|
|
||
| # =========================== | ||
| # Python – tests and coverage | ||
| # =========================== | ||
| .coverage | ||
| .coverage.* | ||
| htmlcov/ | ||
| .tox/ | ||
| .nox/ | ||
| .cache | ||
| .pytest_cache/ | ||
| .hypothesis/ | ||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| *.py,cover | ||
| cover/ | ||
|
|
||
| # =========================== | ||
| # Python – installer logs | ||
| # =========================== | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # =========================== | ||
| # Python – misc frameworks | ||
| # =========================== | ||
| *.log | ||
| local_settings.py | ||
| db.sqlite3 | ||
| db.sqlite3-journal | ||
| instance/ | ||
| .webassets-cache | ||
| .scrapy | ||
| celerybeat-schedule | ||
| celerybeat.pid | ||
| *.sage.py | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # =========================== | ||
| # Documentation | ||
| # =========================== | ||
| docs/_build/ | ||
| /site | ||
| .ipynb_checkpoints | ||
| profile_default/ | ||
| ipython_config.py | ||
|
|
||
| # =========================== | ||
| # Terraform and Terragrunt | ||
| # =========================== | ||
| .terraform/ | ||
| *.tfstate | ||
| *.tfstate.* | ||
| crash.log | ||
| crash.*.log | ||
| override.tf | ||
| override.tf.json | ||
| *_override.tf | ||
| *_override.tf.json | ||
| .terraformrc | ||
| terraform.rc | ||
| .terraform.lock.hcl | ||
| .terragrunt-cache/ | ||
|
|
||
| # =========================== | ||
| # Corporate CA certificates | ||
| # Actual cert files must never be committed -- provide via CI/CD secrets. | ||
| # The trusted_certs/ directory is kept (README only) to document the convention. | ||
| # =========================== | ||
| trusted_certs/*.pem | ||
| trusted_certs/*.crt | ||
|
|
||
| *.sarif | ||
| # =========================== | ||
| # Temporary files and logs | ||
| # =========================== | ||
| tmp/ | ||
| temp/ | ||
| *.tmp | ||
| logs/ |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -257,6 +257,24 @@ def test_post_success_all_writers(event_gate_module, make_event, valid_payload): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert 202 == body["statusCode"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_post_authorized_user_case_insensitive(event_gate_module, make_event, valid_payload): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with patch.object(event_gate_module.handler_token, "decode_jwt", return_value={"sub": "testuser"}): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for writer in event_gate_module.handler_topic.writers.values(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| writer.write = MagicMock(return_value=None) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| event = make_event( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "/topics/{topic_name}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method="POST", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| topic="public.cps.za.test", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body=valid_payload, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers={"Authorization": "Bearer token"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resp = event_gate_module.lambda_handler(event) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert 202 == resp["statusCode"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body = json.loads(resp["body"]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert body["success"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+260
to
+277
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Use As per coding guidelines, use the ♻️ Proposed refactor-def test_post_authorized_user_case_insensitive(event_gate_module, make_event, valid_payload):
- with patch.object(event_gate_module.handler_token, "decode_jwt", return_value={"sub": "testuser"}):
- for writer in event_gate_module.handler_topic.writers.values():
- writer.write = MagicMock(return_value=None)
-
- event = make_event(
- "/topics/{topic_name}",
- method="POST",
- topic="public.cps.za.test",
- body=valid_payload,
- headers={"Authorization": "Bearer token"},
- )
- resp = event_gate_module.lambda_handler(event)
- assert 202 == resp["statusCode"]
- body = json.loads(resp["body"])
- assert body["success"]
+def test_post_authorized_user_case_insensitive(event_gate_module, make_event, valid_payload, mocker):
+ mocker.patch.object(event_gate_module.handler_token, "decode_jwt", return_value={"sub": "testuser"})
+ for writer in event_gate_module.handler_topic.writers.values():
+ mocker.patch.object(writer, "write", return_value=None)
+
+ event = make_event(
+ "/topics/{topic_name}",
+ method="POST",
+ topic="public.cps.za.test",
+ body=valid_payload,
+ headers={"Authorization": "Bearer token"},
+ )
+ resp = event_gate_module.lambda_handler(event)
+ assert 202 == resp["statusCode"]
+ body = json.loads(resp["body"])
+ assert True == body["success"]📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_post_passes_topic_key_to_writers(event_gate_module, make_event, valid_payload): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Configured topic key field is extracted and passed to writer.write.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with patch.object(event_gate_module.handler_token, "decode_jwt", return_value={"sub": "TestUser"}): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.