refactor(system/views): remove dead deprecation-check code
HEAD mainThe /auth/system/roles endpoint has no active blueprint registration —
the system Blueprint is only reachable via /auth/resource/system/roles.
The `if "/resource/" not in request.path` branch could never fire, so
remove it along with _SUCCESSOR, and the warnings import.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
1 files changed, 8 insertions, 15 deletions
diff --git a/gn_auth/auth/authorisation/resources/system/views.py b/gn_auth/auth/authorisation/resources/system/views.py
index 23ea6e9..54aa086 100644
--- a/gn_auth/auth/authorisation/resources/system/views.py
+++ b/gn_auth/auth/authorisation/resources/system/views.py
@@ -1,8 +1,12 @@
"""Views relating to `System` resource(s)."""
import logging
-import warnings
from dataclasses import asdict
-from flask import request, jsonify, Blueprint, make_response, current_app as app
+from flask import (request,
+ jsonify,
+ Response,
+ Blueprint,
+ make_response,
+ current_app as app)
from gn_libs import sqlite3 as authdb
@@ -14,11 +18,9 @@ from .models import user_roles_on_system
logger = logging.getLogger(__name__)
system = Blueprint("system", __name__)
-_SUCCESSOR = "/auth/resource/system/roles"
-
@system.route("/roles")
-def system_roles():
+def system_roles() -> Response:
"""Get the roles that a user has that act on the system."""
with (authdb.connection(app.config["AUTH_DB"]) as conn,
authdb.cursor(conn) as cursor):
@@ -36,13 +38,4 @@ def system_roles():
asdict(role) for role in
user_roles_on_system(conn, the_token.user))
- resp = make_response(jsonify(roles_data))
- if "/resource/" not in request.path:
- resp.headers["Deprecation"] = "true"
- resp.headers["Link"] = f'<{_SUCCESSOR}>; rel="successor-version"'
- warnings.warn(
- ("The endpoint `/auth/system/roles` is deprecated -- please use "
- "`/auth/resource/system/roles` instead."),
- category=DeprecationWarning,
- stacklevel=2)
- return resp
+ return make_response(jsonify(roles_data), 200)
|