tests: fix style

This commit is contained in:
Éloi Rivard 2025-01-10 14:50:17 +01:00
parent d18a0e1a80
commit af2f71c978
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184
7 changed files with 22 additions and 22 deletions

View file

@ -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):

View file

@ -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"]

View file

@ -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:

View file

@ -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

View file

@ -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",

View file

@ -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,

View file

@ -135,7 +135,7 @@ wheels = [
[[package]]
name = "canaille"
version = "0.0.57"
version = "0.0.58"
source = { editable = "." }
dependencies = [
{ name = "flask" },