mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
mediawiki: Completely uninstall app
Tests: 1. Install Mediawiki, set the admin password and edit the main page 2. Reinstall app: password and wiki content are set back to default 3. After the reinstall, I test uploading an image and backing up/restoring the app Signed-off-by: nbenedek <contact@nbenedek.me> [sunil: Update docstrings, make uninstall fail-safe] [sunil: Fix functional tests by setting up after re-install] [sunil: Fix functional test by account for change in delete button ID] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
30b0019865
commit
50b6fd4093
@ -14,7 +14,7 @@ from plinth.modules.backups.components import BackupRestore
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
from plinth.package import Packages
|
||||
|
||||
from . import manifest, privileged, forms
|
||||
from . import forms, manifest, privileged
|
||||
|
||||
_description = [
|
||||
_('MediaWiki is the wiki engine that powers Wikipedia and other WikiMedia '
|
||||
@ -97,6 +97,11 @@ class MediaWikiApp(app_module.App):
|
||||
privileged.update()
|
||||
self.enable()
|
||||
|
||||
def uninstall(self):
|
||||
"""De-configure and uninstall the app."""
|
||||
super().uninstall()
|
||||
privileged.uninstall()
|
||||
|
||||
|
||||
class Shortcut(frontpage.Shortcut):
|
||||
"""Frontpage shortcut for only logged users when in private mode."""
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
"""Configure MediaWiki."""
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from typing import Optional
|
||||
@ -218,5 +220,11 @@ def set_default_language(language: str):
|
||||
# languages.
|
||||
rebuild_messages_script = os.path.join(MAINTENANCE_SCRIPTS_DIR,
|
||||
'rebuildmessages.php')
|
||||
subprocess.check_call([
|
||||
_get_php_command(), rebuild_messages_script])
|
||||
subprocess.check_call([_get_php_command(), rebuild_messages_script])
|
||||
|
||||
|
||||
@privileged
|
||||
def uninstall():
|
||||
"""Remove Mediawiki's database and local config file."""
|
||||
shutil.rmtree('/var/lib/mediawiki-db', ignore_errors=True)
|
||||
pathlib.Path(LOCAL_SETTINGS_CONF).unlink(missing_ok=True)
|
||||
|
||||
@ -100,6 +100,12 @@ class TestMediawikiApp(functional.BaseAppTests):
|
||||
assert _image_exists(session_browser, 'Noise.png')
|
||||
_verify_create_account_link(session_browser)
|
||||
|
||||
def test_uninstall(self, session_browser):
|
||||
"""Setup the app configuration again after a re-install."""
|
||||
super().test_uninstall(session_browser)
|
||||
_set_domain(session_browser)
|
||||
_set_admin_password(session_browser, 'whatever123')
|
||||
|
||||
|
||||
def _enable_public_registrations(browser):
|
||||
"""Enable public registrations in MediaWiki."""
|
||||
@ -213,6 +219,10 @@ def _delete_image(browser, username, password, image):
|
||||
path = f'/mediawiki/index.php?title=File:{image}&action=delete'
|
||||
functional.visit(browser, path)
|
||||
delete_button = browser.find_by_id('mw-filedelete-submit')
|
||||
if not delete_button:
|
||||
# On bookworm and higher
|
||||
delete_button = browser.find_by_id('wpConfirmB')
|
||||
|
||||
functional.submit(browser, element=delete_button)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user