From ae212d4acf1e80d117bc9fb7692605a19721a41b Mon Sep 17 00:00:00 2001 From: Claude Sonnet 4.6 Date: Wed, 2 Sep 2026 19:21:29 +0000 Subject: refactor(system/views): remove dead deprecation-check code The /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 Reviewed-By: Frederick M. Muriithi --- .../auth/authorisation/resources/system/views.py | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'gn_auth') 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) -- cgit 1.4.1