From df7638c14bb2ea7f4d183c3b4ff55fd1a6898929 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Fri, 10 Jun 2022 07:19:46 -0400 Subject: [PATCH] Remove Fedora-specific defaults from Noggin This makes it easier for third-party (non-Fedora) deployments of Noggin to work. Signed-off-by: Neal Gompa --- news/PR949.bic | 1 + noggin.cfg.example | 14 ++++++++++++-- noggin/defaults.py | 16 ++++++++-------- tests/unit/conftest.py | 2 ++ tests/unit/controller/test_registration.py | 2 +- tests/unit/utility/test_templates.py | 14 +++++++------- 6 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 news/PR949.bic diff --git a/news/PR949.bic b/news/PR949.bic new file mode 100644 index 000000000..325bb3469 --- /dev/null +++ b/news/PR949.bic @@ -0,0 +1 @@ +Noggin no longer assumes it is being deployed in Fedora infrastructure by default. diff --git a/noggin.cfg.example b/noggin.cfg.example index d5c5ba8e7..13ece68db 100644 --- a/noggin.cfg.example +++ b/noggin.cfg.example @@ -62,7 +62,7 @@ MAIL_DEFAULT_SENDER = "Noggin " MAIL_SUPPRESS_SEND = True # Email domains that a user cannot use to register or change to -# MAIL_DOMAIN_BLOCKLIST = ['fedoraproject.org'] +# MAIL_DOMAIN_BLOCKLIST = ['example.com', 'example.org'] # Allowed format for usernames # ALLOWED_USERNAME_PATTERN = "^[a-z0-9][a-z0-9-]{3,30}[a-z0-9]$" @@ -91,6 +91,16 @@ MAIL_SUPPRESS_SEND = True # Page size when paginating results # PAGE_SIZE = 30 +# Chat network settings +CHAT_NETWORKS = { + "irc": {"default_server": "irc.libera.chat"}, + "matrix": {"default_server": "matrix.org"}, +} +# Link to matrix rooms and usernames using the element.io web client +# instance at app.element.io. Set this variable to whatever Element instance +# you use (e.g. chat.fedoraproject.org, chat.opensuse.org, etc.) +CHAT_MATRIX_TO_ARGS = "web-instance[element.io]=app.element.io" + # IPA role allowed to modify and delete stage users. The stage users admin page # will only be accessible to users that have this role. # STAGE_USERS_ROLE = "Stage User Managers" @@ -114,5 +124,5 @@ MAIL_SUPPRESS_SEND = True # BASSET_URL = None # SPAMCHECK_TOKEN_EXPIRATION = 60 # in minutes -# Set to False to disable Fedora Messaging integration +# Set to True to enable Fedora Messaging integration # FEDORA_MESSAGING_ENABLED = True diff --git a/noggin/defaults.py b/noggin/defaults.py index 1baaaefbd..704f087f3 100644 --- a/noggin/defaults.py +++ b/noggin/defaults.py @@ -26,7 +26,7 @@ AVATAR_SERVICE_URL = "https://seccdn.libravatar.org/" AVATAR_DEFAULT_TYPE = "robohash" -MAIL_DOMAIN_BLOCKLIST = ['fedoraproject.org'] +MAIL_DOMAIN_BLOCKLIST = ['example.com', 'example.org'] HEALTHZ = { "live": "noggin.controller.root.liveness", @@ -37,12 +37,12 @@ CHAT_NETWORKS = { "irc": {"default_server": "irc.libera.chat"}, - "matrix": {"default_server": "fedora.im"}, + "matrix": {"default_server": "matrix.org"}, } -# Link to matrix rooms and usernames using the element.io web client -# instance at chat.fedoraproject.org. Set this variable to a falsy -# value to use element.io. -CHAT_MATRIX_TO_ARGS = "web-instance[element.io]=chat.fedoraproject.org" +# Link to matrix rooms and usernames using a element.io web client +# instance. Set this variable to whatever instance you have. +# e.g. chat.fedoraproject.org, chat.opensuse.org +CHAT_MATRIX_TO_ARGS = "web-instance[element.io]=app.element.io" STAGE_USERS_ROLE = "Stage User Managers" @@ -52,5 +52,5 @@ BASSET_URL = None SPAMCHECK_TOKEN_EXPIRATION = 60 # in minutes -# Cheat code to disable Fedora Messaging -FEDORA_MESSAGING_ENABLED = True +# Cheat code to toggle Fedora Messaging support +FEDORA_MESSAGING_ENABLED = False diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 5f520ed2a..a5cff3943 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -36,6 +36,8 @@ def app_config(ipa_cert): PASSWORD_POLICY={"min": 6}, # Don't delete the role we may have in the dev env STAGE_USERS_ROLE="Testing Stage Users Admins", + # Turn on Fedora Messaging + FEDORA_MESSAGING_ENABLED=True, ) diff --git a/tests/unit/controller/test_registration.py b/tests/unit/controller/test_registration.py index e5d729eeb..3009720fd 100644 --- a/tests/unit/controller/test_registration.py +++ b/tests/unit/controller/test_registration.py @@ -578,7 +578,7 @@ def test_invalid_email(client, post_data_step_1): @pytest.mark.vcr() def test_blocklisted_email(client, post_data_step_1): """Register a user with an invalid email address""" - post_data_step_1["register-mail"] = "dude@fedoraproject.org" + post_data_step_1["register-mail"] = "dude@example.org" result = client.post('/', data=post_data_step_1) assert_form_field_error( result, diff --git a/tests/unit/utility/test_templates.py b/tests/unit/utility/test_templates.py index d2010c98e..06f27327a 100644 --- a/tests/unit/utility/test_templates.py +++ b/tests/unit/utility/test_templates.py @@ -27,10 +27,10 @@ "matrix:/username", { "href": ( - "https://matrix.to/#/@username:fedora.im" - "?web-instance[element.io]=chat.fedoraproject.org" + "https://matrix.to/#/@username:matrix.org" + "?web-instance[element.io]=app.element.io" ), - "title": "Matrix on fedora.im", + "title": "Matrix on matrix.org", "name": "@username", }, ), @@ -39,7 +39,7 @@ { "href": ( "https://matrix.to/#/@username:unit.tests" - "?web-instance[element.io]=chat.fedoraproject.org" + "?web-instance[element.io]=app.element.io" ), "title": "Matrix on unit.tests", "name": "@username:unit.tests", @@ -123,9 +123,9 @@ def test_format_nickname_invalid_with_config(app, request_context, mocker): ( "matrix:/channel", { - "href": "https://matrix.to/#/#channel:fedora.im", - "title": "Matrix on fedora.im", - "name": "#channel:fedora.im", + "href": "https://matrix.to/#/#channel:matrix.org", + "title": "Matrix on matrix.org", + "name": "#channel:matrix.org", }, ), (