From b55e935feb3ff865b059a36f52dcc28a6e2fd238 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 21 Sep 2021 10:59:49 +0200 Subject: [PATCH 38/59] misc: fix pointless-string-statement pylint error (#56982) --- src/authentic2/idp/saml/saml2_endpoints.py | 19 ++++++------------- src/authentic2/idp/signals.py | 14 ++++++-------- tests/conftest.py | 1 + 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/authentic2/idp/saml/saml2_endpoints.py b/src/authentic2/idp/saml/saml2_endpoints.py index 651439b1..f80ec781 100644 --- a/src/authentic2/idp/saml/saml2_endpoints.py +++ b/src/authentic2/idp/saml/saml2_endpoints.py @@ -838,6 +838,7 @@ def sso_after_process_request( if not saml_policy: return error_page(request, _('No service provider policy defined'), logger=logger) + # pylint: disable=pointless-string-statement '''User consent for federation management 1- Check if the policy enforce the consent @@ -900,8 +901,7 @@ def sso_after_process_request( ) logger.debug('consent already given (existing federation) for %s', login.remoteProviderId) consent_obtained = True - '''This is abusive since a federation may exist even if we have - not previously asked the user consent.''' + # This is abusive since a federation may exist even if we have not previously asked the user consent. consent_value = 'urn:oasis:names:tc:SAML:2.0:consent:prior' except ObjectDoesNotExist: logger.debug('consent not yet given (no existing federation) for %s', login.remoteProviderId) @@ -1296,7 +1296,7 @@ def slo_soap(request): logger.warning('received slo from %s not authorized', logout.remoteProviderId) return return_logout_error(request, logout, AUTHENTIC_STATUS_CODE_UNAUTHORIZED) - '''Find all active sessions on SPs but the SP initiating the SLO''' + # Find all active sessions on SPs but the SP initiating the SLO found, lib_sessions, django_session_keys = get_only_last_session( logout.server.providerId, logout.remoteProviderId, @@ -1324,10 +1324,7 @@ def slo_soap(request): try: logout.validateRequest() except lasso.LogoutUnsupportedProfileError: - """ - If one provider does not support SLO by SOAP, - continue with others! - """ + # If one provider does not support SLO by SOAP, continue with others! logger.warning( 'one provider does not support SOAP among %s', [s.provider_id for s in lib_sessions] ) @@ -1341,9 +1338,7 @@ def slo_soap(request): for lib_session in lib_sessions: try: logger.debug('slo, relaying logout to provider %s', lib_session.provider_id) - ''' - As we are in a synchronous binding, we need SOAP support - ''' + # As we are in a synchronous binding, we need SOAP support logout.initRequest(lib_session.provider_id, lasso.HTTP_METHOD_SOAP) logout.buildRequestMsg() if logout.msgBody: @@ -1355,9 +1350,7 @@ def slo_soap(request): except lasso.Error as e: logger.warning('slo, relaying to %s failed: %s', lib_session.provider_id, e) - ''' - Respond to the SP initiating SLO - ''' + # Respond to the SP initiating SLO try: logout.buildResponseMsg() except lasso.Error as e: diff --git a/src/authentic2/idp/signals.py b/src/authentic2/idp/signals.py index c20c99ea..78911c6f 100644 --- a/src/authentic2/idp/signals.py +++ b/src/authentic2/idp/signals.py @@ -16,14 +16,12 @@ from django.dispatch import Signal -'''authorize_decision -Expect a dictionnaries as return with: - - the authorization decision e.g. dic['authz'] = True or False - - optionnaly a message e.g. dic['message'] = message -''' +# authorize_decision +# Expect a dictionnaries as return with: +# - the authorization decision e.g. dic['authz'] = True or False +# - optionnaly a message e.g. dic['message'] = message authorize_service = Signal(providing_args=["request", "user", "audience", "attributes"]) -'''avoid_consent -Expect a boolean e.g. dic['avoid_consent'] = True or False -''' +# avoid_consent +# Expect a boolean e.g. dic['avoid_consent'] = True or False avoid_consent = Signal(providing_args=["request", "user", "audience"]) diff --git a/tests/conftest.py b/tests/conftest.py index 8f39fe83..c35fe3cc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -481,6 +481,7 @@ def migration(request, transactional_db): # see https://gist.github.com/asfaltboy/b3e6f9b5d95af8ba2cc46f2ba6eae5e2 if django.VERSION < (1, 9): pytest.skip('migration fixture only works with Django 1.9') + # pylint: disable=pointless-string-statement """ This fixture returns a helper object to test Django data migrations. The fixture returns an object with two methods; -- 2.30.2