mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- Uninstall deletes wikis & extensions - Use Skylark (v1.8.0) - Add option to upload existing wiki - Open wiki links in new tab. Since Feather Wiki modifies browser history, it takes several clicks to go back and reach the FreedomBox app for Feather Wiki if the user wants to switch to another wiki file. Opening in a new tab also makes it easy for the user to move text between wikis (i.e. the Refile use case). - Improve HTML file path handling. Extract only the HTML file name from the URL. Return a 404 status if the file cannot be found - Place featherwiki_nest.cgi file in /usr/lib/cgi-bin. The file is installed as part of the FreedomBox package, rather than a step in the installation of Feather Wiki. [sunil] - Reorganized description to complete the introduction before talking about FreedomBox implementation. - Update description to say that only users of 'wiki' group can access. - Update description to talk about where the wiki is downloaded from how to upgrade it. - Update short description to 'Personal Notebooks'. - Add UsersAndGroups component and to reuse 'wiki' group properly. - Reorder component to resemble other apps (could prove useful in future). - Restrict frontpage shortcut to 'wiki' group users. - Minor styling updates. Run isort. - Use pathlib.Path object where possible instead of os.path. - Perform sanitization in privileged methods instead of callers. This leads better security if the service is compromised. - Perform duplicate checking in privileged methods instead of callers. - Check in privileged action that uploaded file originates from temporary directory. Otherwise, arbitrary files can moved into DAV directory. - Switch storage path to /var/lib/ which is an application data folder from /var/www which is a user data folder. - Add extra security to the DAV folder by explicitly rejecting .htaccess directives, forcing mime type and removing all options. - Update SVG/PNG logo icons to adhere to our guidelines. - Minor template updates. Add required attributes. Improve i18n. Avoid <p> inside <p>. - Refactor tests for more code reuse and fewer globals. Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
106 lines
4.3 KiB
Python
106 lines
4.3 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Functional, browser based tests for Feather Wiki app."""
|
|
|
|
import pathlib
|
|
|
|
import pytest
|
|
|
|
from plinth.tests import functional
|
|
|
|
pytestmark = [pytest.mark.apps, pytest.mark.featherwiki]
|
|
|
|
course_1 = 'Computer Organization and Architecture'
|
|
file_name_1 = 'Computer_Organization_and_Architecture.html'
|
|
|
|
|
|
class TestFeatherWikiApp(functional.BaseAppTests):
|
|
app_name = 'featherwiki'
|
|
has_service = False
|
|
has_web = True
|
|
|
|
def _create_wiki_file(self, session_browser):
|
|
"""Add a wiki to using the 'Create' functionality."""
|
|
functional.nav_to_module(session_browser, 'featherwiki')
|
|
|
|
wiki_link_1 = f'/featherwiki/{file_name_1}'
|
|
if self._get_links_in_app_page(session_browser, wiki_link_1):
|
|
return
|
|
|
|
session_browser.links.find_by_href(
|
|
'/plinth/apps/featherwiki/create/').first.click()
|
|
session_browser.find_by_id('id_featherwiki-name').fill(course_1)
|
|
functional.submit(session_browser, form_class='form-featherwiki')
|
|
|
|
def _get_links_in_app_page(self, session_browser, link):
|
|
"""Return the links matching a href in the app page."""
|
|
functional.nav_to_module(session_browser, 'featherwiki')
|
|
return session_browser.links.find_by_href(link)
|
|
|
|
def _get_links_in_apache_listing(self, session_browser, link):
|
|
"""Return the links matching a href in the index page."""
|
|
default_url = functional.config['DEFAULT']['url']
|
|
session_browser.visit(f'{default_url}/featherwiki')
|
|
return session_browser.links.find_by_href(link)
|
|
|
|
def _assert_wiki_present(self, session_browser, file_name, present=True):
|
|
"""Assert that a wiki is present."""
|
|
wiki_link = f'/featherwiki/{file_name}'
|
|
assert bool(self._get_links_in_app_page(session_browser,
|
|
wiki_link)) == present
|
|
assert bool(
|
|
self._get_links_in_apache_listing(session_browser,
|
|
file_name)) == present
|
|
|
|
def _assert_wiki_works(self, session_browser, file_name):
|
|
"""Assert that wiki loads and run as expected."""
|
|
wiki_link = f'/featherwiki/{file_name}'
|
|
default_url = functional.config['DEFAULT']['url']
|
|
session_browser.visit(f'{default_url}{wiki_link}')
|
|
links = session_browser.links.find_by_href('https://feather.wiki')
|
|
assert len(links) == 1
|
|
|
|
def test_wiki_file_access(self, session_browser):
|
|
"""Test creating a new wiki file."""
|
|
self._create_wiki_file(session_browser)
|
|
|
|
self._assert_wiki_present(session_browser, file_name_1)
|
|
self._assert_wiki_works(session_browser, file_name_1)
|
|
|
|
def test_rename_wiki_file(self, session_browser):
|
|
"""Test changing the name of a wiki file."""
|
|
self._create_wiki_file(session_browser)
|
|
|
|
new_course = 'A Midsummer Night\'s Dream'
|
|
new_file_name = 'A_Midsummer_Nights_Dream.html'
|
|
self._get_links_in_app_page(
|
|
session_browser, '/plinth/apps/featherwiki/' + file_name_1 +
|
|
'/rename/').first.click()
|
|
session_browser.find_by_id('id_featherwiki-new_name').fill(new_course)
|
|
functional.submit(session_browser, form_class='form-featherwiki')
|
|
|
|
self._assert_wiki_present(session_browser, new_file_name)
|
|
self._assert_wiki_works(session_browser, new_file_name)
|
|
|
|
def test_upload_wiki_file(self, session_browser):
|
|
"""Test uploading an existing wiki file."""
|
|
_test_data_dir = pathlib.Path(__file__).parent / 'data'
|
|
test_wiki_file = str(_test_data_dir / 'dummy_wiki.html')
|
|
|
|
session_browser.links.find_by_href(
|
|
'/plinth/apps/featherwiki/upload/').first.click()
|
|
session_browser.attach_file('featherwiki-file', test_wiki_file)
|
|
functional.submit(session_browser, form_class='form-featherwiki')
|
|
|
|
self._assert_wiki_present(session_browser, 'dummy_wiki.html')
|
|
|
|
def test_delete_wiki_file(self, session_browser):
|
|
"""Test deleting an existing wiki file"""
|
|
self._create_wiki_file(session_browser)
|
|
|
|
self._get_links_in_app_page(
|
|
session_browser, '/plinth/apps/featherwiki/' + file_name_1 +
|
|
'/delete/').first.click()
|
|
functional.submit(session_browser, form_class='form-delete')
|
|
|
|
self._assert_wiki_present(session_browser, file_name_1, present=False)
|