mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
app: info: Move client validation to info component
- Each app does not have to call the validator by itself. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
5f3c691c38
commit
6fc9e228a0
@ -5,6 +5,8 @@ Base class for all Freedombox applications.
|
||||
|
||||
import collections
|
||||
|
||||
from . import clients as clients_module
|
||||
|
||||
|
||||
class App:
|
||||
"""Implement common functionality for an app.
|
||||
@ -373,3 +375,5 @@ class Info(FollowerComponent):
|
||||
self.manual_page = manual_page
|
||||
self.clients = clients
|
||||
self.donation_url = donation_url
|
||||
if clients:
|
||||
clients_module.validate(clients)
|
||||
|
||||
@ -2,15 +2,13 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('bepasty'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/bepasty'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -2,15 +2,13 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('calibre'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/calibre/'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'data': {
|
||||
|
||||
@ -5,15 +5,13 @@ Application manifest for cockpit.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('Cockpit'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/_cockpit/'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
# cockpit.conf need not be backed up because add/remove domain signals are
|
||||
# triggered on every Plinth domain change (and cockpit application install) and
|
||||
|
||||
@ -2,16 +2,14 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('Deluge'),
|
||||
'description': _('Bittorrent client written in Python/PyGTK'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/deluge'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
from plinth.modules import diaspora
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('dandelion*'),
|
||||
'description':
|
||||
@ -30,4 +30,4 @@ clients = validate([{
|
||||
host=diaspora.get_configured_domain_name()
|
||||
if diaspora.is_setup() else "<please-setup-domain-name>")
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
from plinth.modules.jsxc import manifest as jsxc_manifest
|
||||
|
||||
_clients = validate([{
|
||||
_clients = [{
|
||||
'name':
|
||||
_('Conversations'),
|
||||
'platforms': [{
|
||||
@ -99,7 +99,7 @@ _clients = validate([{
|
||||
'os': 'windows',
|
||||
'url': 'https://gajim.org/downloads.php'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
_clients.extend(jsxc_manifest.clients)
|
||||
|
||||
|
||||
@ -2,12 +2,10 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
CONFIG_FILE = '/etc/gitweb-freedombox.conf'
|
||||
GIT_REPO_PATH = '/var/lib/git'
|
||||
|
||||
clients = validate([
|
||||
clients = [
|
||||
{
|
||||
'name': _('Gitweb'),
|
||||
'platforms': [{
|
||||
@ -32,7 +30,7 @@ clients = validate([
|
||||
'url': 'https://git-scm.com/download/windows'
|
||||
}]
|
||||
},
|
||||
])
|
||||
]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -5,12 +5,10 @@ Application manifest for I2P.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
_package_id = 'net.geti2p.i2p'
|
||||
_download_url = 'https://geti2p.net/download'
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('I2P'),
|
||||
'platforms': [{
|
||||
@ -33,7 +31,7 @@ clients = validate([{
|
||||
'os': 'windows',
|
||||
'url': _download_url,
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'secrets': {
|
||||
|
||||
@ -2,14 +2,12 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('ikiwiki'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/ikiwiki'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {'data': {'directories': ['/var/lib/ikiwiki/', '/var/www/ikiwiki/']}}
|
||||
|
||||
@ -3,10 +3,9 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import cfg
|
||||
from plinth.clients import validate
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Gobby'),
|
||||
'description':
|
||||
@ -29,7 +28,7 @@ clients = validate([{
|
||||
'format': 'deb',
|
||||
'name': 'gobby'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'data': {
|
||||
|
||||
@ -3,14 +3,12 @@
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('JSXC'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': reverse_lazy('jsxc:jsxc')
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {}
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
_android_package_id = 'im.vector.app'
|
||||
_element_desktop_download_url = 'https://element.io/get-started'
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Element'),
|
||||
'platforms': [{
|
||||
@ -41,7 +41,7 @@ clients = validate([{
|
||||
'os': 'windows',
|
||||
'url': _element_desktop_download_url,
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -2,15 +2,13 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('MediaWiki'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/mediawiki'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Minetest'),
|
||||
'platforms': [{
|
||||
@ -34,7 +34,7 @@ clients = validate([{
|
||||
'format': 'deb',
|
||||
'name': 'minetest'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
clients = validate([
|
||||
clients = [
|
||||
{
|
||||
'name':
|
||||
_('vlc'),
|
||||
@ -96,7 +96,7 @@ clients = validate([
|
||||
'name': 'totem',
|
||||
}]
|
||||
},
|
||||
])
|
||||
]
|
||||
|
||||
# TODO: get all media directories from config file
|
||||
# for now hard code default media folder.
|
||||
|
||||
@ -5,9 +5,9 @@ Application manifest for mldonkey.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('MLDonkey'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
@ -34,7 +34,7 @@ clients = validate([{
|
||||
'store_name': 'google-play',
|
||||
'url': store_url('google-play', 'com.devwom.amldonkey'),
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Mumble'),
|
||||
'platforms': [{
|
||||
@ -52,7 +52,7 @@ clients = validate([{
|
||||
'store_name': 'google-play',
|
||||
'url': store_url('google-play', 'se.lublin.mumla')
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'data': {
|
||||
|
||||
@ -5,14 +5,14 @@ Application manifest for OpenVPN.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
_package_id = 'de.blinkt.openvpn'
|
||||
_download_url = 'https://openvpn.net/community-downloads'
|
||||
|
||||
backup = {'secrets': {'directories': ['/etc/openvpn/']}}
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('OpenVPN'),
|
||||
'platforms': [{
|
||||
@ -50,4 +50,4 @@ clients = validate([{
|
||||
'os': 'macos',
|
||||
'url': 'https://tunnelblick.net/downloads.html'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
@ -5,12 +5,10 @@ FreedomBox app for System Monitoring (cockpit-pcp) in ‘System’.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('Cockpit'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/_cockpit/system/graphs'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Quassel'),
|
||||
'platforms': [{
|
||||
@ -42,7 +42,7 @@ clients = validate([{
|
||||
'store_name': 'google-play',
|
||||
'url': store_url('google-play', 'com.iskrembilen.quasseldroid'),
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'secrets': {
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('DAVx5'),
|
||||
'usage':
|
||||
@ -76,7 +76,7 @@ clients = validate([{
|
||||
'type': 'web',
|
||||
'url': '/radicale/'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'data': {
|
||||
|
||||
@ -2,14 +2,12 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('Roundcube'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/roundcube'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {}
|
||||
|
||||
@ -5,11 +5,11 @@ Application manifest for Samba.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
SHARES_CONF_BACKUP_FILE = '/var/lib/plinth/backups-data/samba-shares-dump.conf'
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Android Samba Client'),
|
||||
'platforms': [{
|
||||
@ -74,7 +74,7 @@ clients = validate([{
|
||||
'os': 'gnu-linux',
|
||||
'url': 'https://kde.org/applications/system/org.kde.dolphin'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'data': {
|
||||
|
||||
@ -2,15 +2,13 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('Searx'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/searx/'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
PUBLIC_ACCESS_SETTING_FILE = '/etc/searx/allow_public_access'
|
||||
|
||||
|
||||
@ -2,12 +2,10 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('Shaarli'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/shaarli'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
_package_id = 'com.nutomic.syncthingandroid'
|
||||
_download_url = 'https://syncthing.net/'
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Syncthing'),
|
||||
'platforms': [{
|
||||
@ -44,7 +44,7 @@ clients = validate([{
|
||||
'type': 'web',
|
||||
'url': '/syncthing'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'secrets': {
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
_orbot_package_id = 'org.torproject.android'
|
||||
_tor_browser_download_url = \
|
||||
'https://www.torproject.org/download/download-easy.html'
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Tor Browser'),
|
||||
'platforms': [{
|
||||
@ -38,7 +38,7 @@ clients = validate([{
|
||||
'store_name': 'f-droid',
|
||||
'url': store_url('f-droid', _orbot_package_id)
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'config': {
|
||||
|
||||
@ -2,15 +2,13 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name': _('Transmission'),
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': '/transmission'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'data': {
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('Tiny Tiny RSS (Fork)'),
|
||||
'platforms': [{
|
||||
@ -25,7 +25,7 @@ clients = validate([{
|
||||
'type': 'web',
|
||||
'url': '/tt-rss'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
backup = {
|
||||
'data': {
|
||||
|
||||
@ -5,11 +5,11 @@ Application manifest for WireGuard.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.clients import store_url
|
||||
|
||||
_wireguard_package_id = 'com.wireguard.android'
|
||||
|
||||
clients = validate([{
|
||||
clients = [{
|
||||
'name':
|
||||
_('WireGuard'),
|
||||
'platforms': [{
|
||||
@ -40,4 +40,4 @@ clients = validate([{
|
||||
'store_name': 'app-store',
|
||||
'url': 'https://apps.apple.com/us/app/wireguard/id1441195209'
|
||||
}]
|
||||
}])
|
||||
}]
|
||||
|
||||
@ -10,6 +10,8 @@ import pytest
|
||||
|
||||
from plinth.app import App, Component, FollowerComponent, Info, LeaderComponent
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
|
||||
class AppTest(App):
|
||||
"""Sample App for testing."""
|
||||
@ -302,10 +304,17 @@ def test_info_initialization_without_args():
|
||||
|
||||
def test_info_initialization_with_args():
|
||||
"""Test initializing the Info component with arguments."""
|
||||
clients = [{
|
||||
'name': 'test',
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': 'test-url'
|
||||
}]
|
||||
}]
|
||||
info = Info('test-app', 3, is_essential=True, depends=['test-app-2'],
|
||||
name='Test App', icon='fa-test', icon_filename='test-icon',
|
||||
short_description='For Test', description='Test description',
|
||||
manual_page='Test', clients=['test'])
|
||||
manual_page='Test', clients=clients)
|
||||
assert info.is_essential
|
||||
assert info.depends == ['test-app-2']
|
||||
assert info.name == 'Test App'
|
||||
@ -314,4 +323,19 @@ def test_info_initialization_with_args():
|
||||
assert info.short_description == 'For Test'
|
||||
assert info.description == 'Test description'
|
||||
assert info.manual_page == 'Test'
|
||||
assert info.clients == ['test']
|
||||
assert info.clients == clients
|
||||
|
||||
|
||||
def test_info_clients_validation():
|
||||
"""Test clients parameter validation during initialization."""
|
||||
with pytest.raises(AssertionError):
|
||||
Info('test-app', 3, clients='invalid')
|
||||
|
||||
clients = [{
|
||||
'name': 'test',
|
||||
'platforms': [{
|
||||
'type': 'web',
|
||||
'url': 'test-url'
|
||||
}]
|
||||
}]
|
||||
Info('test-app', 3, clients=clients)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user