fix: sonarqube findings, deprecations, ownership enforcement, test fi…#10
Merged
Maneesh-Relanto merged 1 commit intomainfrom Feb 23, 2026
Merged
Conversation
…eld names SonarQube / code quality fixes: - src/rbac/storage/sqlalchemy_adapter.py: extract _FK_ROLES_ID constant for duplicate 'rbac_roles.id' literal; rename _Session -> _session_factory to resolve naming clash with _session() method - src/rbac/core/models/__init__.py: replace datetime.utcnow with _utcnow() helper returning timezone-aware datetime.now(timezone.utc) - test-apps/02-flask-blog-api/app.py: refactor into Flask Blueprints to reduce cognitive complexity (67 -> minimal); fix utcnow; add perm_comment_delete to reader role - test-apps/02-flask-blog-api/decorators.py: extract _fetch_owned_resource, _build_permission_context, _forbidden_response helpers; add ownership enforcement via OWNERSHIP_OVERRIDE_ROLES; add MSG_* constants - test-apps/02-flask-blog-api/models.py: fix utcnow deprecation - test-apps/02-flask-blog-api/storage.py: fix utcnow deprecation (5 places) - test-apps/02-flask-blog-api/test_api.py: fix test_update_others_post_as_author to target correct post (/posts/4 not /posts/1) - test-apps/03-fastapi-blog-api/dependencies.py: extract _resolve_resource, _build_context, _raise_forbidden; add OWNERSHIP_OVERRIDE_ROLES enforcement - test-apps/03-fastapi-blog-api/seed_data.py: extract title constants; add NOSONAR on demo passwords; remove unnecessary f-string - test-apps/03-fastapi-blog-api/test_api.py: remove unused variable; add NOSONAR on hardcoded test credentials Pre-existing test model field-name mismatches fixed: - tests/conftest.py: username -> name, metadata -> attributes, fix Permission fields (resource -> resource_type, drop domain) - tests/test_models.py: same field-name fixes + assertion updates - tests/test_storage.py: username -> name - tests/integration/test_complete_workflows.py: username -> name, metadata -> attributes, Permission resource=obj -> resource_type=obj.type - tests/property/test_authorization_invariants.py: username -> name, Permission resource=obj -> resource_type=obj.type Test results after fixes: - test-apps/02-flask-blog-api: 34/34 passing - test-apps/03-fastapi-blog-api: 39/39 passing - tests/test_sqlalchemy_storage.py: 50/50 passing
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
…eld names
SonarQube / code quality fixes:
Pre-existing test model field-name mismatches fixed:
Test results after fixes: