Commit ed55f62a authored by James Valleroy's avatar James Valleroy

functional_tests: Test mediawiki backup and restore

Signed-off-by: James Valleroy's avatarJames Valleroy <jvalleroy@mailbox.org>
parent e1cda649
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
@apps @mediawiki @apps @mediawiki @backups
Feature: MediaWiki Wiki Engine Feature: MediaWiki Wiki Engine
Manage wikis, multimedia and more. Manage wikis, multimedia and more.
...@@ -82,3 +82,11 @@ Scenario: Upload SVG image ...@@ -82,3 +82,11 @@ Scenario: Upload SVG image
Given the mediawiki application is enabled Given the mediawiki application is enabled
When I upload an image named FreedomBox-logo-grayscale.svg to mediawiki with credentials admin and whatever123 When I upload an image named FreedomBox-logo-grayscale.svg to mediawiki with credentials admin and whatever123
Then there should be FreedomBox-logo-grayscale.svg image Then there should be FreedomBox-logo-grayscale.svg image
Scenario: Backup and restore mediawiki
Given the mediawiki application is enabled
When I create a backup of the mediawiki app data
And I delete the mediawiki main page
And I export the mediawiki app data backup
And I restore the mediawiki app data backup
Then the mediawiki main page should be restored
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from pytest_bdd import parsers, then, when from pytest_bdd import given, parsers, then, when
from support import site from support import site
...@@ -86,3 +86,13 @@ def mediawiki_does_not_allow__account_creation_anonymous_reads_edits(browser): ...@@ -86,3 +86,13 @@ def mediawiki_does_not_allow__account_creation_anonymous_reads_edits(browser):
'with credentials {username:w} and {password:w}')) 'with credentials {username:w} and {password:w}'))
def login_to_mediawiki_with_credentials(browser, username, password): def login_to_mediawiki_with_credentials(browser, username, password):
site.login_to_mediawiki_with_credentials(browser, username, password) site.login_to_mediawiki_with_credentials(browser, username, password)
@when('I delete the mediawiki main page')
def mediawiki_delete_main_page(browser):
site.mediawiki_delete_main_page(browser)
@then('the mediawiki main page should be restored')
def mediawiki_verify_text(browser):
assert site.mediawiki_has_main_page(browser)
...@@ -24,6 +24,7 @@ from selenium.webdriver.common.keys import Keys ...@@ -24,6 +24,7 @@ from selenium.webdriver.common.keys import Keys
from support import config, interface from support import config, interface
from support.service import eventually, wait_for_page_update from support.service import eventually, wait_for_page_update
# unlisted sites just use '/' + site_name as url # unlisted sites just use '/' + site_name as url
site_url = { site_url = {
'wiki': '/ikiwiki', 'wiki': '/ikiwiki',
...@@ -123,3 +124,20 @@ def get_uploaded_image_in_mediawiki(browser, image): ...@@ -123,3 +124,20 @@ def get_uploaded_image_in_mediawiki(browser, image):
browser.visit(config['DEFAULT']['url'] + '/mediawiki/Special:ListFiles') browser.visit(config['DEFAULT']['url'] + '/mediawiki/Special:ListFiles')
elements = browser.find_link_by_partial_href(image) elements = browser.find_link_by_partial_href(image)
return elements[0].value return elements[0].value
def mediawiki_delete_main_page(browser):
"""Delete the mediawiki main page."""
_login_to_mediawiki(browser, 'admin', 'whatever123')
browser.visit(
'{}/mediawiki/index.php?title=Main_Page&action=delete'.format(
interface.default_url))
with wait_for_page_update(browser):
browser.find_by_id('wpConfirmB').first.click()
def mediawiki_has_main_page(browser):
"""Check if mediawiki main page exists."""
browser.visit('{}/mediawiki/Main_Page'.format(interface.default_url))
content = browser.find_by_id('mw-content-text').first
return 'This page has been deleted.' not in content.text
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
from support import config from support import config
from .interface import nav_to_module, submit from .interface import default_url, nav_to_module, submit
config_page_title_language_map = { config_page_title_language_map = {
'da': 'Generel Konfiguration', 'da': 'Generel Konfiguration',
...@@ -150,6 +150,7 @@ def dynamicdns_change_config(browser): ...@@ -150,6 +150,7 @@ def dynamicdns_change_config(browser):
def backup_create(browser, app_name): def backup_create(browser, app_name):
browser.visit(default_url)
nav_to_module(browser, 'backups') nav_to_module(browser, 'backups')
delete = browser.find_link_by_href( delete = browser.find_link_by_href(
'/plinth/sys/backups/delete/_functional_test_' + app_name + '/') '/plinth/sys/backups/delete/_functional_test_' + app_name + '/')
...@@ -163,6 +164,7 @@ def backup_create(browser, app_name): ...@@ -163,6 +164,7 @@ def backup_create(browser, app_name):
def backup_export(browser, app_name): def backup_export(browser, app_name):
browser.visit(default_url)
nav_to_module(browser, 'backups') nav_to_module(browser, 'backups')
browser.find_link_by_href( browser.find_link_by_href(
'/plinth/sys/backups/export/_functional_test_' '/plinth/sys/backups/export/_functional_test_'
...@@ -172,6 +174,7 @@ def backup_export(browser, app_name): ...@@ -172,6 +174,7 @@ def backup_export(browser, app_name):
def backup_restore(browser, app_name): def backup_restore(browser, app_name):
browser.visit(default_url)
nav_to_module(browser, 'backups') nav_to_module(browser, 'backups')
browser.find_link_by_href( browser.find_link_by_href(
'/plinth/sys/backups/restore/Root%2520Filesystem/_functional_test_' '/plinth/sys/backups/restore/Root%2520Filesystem/_functional_test_'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment