mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
apps: Remove Coquelicot
Bepasty is the replacement file-sharing app. Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
5971ace116
commit
4e9d22d376
19 files changed
+6
-1145
No files matched your search
@@ -1,86 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Plinth module to configure coquelicot.
|
||||
"""
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth import app as app_module
|
||||
from plinth import frontpage, menu
|
||||
from plinth.daemon import Daemon
|
||||
from plinth.modules.apache.components import Webserver
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
|
||||
from .manifest import backup, clients # noqa, pylint: disable=unused-import
|
||||
|
||||
version = 1
|
||||
|
||||
managed_services = ['coquelicot']
|
||||
|
||||
managed_packages = ['coquelicot']
|
||||
|
||||
_description = [
|
||||
_('Coquelicot is a "one-click" file sharing web application with a focus '
|
||||
'on protecting users\' privacy. It is best used for quickly sharing a '
|
||||
'single file. '),
|
||||
_('This Coquelicot instance is exposed to the public but requires an '
|
||||
'upload password to prevent unauthorized access. You can set a new '
|
||||
'upload password in the form that will appear below after installation. '
|
||||
'The default upload password is "test".')
|
||||
]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
class CoquelicotApp(app_module.App):
|
||||
"""FreedomBox app for Coquelicot."""
|
||||
|
||||
app_id = 'coquelicot'
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
name=_('Coquelicot'),
|
||||
icon_filename='coquelicot',
|
||||
short_description=_('File Sharing'),
|
||||
description=_description,
|
||||
manual_page='Coquelicot', clients=clients)
|
||||
self.add(info)
|
||||
|
||||
menu_item = menu.Menu('menu-coquelicot', info.name,
|
||||
info.short_description, info.icon_filename,
|
||||
'coquelicot:index', parent_url_name='apps')
|
||||
self.add(menu_item)
|
||||
|
||||
shortcut = frontpage.Shortcut('shortcut-coquelicot', info.name,
|
||||
short_description=info.short_description,
|
||||
icon='coquelicot', url='/coquelicot',
|
||||
clients=info.clients,
|
||||
login_required=True)
|
||||
self.add(shortcut)
|
||||
|
||||
firewall = Firewall('firewall-coquelicot', info.name,
|
||||
ports=['http', 'https'], is_external=True)
|
||||
self.add(firewall)
|
||||
|
||||
webserver = Webserver('webserver-coquelicot', 'coquelicot-freedombox',
|
||||
urls=['https://{host}/coquelicot'])
|
||||
self.add(webserver)
|
||||
|
||||
daemon = Daemon('daemon-coquelicot', managed_services[0])
|
||||
self.add(daemon)
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', actions.superuser_run, 'coquelicot', ['setup'])
|
||||
helper.call('post', app.enable)
|
||||
|
||||
|
||||
def get_current_max_file_size():
|
||||
"""Get the current value of maximum file size."""
|
||||
size = actions.superuser_run('coquelicot', ['get-max-file-size'])
|
||||
return int(size.strip())
|
||||
@@ -1,5 +0,0 @@
|
||||
<Location /coquelicot>
|
||||
ProxyPass http://127.0.0.1:51161/coquelicot
|
||||
SetEnv proxy-sendchunks 1
|
||||
RequestHeader set X-Forwarded-SSL "on"
|
||||
</Location>
|
||||
@@ -1 +0,0 @@
|
||||
#plinth.modules.coquelicot
|
||||
@@ -1,20 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Plinth form for configuring Coquelicot.
|
||||
"""
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class CoquelicotForm(forms.Form): # pylint: disable=W0232
|
||||
"""Coquelicot configuration form."""
|
||||
upload_password = forms.CharField(
|
||||
label=_('Upload Password'),
|
||||
help_text=_('Set a new upload password for Coquelicot. '
|
||||
'Leave this field blank to keep the current password.'),
|
||||
required=False, widget=forms.PasswordInput)
|
||||
max_file_size = forms.IntegerField(
|
||||
label=_("Maximum File Size (in MiB)"), help_text=_(
|
||||
'Set the maximum size of the files that can be uploaded to '
|
||||
'Coquelicot.'), required=False, min_value=0)
|
||||
@@ -1,24 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
from plinth.modules.backups.api import validate as validate_backups
|
||||
|
||||
clients = validate([{
|
||||
'name': _('coquelicot'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/coquelicot'
|
||||
}]
|
||||
}])
|
||||
|
||||
backup = validate_backups({
|
||||
'data': {
|
||||
'directories': ['/var/lib/coquelicot']
|
||||
},
|
||||
'secrets': {
|
||||
'files': ['/etc/coquelicot/settings.yml']
|
||||
},
|
||||
'services': ['coquelicot']
|
||||
})
|
||||
Whitespace-only changes.
@@ -1,57 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@apps @coquelicot @backups @skip
|
||||
Feature: Coquelicot File Sharing
|
||||
Run Coquelicot File Sharing server.
|
||||
|
||||
Background:
|
||||
Given I'm a logged in user
|
||||
Given the coquelicot application is installed
|
||||
|
||||
Scenario: Enable coquelicot application
|
||||
Given the coquelicot application is disabled
|
||||
When I enable the coquelicot application
|
||||
Then the coquelicot service should be running
|
||||
|
||||
Scenario: Modify maximum upload size
|
||||
Given the coquelicot application is enabled
|
||||
When I modify the maximum file size of coquelicot to 256
|
||||
Then the maximum file size of coquelicot should be 256
|
||||
|
||||
Scenario: Modify upload password
|
||||
Given the coquelicot application is enabled
|
||||
When I modify the coquelicot upload password to whatever123
|
||||
Then I should be able to login to coquelicot with password whatever123
|
||||
|
||||
Scenario: Modify maximum upload size in disabled case
|
||||
Given the coquelicot application is disabled
|
||||
When I modify the maximum file size of coquelicot to 123
|
||||
Then the coquelicot service should not be running
|
||||
|
||||
Scenario: Upload a file to coquelicot
|
||||
Given the coquelicot application is enabled
|
||||
And a sample local file
|
||||
When I modify the coquelicot upload password to whatever123
|
||||
And I upload the sample local file to coquelicot with password whatever123
|
||||
And I download the uploaded file from coquelicot
|
||||
Then contents of downloaded sample file should be same as sample local file
|
||||
|
||||
Scenario: Backup and restore coquelicot
|
||||
Given the coquelicot application is enabled
|
||||
When I modify the coquelicot upload password to beforebackup123
|
||||
And I modify the maximum file size of coquelicot to 128
|
||||
And I upload the sample local file to coquelicot with password beforebackup123
|
||||
And I create a backup of the coquelicot app data with name test_coquelicot
|
||||
And I modify the coquelicot upload password to afterbackup123
|
||||
And I modify the maximum file size of coquelicot to 64
|
||||
And I restore the coquelicot app data backup with name test_coquelicot
|
||||
And I download the uploaded file from coquelicot
|
||||
Then the coquelicot service should be running
|
||||
And I should be able to login to coquelicot with password beforebackup123
|
||||
And the maximum file size of coquelicot should be 128
|
||||
And contents of downloaded sample file should be same as sample local file
|
||||
|
||||
Scenario: Disable coquelicot application
|
||||
Given the coquelicot application is enabled
|
||||
When I disable the coquelicot application
|
||||
Then the coquelicot service should not be running
|
||||
@@ -1,126 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Functional, browser based tests for coquelicot app.
|
||||
"""
|
||||
|
||||
import random
|
||||
import tempfile
|
||||
|
||||
from pytest_bdd import given, parsers, scenarios, then, when
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
from plinth.tests import functional
|
||||
|
||||
scenarios('coquelicot.feature')
|
||||
|
||||
|
||||
@given('a sample local file')
|
||||
def sample_local_file():
|
||||
file_path, contents = _create_sample_local_file()
|
||||
return dict(file_path=file_path, contents=contents)
|
||||
|
||||
|
||||
@when(parsers.parse('I modify the maximum file size of coquelicot to {size:d}')
|
||||
)
|
||||
def modify_max_file_size(session_browser, size):
|
||||
_modify_max_file_size(session_browser, size)
|
||||
|
||||
|
||||
@then(parsers.parse('the maximum file size of coquelicot should be {size:d}'))
|
||||
def assert_max_file_size(session_browser, size):
|
||||
assert _get_max_file_size(session_browser) == size
|
||||
|
||||
|
||||
@when(parsers.parse('I modify the coquelicot upload password to {password:w}'))
|
||||
def modify_upload_password(session_browser, password):
|
||||
_modify_upload_password(session_browser, password)
|
||||
|
||||
|
||||
@then(
|
||||
parsers.parse(
|
||||
'I should be able to login to coquelicot with password {password:w}'))
|
||||
def verify_upload_password(session_browser, password):
|
||||
_verify_upload_password(session_browser, password)
|
||||
|
||||
|
||||
@when(
|
||||
parsers.parse('I upload the sample local file to coquelicot with password '
|
||||
'{password:w}'))
|
||||
def coquelicot_upload_file(session_browser, sample_local_file, password):
|
||||
url = _upload_file(session_browser, sample_local_file['file_path'],
|
||||
password)
|
||||
sample_local_file['upload_url'] = url
|
||||
|
||||
|
||||
@when('I download the uploaded file from coquelicot')
|
||||
def coquelicot_download_file(sample_local_file):
|
||||
file_path = functional.download_file_outside_browser(
|
||||
sample_local_file['upload_url'])
|
||||
sample_local_file['download_path'] = file_path
|
||||
|
||||
|
||||
@then('contents of downloaded sample file should be same as sample local file')
|
||||
def coquelicot_compare_upload_download_files(sample_local_file):
|
||||
_compare_files(sample_local_file['file_path'],
|
||||
sample_local_file['download_path'])
|
||||
|
||||
|
||||
def _create_sample_local_file():
|
||||
"""Create a sample file for upload using browser."""
|
||||
contents = bytearray(random.getrandbits(8) for _ in range(64))
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
temp_file.write(contents)
|
||||
|
||||
return temp_file.name, contents
|
||||
|
||||
|
||||
def _verify_upload_password(browser, password):
|
||||
functional.visit(browser, '/coquelicot')
|
||||
# ensure the password form is scrolled into view
|
||||
browser.execute_script('window.scrollTo(100, 0)')
|
||||
browser.find_by_id('upload_password').fill(password)
|
||||
actions = ActionChains(browser.driver)
|
||||
actions.send_keys(Keys.RETURN)
|
||||
actions.perform()
|
||||
assert functional.eventually(browser.is_element_present_by_css,
|
||||
args=['div[style*="display: none;"]'])
|
||||
|
||||
|
||||
def _upload_file(browser, file_path, password):
|
||||
"""Upload a local file from disk to coquelicot."""
|
||||
_verify_upload_password(browser, password)
|
||||
browser.attach_file('file', file_path)
|
||||
functional.submit(browser)
|
||||
assert functional.eventually(browser.is_element_present_by_css,
|
||||
args=['#content .url'])
|
||||
url_textarea = browser.find_by_css('#content .url textarea').first
|
||||
return url_textarea.value
|
||||
|
||||
|
||||
def _modify_max_file_size(browser, size):
|
||||
"""Change the maximum file size of coquelicot to the given value"""
|
||||
functional.visit(browser, '/plinth/apps/coquelicot/')
|
||||
browser.find_by_id('id_max_file_size').fill(size)
|
||||
functional.submit(browser, form_class='form-configuration')
|
||||
|
||||
|
||||
def _get_max_file_size(browser):
|
||||
"""Get the maximum file size of coquelicot"""
|
||||
functional.visit(browser, '/plinth/apps/coquelicot/')
|
||||
return int(browser.find_by_id('id_max_file_size').value)
|
||||
|
||||
|
||||
def _modify_upload_password(browser, password):
|
||||
"""Change the upload password for coquelicot to the given value"""
|
||||
functional.visit(browser, '/plinth/apps/coquelicot/')
|
||||
browser.find_by_id('id_upload_password').fill(password)
|
||||
functional.submit(browser, form_class='form-configuration')
|
||||
|
||||
|
||||
def _compare_files(file1, file2):
|
||||
"""Assert that the contents of two files are the same."""
|
||||
file1_contents = open(file1, 'rb').read()
|
||||
file2_contents = open(file2, 'rb').read()
|
||||
|
||||
assert file1_contents == file2_contents
|
||||
@@ -1,12 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
URLs for the coquelicot module.
|
||||
"""
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from .views import CoquelicotAppView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/coquelicot/$', CoquelicotAppView.as_view(), name='index'),
|
||||
]
|
||||
@@ -1,52 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Plinth views for Coquelicot.
|
||||
"""
|
||||
|
||||
from django.contrib import messages
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from plinth import actions, views
|
||||
from plinth.errors import ActionError
|
||||
from plinth.modules.coquelicot import get_current_max_file_size
|
||||
|
||||
from .forms import CoquelicotForm
|
||||
|
||||
|
||||
class CoquelicotAppView(views.AppView):
|
||||
"""Serve configuration page."""
|
||||
app_id = 'coquelicot'
|
||||
form_class = CoquelicotForm
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the status of the service to fill in the form."""
|
||||
initial = super().get_initial()
|
||||
initial['max_file_size'] = get_current_max_file_size()
|
||||
return initial
|
||||
|
||||
def form_valid(self, form):
|
||||
"""Apply the changes submitted in the form."""
|
||||
form_data = form.cleaned_data
|
||||
|
||||
if form_data['upload_password']:
|
||||
try:
|
||||
actions.superuser_run(
|
||||
'coquelicot', ['set-upload-password'],
|
||||
input=form_data['upload_password'].encode())
|
||||
messages.success(self.request, _('Upload password updated'))
|
||||
except ActionError:
|
||||
messages.error(self.request,
|
||||
_('Failed to update upload password'))
|
||||
|
||||
max_file_size = form_data['max_file_size']
|
||||
if max_file_size and max_file_size != get_current_max_file_size():
|
||||
try:
|
||||
actions.superuser_run(
|
||||
'coquelicot', ['set-max-file-size',
|
||||
str(max_file_size)])
|
||||
messages.success(self.request, _('Maximum file size updated'))
|
||||
except ActionError:
|
||||
messages.error(self.request,
|
||||
_('Failed to update maximum file size'))
|
||||
|
||||
return super().form_valid(form)
|
||||
Reference in new issue
Block a user