diff --git a/canaille/app/configuration.py b/canaille/app/configuration.py index 640d36f3..d89d30a4 100644 --- a/canaille/app/configuration.py +++ b/canaille/app/configuration.py @@ -234,7 +234,7 @@ def validate_smtp_configuration(config): except smtplib.SMTPAuthenticationError as exc: raise ConfigurationException( - f'SMTP authentication failed with user \'{config["LOGIN"]}\'' + f"SMTP authentication failed with user '{config['LOGIN']}'" ) from exc except smtplib.SMTPNotSupportedError as exc: @@ -270,7 +270,7 @@ def validate_theme(config): if not os.path.exists(config["THEME"]) and not os.path.exists( os.path.join(ROOT, "themes", config["THEME"]) ): - raise ConfigurationException(f'Cannot find theme \'{config["THEME"]}\'') + raise ConfigurationException(f"Cannot find theme '{config['THEME']}'") def validate_admin_email(config): diff --git a/canaille/backends/ldap/backend.py b/canaille/backends/ldap/backend.py index 2ab45eab..7e1f4ea0 100644 --- a/canaille/backends/ldap/backend.py +++ b/canaille/backends/ldap/backend.py @@ -135,8 +135,8 @@ class LDAPBackend(Backend): except ldap.INSUFFICIENT_ACCESS as exc: raise ConfigurationException( - f'LDAP user \'{config["CANAILLE_LDAP"]["BIND_DN"]}\' cannot create ' - f'users at \'{config["CANAILLE_LDAP"]["USER_BASE"]}\'' + f"LDAP user '{config['CANAILLE_LDAP']['BIND_DN']}' cannot create " + f"users at '{config['CANAILLE_LDAP']['USER_BASE']}'" ) from exc try: @@ -160,8 +160,8 @@ class LDAPBackend(Backend): except ldap.INSUFFICIENT_ACCESS as exc: raise ConfigurationException( - f'LDAP user \'{config["CANAILLE_LDAP"]["BIND_DN"]}\' cannot create ' - f'groups at \'{config["CANAILLE_LDAP"]["GROUP_BASE"]}\'' + f"LDAP user '{config['CANAILLE_LDAP']['BIND_DN']}' cannot create " + f"groups at '{config['CANAILLE_LDAP']['GROUP_BASE']}'" ) from exc finally: @@ -430,7 +430,7 @@ def setup_ldap_models(config): LDAPObject.root_dn = config["CANAILLE_LDAP"]["ROOT_DN"] user_base = config["CANAILLE_LDAP"]["USER_BASE"].replace( - f',{config["CANAILLE_LDAP"]["ROOT_DN"]}', "" + f",{config['CANAILLE_LDAP']['ROOT_DN']}", "" ) models.User.base = user_base models.User.rdn_attribute = config["CANAILLE_LDAP"]["USER_RDN"] @@ -438,7 +438,7 @@ def setup_ldap_models(config): models.User.ldap_object_class = listify(object_class) group_base = config["CANAILLE_LDAP"]["GROUP_BASE"].replace( - f',{config["CANAILLE_LDAP"]["ROOT_DN"]}', "" + f",{config['CANAILLE_LDAP']['ROOT_DN']}", "" ) models.Group.base = group_base or None models.Group.rdn_attribute = config["CANAILLE_LDAP"]["GROUP_RDN"] diff --git a/canaille/core/endpoints/auth.py b/canaille/core/endpoints/auth.py index e8caac0d..919970f5 100644 --- a/canaille/core/endpoints/auth.py +++ b/canaille/core/endpoints/auth.py @@ -103,7 +103,7 @@ def password(): if not success: logout_user() current_app.logger.security( - f'Failed login attempt for {session["attempt_login"]} from {request_ip}' + f"Failed login attempt for {session['attempt_login']} from {request_ip}" ) flash(message or _("Login failed, please check your information"), "error") return render_template( @@ -126,7 +126,7 @@ def password(): ) else: current_app.logger.security( - f'Succeed login attempt for {session["attempt_login"]} from {request_ip}' + f"Succeed login attempt for {session['attempt_login']} from {request_ip}" ) del session["attempt_login"] login_user(user) @@ -359,7 +359,7 @@ def verify_two_factor_auth(): user.last_otp_login = datetime.datetime.now(datetime.timezone.utc) Backend.instance.save(user) current_app.logger.security( - f'Succeed login attempt for {session["attempt_login_with_correct_password"]} from {request_ip}' + f"Succeed login attempt for {session['attempt_login_with_correct_password']} from {request_ip}" ) del session["attempt_login_with_correct_password"] login_user(user) @@ -380,7 +380,7 @@ def verify_two_factor_auth(): ) request_ip = request.remote_addr or "unknown IP" current_app.logger.security( - f'Failed login attempt (wrong OTP) for {session["attempt_login_with_correct_password"]} from {request_ip}' + f"Failed login attempt (wrong OTP) for {session['attempt_login_with_correct_password']} from {request_ip}" ) return redirect(url_for("core.auth.verify_two_factor_auth")) @@ -408,7 +408,7 @@ def send_mail_otp(): Backend.instance.save(user) request_ip = request.remote_addr or "unknown IP" current_app.logger.security( - f'Sent one-time password for {session["attempt_login_with_correct_password"]} to {user.emails[0]} from {request_ip}' + f"Sent one-time password for {session['attempt_login_with_correct_password']} to {user.emails[0]} from {request_ip}" ) flash( "Code successfully sent!", @@ -448,7 +448,7 @@ def send_sms_otp(): Backend.instance.save(user) request_ip = request.remote_addr or "unknown IP" current_app.logger.security( - f'Sent one-time password for {session["attempt_login_with_correct_password"]} to {user.phone_numbers[0]} from {request_ip}' + f"Sent one-time password for {session['attempt_login_with_correct_password']} to {user.phone_numbers[0]} from {request_ip}" ) flash( "Code successfully sent!", @@ -487,7 +487,7 @@ def redirect_to_verify_mfa(user, otp_method, request_ip, fail_redirect_url): "info", ) current_app.logger.security( - f'Sent one-time password for {session["attempt_login_with_correct_password"]} to {user.emails[0]} from {request_ip}' + f"Sent one-time password for {session['attempt_login_with_correct_password']} to {user.emails[0]} from {request_ip}" ) return redirect(url_for("core.auth.verify_two_factor_auth")) else: @@ -510,7 +510,7 @@ def redirect_to_verify_mfa(user, otp_method, request_ip, fail_redirect_url): "info", ) current_app.logger.security( - f'Sent one-time password for {session["attempt_login_with_correct_password"]} to {user.phone_numbers[0]} from {request_ip}' + f"Sent one-time password for {session['attempt_login_with_correct_password']} to {user.phone_numbers[0]} from {request_ip}" ) return redirect(url_for("core.auth.verify_two_factor_auth")) else: diff --git a/canaille/oidc/endpoints/oauth.py b/canaille/oidc/endpoints/oauth.py index 559e67df..4280e9a5 100644 --- a/canaille/oidc/endpoints/oauth.py +++ b/canaille/oidc/endpoints/oauth.py @@ -96,7 +96,7 @@ def authorize_guards(client): ): return { "error": "invalid_request", - "error_description": f"prompt '{request.args['prompt'] }' value is not supported", + "error_description": f"prompt '{request.args['prompt']}' value is not supported", }, 400 diff --git a/tests/core/test_intruder_lockout.py b/tests/core/test_intruder_lockout.py index bf48fec6..799e92e8 100644 --- a/tests/core/test_intruder_lockout.py +++ b/tests/core/test_intruder_lockout.py @@ -122,7 +122,7 @@ def test_intruder_lockout_two_consecutive_fails(testclient, backend, user, caplo assert ( "error", - f"Too much attempts. Please wait for {PASSWORD_MIN_DELAY*2 - ldap_shift} seconds before trying to login again.", + f"Too much attempts. Please wait for {PASSWORD_MIN_DELAY * 2 - ldap_shift} seconds before trying to login again.", ) in res.flashes assert ( "canaille", diff --git a/tests/core/test_profile_edition.py b/tests/core/test_profile_edition.py index 46832721..03a5ac61 100644 --- a/tests/core/test_profile_edition.py +++ b/tests/core/test_profile_edition.py @@ -124,9 +124,9 @@ def test_edition(testclient, logged_user, admin, jpeg_photo, backend, caplog): form["photo"] = Upload("logo.jpg", jpeg_photo) res = form.submit(name="action", value="edit-profile") - assert res.flashes == [ - ("success", "Le profil a été mis à jour avec succès.") - ], res.text + assert res.flashes == [("success", "Le profil a été mis à jour avec succès.")], ( + res.text + ) assert ( "canaille", logging.SECURITY, diff --git a/uv.lock b/uv.lock index 39e58e28..f2aa8fa6 100644 --- a/uv.lock +++ b/uv.lock @@ -135,7 +135,7 @@ wheels = [ [[package]] name = "canaille" -version = "0.0.57" +version = "0.0.58" source = { editable = "." } dependencies = [ { name = "flask" },