mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
mediawiki: Fix images throwing 403s
- Increment version number - Functional test for uploading files Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
fd988987a4
commit
8f88f0f6b4
@ -7,3 +7,15 @@
|
||||
RewriteRule ^(.*)$ index.php [L]
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
<Directory /var/lib/mediawiki/images>
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine Off
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
<Directory /var/lib/mediawiki/uploads>
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine Off
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
@ -67,7 +67,13 @@ Scenario: Enabling public registrations disables private mode
|
||||
And I enable mediawiki public registrations
|
||||
Then the mediawiki site should allow creating accounts
|
||||
|
||||
# Requires JS
|
||||
Scenario: Logged in user can see upload files option
|
||||
Given the mediawiki application is enabled
|
||||
When I set the mediawiki admin password to whatever123
|
||||
Then I should see the Upload File option in the side pane when logged in with credentials admin and whatever123
|
||||
|
||||
Scenario: Upload images
|
||||
Given the mediawiki application is enabled
|
||||
When I upload an image to mediawiki with credentials admin and whatever123
|
||||
Then there should be 1 uploaded images
|
||||
|
||||
@ -35,6 +35,20 @@ def access_application(browser, app_name):
|
||||
site.access_url(browser, app_name)
|
||||
|
||||
|
||||
@when(
|
||||
parsers.parse(
|
||||
'I upload an image to mediawiki with credentials {username:w} and {password:w}'
|
||||
))
|
||||
def upload_image(browser, username, password):
|
||||
site.upload_image_mediawiki(browser, username, password)
|
||||
|
||||
|
||||
@then(parsers.parse('there should be {count:d} uploaded images'))
|
||||
def uploaded_image_should_be_available(browser, count):
|
||||
num_images = site.get_number_of_uploaded_images_in_mediawiki(browser)
|
||||
assert count == num_images
|
||||
|
||||
|
||||
@then(
|
||||
parsers.parse(
|
||||
'I should be able to login to coquelicot with password {password:w}'))
|
||||
|
||||
@ -91,7 +91,7 @@ def _change_status(browser, app_name, change_status_to='enabled',
|
||||
checkbox_id = checkbox_id or get_app_checkbox_id(app_name)
|
||||
checkbox = browser.find_by_id(checkbox_id)
|
||||
checkbox.check() if change_status_to == 'enabled' else checkbox.uncheck()
|
||||
interface.submit(browser, 'form-configuration')
|
||||
interface.submit(browser, form_class='form-configuration')
|
||||
if app_name in apps_with_loaders:
|
||||
wait_for_config_update(browser, app_name)
|
||||
|
||||
@ -113,7 +113,7 @@ def select_domain_name(browser, app_name, domain_name):
|
||||
browser.visit('{}/plinth/apps/{}/setup/'.format(default_url, app_name))
|
||||
drop_down = browser.find_by_id('id_domain_name')
|
||||
drop_down.select(domain_name)
|
||||
interface.submit(browser, 'form-configuration')
|
||||
interface.submit(browser, form_class='form-configuration')
|
||||
|
||||
|
||||
def configure_shadowsocks(browser):
|
||||
@ -121,14 +121,14 @@ def configure_shadowsocks(browser):
|
||||
browser.visit('{}/plinth/apps/shadowsocks/'.format(default_url))
|
||||
browser.find_by_id('id_server').fill('some.shadow.tunnel')
|
||||
browser.find_by_id('id_password').fill('fakepassword')
|
||||
interface.submit(browser, 'form-configuration')
|
||||
interface.submit(browser, form_class='form-configuration')
|
||||
|
||||
|
||||
def modify_max_file_size(browser, size):
|
||||
"""Change the maximum file size of coquelicot to the given value"""
|
||||
browser.visit('{}/plinth/apps/coquelicot/'.format(default_url))
|
||||
browser.find_by_id('id_max_file_size').fill(size)
|
||||
interface.submit(browser, 'form-configuration')
|
||||
interface.submit(browser, form_class='form-configuration')
|
||||
|
||||
|
||||
def get_max_file_size(browser):
|
||||
@ -141,7 +141,7 @@ def modify_upload_password(browser, password):
|
||||
"""Change the upload password for coquelicot to the given value"""
|
||||
browser.visit('{}/plinth/apps/coquelicot/'.format(default_url))
|
||||
browser.find_by_id('id_upload_password').fill(password)
|
||||
interface.submit(browser, 'form-configuration')
|
||||
interface.submit(browser, form_class='form-configuration')
|
||||
|
||||
|
||||
# Sharing app helper functions
|
||||
|
||||
@ -106,9 +106,11 @@ def create_admin_account(browser, username, password):
|
||||
submit(browser)
|
||||
|
||||
|
||||
def submit(browser, form_class=None):
|
||||
def submit(browser, element=None, form_class=None):
|
||||
with wait_for_page_update(browser):
|
||||
if form_class:
|
||||
if element:
|
||||
element.click()
|
||||
elif form_class:
|
||||
browser.find_by_css(
|
||||
'.{} input[type=submit]'.format(form_class)).click()
|
||||
else:
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import os
|
||||
from time import sleep
|
||||
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
@ -84,13 +85,35 @@ def verify_mediawiki_no_anonymous_reads_edits_link(browser):
|
||||
args=['ca-nstab-special'])
|
||||
|
||||
|
||||
def login_to_mediawiki_with_credentials(browser, username, password):
|
||||
def _login_to_mediawiki(browser, username, password):
|
||||
browser.visit(config['DEFAULT']['url'] + '/mediawiki')
|
||||
browser.find_by_id('pt-login').click()
|
||||
browser.find_by_id('wpName1').fill(username)
|
||||
browser.find_by_id('wpPassword1').fill(password)
|
||||
with wait_for_page_update(browser):
|
||||
browser.find_by_id('wpLoginAttempt').click()
|
||||
|
||||
|
||||
def login_to_mediawiki_with_credentials(browser, username, password):
|
||||
_login_to_mediawiki(browser, username, password)
|
||||
# Had to put it in the same step because sessions don't
|
||||
# persist between steps
|
||||
assert eventually(browser.is_element_present_by_id, args=['t-upload'])
|
||||
|
||||
|
||||
def upload_image_mediawiki(browser, username, password):
|
||||
"""Upload an image to MediaWiki. Idempotent."""
|
||||
browser.visit(config['DEFAULT']['url'] + '/mediawiki')
|
||||
_login_to_mediawiki(browser, username, password)
|
||||
|
||||
# Upload file
|
||||
browser.visit(config['DEFAULT']['url'] + '/mediawiki/Special:Upload')
|
||||
file_path = os.path.realpath(
|
||||
'../static/themes/default/img/freedombox-logo-32px.png')
|
||||
browser.attach_file('wpUploadFile', file_path)
|
||||
interface.submit(browser, element=browser.find_by_name('wpUpload')[0])
|
||||
|
||||
|
||||
def get_number_of_uploaded_images_in_mediawiki(browser):
|
||||
browser.visit(config['DEFAULT']['url'] + '/mediawiki/Special:ListFiles')
|
||||
return len(browser.find_by_css('.TablePager_col_img_timestamp'))
|
||||
|
||||
@ -26,7 +26,7 @@ from plinth.menu import main_menu
|
||||
|
||||
from .manifest import backup, clients
|
||||
|
||||
version = 4
|
||||
version = 5
|
||||
|
||||
managed_packages = ['mediawiki', 'imagemagick', 'php-sqlite3']
|
||||
|
||||
@ -59,8 +59,7 @@ clients = clients
|
||||
def init():
|
||||
"""Intialize the module."""
|
||||
menu = main_menu.get('apps')
|
||||
menu.add_urlname(name, 'mediawiki', 'mediawiki:index',
|
||||
short_description)
|
||||
menu.add_urlname(name, 'mediawiki', 'mediawiki:index', short_description)
|
||||
|
||||
global service
|
||||
setup_helper = globals()['setup_helper']
|
||||
@ -96,9 +95,9 @@ def setup(helper, old_version=None):
|
||||
|
||||
def add_shortcut():
|
||||
"""Helper method to add a shortcut to the frontpage."""
|
||||
frontpage.add_shortcut('mediawiki', name,
|
||||
short_description=short_description,
|
||||
url='/mediawiki', login_required=is_private_mode_enabled())
|
||||
frontpage.add_shortcut(
|
||||
'mediawiki', name, short_description=short_description,
|
||||
url='/mediawiki', login_required=is_private_mode_enabled())
|
||||
|
||||
|
||||
def is_enabled():
|
||||
@ -137,6 +136,5 @@ def is_public_registration_enabled():
|
||||
|
||||
def is_private_mode_enabled():
|
||||
""" Return wheter private mode is enabled or disabled"""
|
||||
output = actions.superuser_run('mediawiki',
|
||||
['private-mode', 'status'])
|
||||
output = actions.superuser_run('mediawiki', ['private-mode', 'status'])
|
||||
return output.strip() == 'enabled'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user