416 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
6c3b2e1f82
package: Prevent freedombox's deps from removal during app uninstall
- If an app declares dependency on package that is also a dependency for
freedombox, then during the app's uninstall, the dependency is attempt to be
removed and will fail (because freedombox package will be held state).

- Add freedombox (and thus its dependencies) to the list packages that should be
removed from list of packages to be removed during app uninstall.

- In test case, update list of packages attempted removal as the 'freedombox'
package is installed only in some environments.

Tests:

- Uninstall janus works. Log messages show that libjs-bootstrap5 and
node-popper2 are in the list of packages originally set to removed during app
uninstall but are later filtered out.

- Run pytest with 'freedombox' package installed and ensure all tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-17 13:03:06 -05:00
Sunil Mohan Adapa
743b7bd163
ttrss: Remove app not available in Trixie
Tests:

- Running 'make build install' remove the module loading include file for ttrss.

- TT-RSS is no longer available in apps page.

- Installing Tor works. Onion header is set correctly. Re-running app setup
works.

- RSS Bridge's description is updated as expected. Links work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-10 19:20:33 -05:00
Sunil Mohan Adapa
f9ca06dc5f
daemon: When ensuring running state handle not-installed state
Tests:

- Uninstall miniflux and postgresql. Install freshly with all the patches in
this series. When installing miniflux freshly, postgresql is not disabled soon
after miniflux package is installed. Without this patch, postgresql is disabled
after packages are installed leading to a setup failure.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-10-05 10:39:15 -04:00
Sunil Mohan Adapa
7f608cd570
*: Collect output for all privileged sub-processes
- Now that we have a mechanism for properly collecting, transmitting, and display
the stdout and stderr. There is no reason not to collect all of the stdin and
stderr.

- Also, the stdin/stderr=subprocess.PIPE is redundant and prevents the output
from getting collected for debugging. So, remove it.

Tests:

- Ran functional tests on backups, calibre, ejabberd, email, gitweb, ikiwiki,
infinoted, kiwix, mediawiki, mumble, nextcloud,, openvpn, samba, wireguard,
zoph. 2-3 issues were found but did not seem like new errors.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:57 +03:00
Sunil Mohan Adapa
61ff15a04f
*: Use action_utils.run instead of subprocess.run
- This is to capture stdout and stderr and transmit that from privileged daemon
back to the service to be displayed in HTML.

Tests:

- Unit tests and code checks pass.

- Some of the modified actions work as expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:53 +03:00
Sunil Mohan Adapa
0661d7da7c
app: Add ability to retrieve logs from all systemd units of an app
Tests:

- Upto 200 lines are shown in the logs. The description and unit name of the app
is correct.

- Apps without systemd units don't have 'View Logs' menu item.

- Nextcloud container logs are shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-18 16:35:23 +03:00
Sunil Mohan Adapa
d8c727a109
package: Don't consider uninstalled packages as available
- Ensure that packages that are not installable to negative priority are not
shown as available.

Tests:

- Set priority of an available package to less than 0. This package will be
shown as not-available in the app install page.

- Normal apps are shown as available and can be installed as usual.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-08 19:33:52 -04:00
Sunil Mohan Adapa
866daf27ef
package: Refresh apt cache if sources list is newer
- When backports repository or unstable repository freshly added by the updates
app. We will like apps to become available due to newly available Debian
packages. For this to happen 'apt update' must be called before checking if an
app is available.

Tests:

- Freshly apply the patches for upgrades app. Setup is re-run and unstable
sources file is introduced. Immediately visit the Matrix app and notice that is
shown as available and can be installed immediately.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-08 19:33:48 -04:00
Sunil Mohan Adapa
0c6f04b55f
actions, backups: Fix tests depending on sudo based actions
Tests:

- Mounting/unmounting of remote SSH repositories works.

- Creating repo, creating/deleting/list archives work.

- If a privileged method raises an exception after outputting to stdout (using
action_utils.run) then stdout is shown in the HTML UI message.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:24:10 +05:30
Sunil Mohan Adapa
944c427f44
actions: Framework for capturing stdout/stderr in privileged daemon
Tests:

- If there is a syntax error in communication with privileged server. 'stdout'
and 'stderr' keys are present in 'exception' dictionary of the reply.

- If there is a error in the privileged method in communication with privileged
server. 'stdout' and 'stderr' keys are present in 'exception' dictionary of the
reply. The values are filled with output of the command that have been run.

- If a privileged method uses action_utils.run, then raising an exception in the
method shows proper stdout and stderr in the UI HTML message.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:23:55 +05:30
Sunil Mohan Adapa
de1070df35
action_utils: Implement a utility to run a command as different user
- To be used to run specific command as another user.

Tests:

- Unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:22:00 +05:30
Sunil Mohan Adapa
a0b2625c6a
tests: functional: Fix incorrect skipping of install tests
Fixes: #2529.

Tests:

- Run functional tests on bepasty. Without the patch, many tests are skipped.
With the patch, all tests are executed. Introducing a sleep delay in
Package.is_available() method also works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-08-21 10:59:10 +03:00
Sunil Mohan Adapa
a70611a2e9
tests: Ensure that privileged daemon is not used during tests
- Fallback to sudo based privileged implementation. Privileged daemon tests are
still to be implemented.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-08-16 22:42:15 +05:30
Sunil Mohan Adapa
acd2f515d7
package: Refresh apt cache if old and some packages are not found
Fixes: #1358

- Refresh the apt cache if required packages for an app are not found and if the
cache is more than 1 hour old (or non-existent).

- If required packages are found, don't refresh the package cache even if the
cache is outdated. This is because the check operation could lead to many
minutes of waiting before app can be installed.

Tests:

- Remove /var/lib/apt/lists/* and /var/cache/apt/pkgcache.bin. Visit an app
setup page. apt cache is updated and it take a while to check that the app is
available. App is shown as available. If page is refreshed, this time, the cache
is not updated.

- Set the modification of /var/cache/apt/pkgcache.bin file to more than 2 hours
ago with 'touch -d "2 hours ago" /var/cache/apt/pkgcache.bin'. Then refreshing
the page will not refresh the cache.

- Repeat test with an app that is not available such as Janus. Again apt cache
is refreshed. App is shown as not available. On refresh, the cache is not
updated.

- Set the modification of /var/cache/apt/pkgcache.bin file to more than 2 hours
ago with 'touch -d "2 hours ago" /var/cache/apt/pkgcache.bin'. Then refreshing
the page will not refresh the cache.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>

- Remove redundant if condition in setup.html template
- Use JavaScript fetch() API instead of XMLHTTPRequest class
- Update a comment in test_package.py
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-08-02 21:06:33 +05:30
Sunil Mohan Adapa
1f98dfcad1
setup: Perform a check for app availability after the page loads
- Using AJAX request instead of loading the initial page slowly.

Tests:

- Unit tests passes.

- Deluge app is not available in bookworm and is available in Trixie.

- When app is available, no message is shown. Install button is enabled.

- When app is not available a proper warning alert message is shown. Install
button is disabled.

- During check for the availability, the progress message is shown. Install
button is disabled.

- When Javascript is disabled on the page, no availability check is performed.
Install button is enabled.

- When an exception is raised in the is-available view, error message is shown.
Install button is enabled.

- When is-available view return HTML response, error message is shown. Install
button is enabled.

- When is-available view invalid JSON response, error message is shown. Install
button is enabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-08-02 21:06:17 +05:30
Sunil Mohan Adapa
cc0a02ad1c
config: Allow overriding target path in dropin config component
- To be used when configuration has to change based on the package version.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-07-20 07:54:02 -07:00
Joseph Nuthalapati
efbf2a80f5
notifications: Fix setting last_update_time
The field last_update_time is set to auto_now in the Django model, but it is not
being updated when using update_or_create() since Django 4.2. This is because it
sends update_fields= argument to save().

Say, a user installed an app a few hours ago and uninstalls it now, the
notification should be updated to show the uninstallation status but it shows
the timestamp of the installation instead.

Explicitly setting the updated timestamp is one way of fixing this issue.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Use django_db mark in test case]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-07-10 16:05:47 -07:00
Sunil Mohan Adapa
5b0d980035
container: Add component for managing containers using podman
Tests:

- Unit tests work.

- Enabling/disabling an app works.

- Developer documentation shows the Container in reference section.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-05-30 15:14:12 -04:00
Sunil Mohan Adapa
16f90d863b
action_utils: Allow checking result for service operations
Tests:

- Functional tests for bepasty, nextcloud, torproxy app work.

- Adding/removing a domains works.

- After first setup, nscd service is masked.

- Re-run setup on miniflux app works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-05-30 15:14:10 -04:00
Sunil Mohan Adapa
3b1eba216a
uninstall: Use reverse order when uninstalling components
Tests:

- Functional tests for bepasty app work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-05-30 15:13:59 -04:00
Sunil Mohan Adapa
97bae21e65
package: Allow app to say it wants to rerun setup after updates
Tests:

- Unit tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-04-04 21:34:40 -04:00
Sunil Mohan Adapa
70ed89eff9
tests: django: Fix a warning related timezone settings
The warning is:

RemovedInDjango50Warning: The default value of USE_TZ will change from False to
True in Django 5.0. Set USE_TZ to False in your project settings if you want to
keep the current default behavior.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-03-28 21:26:43 -04:00
James Valleroy
c7673e039d
tests: functional: Add enable-all-apps script
[sunil]

- Move the script to plinth/tests/functional directory as it is the right place
for it.

- Add HACKING.md entry to talk about the script.

- Update the pyproject.toml to ensure that functional tests config.ini is
installed along with functional tests python code.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-03-24 15:15:01 -07:00
Sunil Mohan Adapa
863d170219
names: Allow adding multiple static domain names
- Change the mechanism for storing domain names in /etc/hosts. Don't write
hostname to /etc/hosts. Don't prepend hostname to domain name. This means that
when hostname changes, set_domain_name need not be called.

- This means that domain names such as example.fbx.one were not resolvable using
/etc/hosts but these will now resolve to 127.0.1.1. This is a minor concern to
becoming a breaking change.

- Don't use socket.getfqdn() for finding the domain name of the machine. Instead
read from /etc/hosts. There does not seem to a glibc/python API for querying
domain names from /etc/hosts with all variations it allows. Forward resolution
properly works no matter the library.

- Drop a pre-Python 3 conversion from unicode to ascii string for hostname. This
is no longer relevant.

- Domain name form is now domain add form. Passing domain name is mandatory.
Domain delete form and view have been introduced.

- Use augeas to edit hosts file. Add privileged methods to add/delete/get
domains. Add method to migration from old format to new. Support reading old
format too in get_domains.

Tests:

- Without hostname written in /etc/hosts, 'resolvectl query <hostname>' and
'ping <hostname>' work.

- With old /etc/hosts format apply patches and restart service. It will be
converted to new format.

- Adding a domain adds a new line to /etc/hosts file. The domain is shown in
domains list in Names app. Applications get reconfigured with the new domain
name.

- Deleting a domain adds a new line to /etc/hosts file. The domain is shown in
domains list in Names app. Applications get reconfigured with the new domain
name.

- Restarting app triggers domain added signal for all domains and all the
domains are shown in the Names app.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:50 -05:00
Benedek Nagy
6887c960fe
sogo: Add a new app for SOGo groupware
SOGo is an open source webmail client and groupware available in Debian.
Make a new FreedomBox app for it to be used with the local
Postfix/Dovecot email server.

SOGo requires a database to store events/tasks as well as user settings. Memcached
is also required for caching.

Users log in with their username (as opposed to username + domain on
Roundcube). The host header seen from the first login will be
associated with the user profile. So, if a user logs into SOGo from
freedombox.local and later configures the email server to use
example.com, they will manually have to edit their account(s) to show
the updated domain.

Authentication is done via openldap. It is possible to authenticate with
apache, however it is limited to http basic auth, so mod_auth_tkt cannot
be used. See: b40d777a86/SoObjects/SOGo/SOGoProxyAuthenticator.m (L137)
Configuring http basic auth in my opinion wouldn't add much to
the user experience. It would actually take away the usage of SOGO's built
in TOTP feature.

SOGo only accepts configurations from /etc/sogo/sogo.conf, other configs
from sogo.d don't get recognised.

Use the sogo icon from upstream source. Update sogo.png and sogo.svg to be the
same image (but resized) that is provided in the upstream source. The previous
image was download from Wikimedia Commons.

Update smtp settings so that messages can be sent

Test result for mail deliverability sent with SOGo: https://www.mail-tester.com/test-pdf2yzy6n

The result shows that the message is not DKIM signed. This seems to be
an issue not specific to SOGo. Mails sent from Thunderbird don't get
signed either.

Tests:
- Install app and log in with a FreedomBox user. Create a new event
  titled "Lunch with 🍕 and fries". Confirm the pizza character displays properly.
- Backup the app and uninstall it.
- Restore from the backup, log in and confirm the event gets restored.

To-do:
- test ActiveSync
- create a fail2ban jail
- include the icons in the copyright file
- test sending email in a production setup
- test sieve filters
- write tests

https://salsa.debian.org/freedombox-team/freedombox/-/issues/56

[Sunil]

- App:

  - Update icons to be uniform size as all other apps and copyright information.

  - Since SOGo is not configured to trust the authentication from Apache, it
  does not require FirewallLocalProtection. Remove it.

  - Expand app description. Talk about Email Server app.

  - Update to match recent tags related changes.

  - Make memcached a shared daemon as other processes might use it.

  - Added shared daemon for PostgreSQL.

  - Don't start services when rerunning setup if the app is currently disabled.

  - Don't restart memcached during a restore operation.

- Security:

  - Add system security restrictions to the daemon.

  - Don't use fail2ban jail. SOGo has a mechanism to lock users for a few
  minutes. Use that instead.

- Apache:

  - Make /.well-known URLs work by moving their definitions to global section.

  - Remove old (<2.4) Apache authorization keywords.

  - Simplify, indentation, new line at EOF.

- Manifest:

  - Add more tags.

  - Add SOGo connector, DAVx5, and GNOME Calendar to list of clients.

  - Add 'sogo' to list of service to bring down during backup/restore.

- Privileged:

  - Switch from MySQL to PostgreSQL as it is recommended by SOGo.

  - Use existing utility to generate database password.

  - Use plget and plmerge utilities from gnustep-common package to parse/edit
  the configuration instead of augeas which don't have a dedicated lens.

  - Don't reset the domain when rerunning setup.

  - Ensure that the configuration file has proper ownership and permissions even
  when it did not exist previously.

  - Add typing information for most methods.

  - Remove configuration file after uninstall.

- Configuration:

  - Define database URLs for all seven database tables.

  - Set calendar default roles as suggested in the installation guide.

  - Refresh view automatically every minute to check for new mail.

  - Use the mechanism to lock account after failed login attempts.

  - Add folder name for Junk folder too explicitly.

- Tests: Add basic functional tests.

Tests:

- Functional tests work.

- Rerunning setup does not change the domain back to the primary domain of the
email server.

- Login works. Sending mail and reading mail works. Creating calendar events and
contact works.

- Changing the domain sets the domain value properly in the configuration file.
Configured domain is shown properly on the form.

- Backup and restore work as expected.

- When configuration file is removed and setup is re-run, then the file is
created with proper ownership and permissions.

- 'systemd-analyze security sogo.service' shows a good score.

Signed-off-by: Benedek Nagy <contact@nbenedek.me>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-01-26 10:50:28 -05:00
Sunil Mohan Adapa
89bce7a344
app: Add tags to menu and frontpage components
- Add typing information for init methods Info, Shortcut, and Menu to easily
  identify problems.

- Update docstrings for these components.

- Updates test cases to deal with tags instead of short description.

- Update custom shortcuts code to read tags and ignore short description.

- Update API to send tags instead of custom shortcuts.

- OpenVPN special treatment of info.description in Shortcut

Tests:

- All unit tests pass and type checking succeeds.

- All apps show icons with tags in apps and system section.

- In help section cards don't show tags.

- In front page, enabled apps show shortcuts with tags.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-01-09 21:08:10 +05:30
Veiko Aasa
fdde1cd40b
tests: functional: Fix typos in diagnostics checks
Signed-off-by: Veiko Aasa <veiko17@disroot.org>
2024-12-29 17:17:14 +02:00
Sunil Mohan Adapa
26d317bfd5
middleware: Handle page not found errors specially
- Show a different message for them.

Test:

- Try to visit page like /plinth/apps/sharing/foo/edit/ where a share named
'foo' does not exist. The common error handling middleware is triggered and an
alert message 'Page not found' with exception trace back is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-29 17:16:48 +02:00
Sunil Mohan Adapa
38829a3cfa
middleware: Handle method not allowed errors and redirect
- These could happen when a user tries to reload a page that only allows POST
requests.

- Or when the generic exception handling logic in the middleware redirects the
user to a page that only allows POST.

Tests:

- Insert a exception in the diagnose() of the 'users' app. Without the patch,
running diagnostics on the users app leads to a blank page. With the patch, the
user is redirected to Diagnostics app page and the original error is shown as a
alert message.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-29 17:16:23 +02:00
Sunil Mohan Adapa
407fccba2f
ui: Handle and show most page load errors as alerts
- In addition to the OperationalError, also handle all generic exceptions during
page submit and page load. Redirect to the same page or parent using
breadcrumbs.

- Log exceptions handled by common error middleware so that they are also part
of the system logs.

- Update kiwix test as needed.

- Refactor some test code that is setting up the menu items.

Tests:

- When an error occurs during form POST, the same page is show but with an error
message.

- When an error occurs in an app page during GET, the browser is redirected to
the parent section.

- When an error occurs in apps page during GET, the browser is redirected to the
home page.

- When an error occurs in home page during GET, the error is not handled and
default 500 handle is triggered.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-29 17:16:06 +02:00
Veiko Aasa
2ae0f19417
tests: functional: Add utility to click element wait for page update
Also, add a click_link_by_href helper function.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Update some more cases to use the utility function]
[sunil: Keep click() and rename new behavior to click_and_wait()]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-12-27 16:43:27 -08:00
Sunil Mohan Adapa
36c4bc30fb
context_processors: Use breadcrumbs to highlight current section
- We were using hacky logic of assuming that if a page using the URL
/plinth/sys/..., then it belongs to 'system' section based on the URL match.
This won't work when the URL does not follow this pattern for any reason.

- Instead use the breadcrumbs mechanism which uses menu items and URL names to
determine the section a page belongs to.

Tests:

- Visit page, apps page, system page, help pages, an app page in apps sections,
an app page in system section, backups -> create backup page and notice that the
correct section is highlighted.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-25 12:24:29 +02:00
Sunil Mohan Adapa
a29fb97dd9
views: Implement retrieving breadcrumbs of a page
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-25 12:23:52 +02:00
Sunil Mohan Adapa
86031d25f1
menu: Implement a helper method to lookup menu items using URL name
- This will used to create breadcumbs.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-25 12:23:16 +02:00
Sunil Mohan Adapa
0d9bd8d23e
tests: functional: Make first wizard run more robust
- If for some reason, first setup is not completed yet, wait for it to complete.

- Update eventually() method to wait for page load errors to go away.

- If first wizard is already completed, don't try to run it again.

- We can eventually remove waiting for 'setup thread finished' in container
script. But not there yet.

Tests:

- Run transmission tests on a freshly created container.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-17 22:07:38 +02:00
Sunil Mohan Adapa
765e3176fa
diagnostics: tests: functional: Pick errors more specifically
- When notifications badge is present in navigation bar, that could be confused
for a diagnostics failure. Make the diagnostics failure selector more specific
to avoid this.

- This was caused because of removing .badge-warning/error classes in favor of
.text-bg-warning/danger classes.

Tests:

- Enable ejabberd app and use 'systemctl stop ejabberd.service'. Run system-wide
diagnostics to see a notification with error it and error badge on the
notification icon. Then run functional tests on transmission app which includes
diagnostic tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-12 13:05:12 +02:00
Sunil Mohan Adapa
a4017b2bf2
ui: Restyle tags, remove underlining of text
- Tags have important text that is too small and could cause problems with users
with limited vision. Make them regular buttons. Make the buttons shorter and
rounder to resemble previous styling.

- Drop underlining of text in the process.

- In code, don't call them 'badges' anymore.

Tests:

- Run functional tests for tags.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-12 12:56:37 +02:00
Sunil Mohan Adapa
4d71e80b1e
ui: Drop use of badge-* utility classes for newer replacements
- Keep the badge-{severity} classes as they are meant for convenience of mapping
severity to style.

- Match bootstrap colors to maintain consistency and contrast.

Tests:

- Visually confirm that all the changes effective.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-12 12:30:28 +02:00
Veiko Aasa
41675eec39
tests: functional: Fix app installation test skipped on slow machines
Fixes an issue where after clicking an app install button (that disables the
button), the app uninstall test is skipped because "App not available in
distribution".

Wait until the app install submit button is not present on the page after
clicking the install button.

Test performed:
 - Increased sleep time to 10s in SetupView. The sharing app uninstall
 functional test pass.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Use wait_for_page_update() instead of eventually]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-12-11 12:32:12 -08:00
Veiko Aasa
b3f82974f0
tests: functional: Don't try disable app after tests if app was not installed
Fixes an issue where app tests teardown fails if app installation fails
or app is not available for distribution.

Tests:
 - On Debian Bookworm, all miniflux functional tests are skipped and
   there are no errors.
 - After running gitweb metadata functional test, the app is disabled.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-12-05 11:38:38 -08:00
Veiko Aasa
50cedaf528
tags: tests: Fix deprecated webdriver attribute
Fixes errors in functional tests:
`AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'`

Tests:
  - All tags tests pass.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-11-28 11:13:45 -08:00
Sunil Mohan Adapa
a32a226492
tests: functional: Fix visit() returning prematurely before page load
- It appears from the functional tests run in Gitlab CI pipelines that visit()
is returning before the page has loaded fully. In the screenshots for help app
test failures, we see gitweb web page.

- To fix this, wait for a proper page load in visit().

- Cleanup syntax, rename the non-existent search class, and mechanism for
matching expected URLs.

- Also refactor waiting for uninstall page in uninstall() method. Using the
wait_for_page_update() method as context processor is more accurate.

Tests:

- Run all functional tests and ensure that there are no errors in visit()
method.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-11-09 08:14:51 +02:00
Sunil Mohan Adapa
63ada3ee62
tests: functional: Don't enable/disable app during tests
- Currently, after every test we disable the app and re-enable for the next
test. The original purpose of this disabling is to make sure that an app is
disabled after test on it. So, change the scope of disabling the app to ensure
that it is only disabled once after all the tests on the app. This should
improve the run time of the tests.

Tests:

- Run functional tests on bepasty app.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-11-08 10:30:55 +02:00
Sunil Mohan Adapa
3807ee4c54
tests: functional: Wait for uninstall page load before uninstalling
- Many functional test failures in the Gitlab CI pipeline show that uninstall
form was attempted to submitted while still in the app page. After clicking on
the uninstall menu item, we are not waiting for the page to load fully. Fix this
by waiting for page load. This change is expected to fix most of the functional
tests failures in the pipeline.

Tests:

- Ran bepasty functional tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-11-07 10:07:12 +02:00
Sunil Mohan Adapa
bfdb05bf0d
networks: Fix editing wireless connections with SSID field
Fixes: #2447.

- When editing an existing wireless connection, SSID field shows as "b'myap'"
instead of "myap". Fix this.

Tests:

- On a machine with a wireless connection, edit the connection. Without the
patch, form show SSID incorrectly. With the patch, it shows the correct value.

- Unit tests in test_network.py pass when run as root.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-11-07 08:39:56 +02:00
Sunil Mohan Adapa
d85105a428
middleware: tests: Drop some obsolete mock code
- setup_helper was removed long ago.

Tests:

- Re-run unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
[vexch: Removed unused global variable setup_helper]
Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-28 09:40:49 +02:00
Veiko Aasa
b67ce15f89
functional tests: Add pytest testinfra plugin
Adds ability to run local commands with functional tests.

By default, commands are run locally. It is possible to set remote
host connection parameters from pytest command line, for example:
`--hosts 'fbx@IP' --ssh-identity-file '.container/ssh/id_ed25519'`

For more options, see documentation
https://testinfra.readthedocs.io/en/latest/backends.html#ssh.

Includes a fixture `host_sudo` to run commands as sudo.

Relates to
https://salsa.debian.org/freedombox-team/freedombox/-/issues/2451#note_530752.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-10-23 21:24:28 -07:00
Veiko Aasa
f12e634bc9
users: Delete or move home folder when user is deleted or renamed
On user deletion, user's home folder is also deleted. Admins have an
option to avoid deleting user's home by inactivating the user instead.

This commit also removes user deletion buttons from the user's list
page and adds this option to the user edit page. The user's edit form
asks for a confirmation if the user deletion is requested. This change
also means that the confirmation password is now required to delete a user.

Also:
  - Add a simple username validation to the privileged actions.
  - Functional tests: Create a fixture to login as an admin before every test.
  - Functional tests: Add a test to check that SSH passwordless login works
    after user is renamed to validate correct SSH related path permissions.
  - Privileged tests: Add `test_` prefix to the generated random string which
    makes easier to check and cleanup created home folders.
  - Minor quote fixes.

Tests performed in stable and testing containers:
  - Run all the users module tests twice, no failures in tests.
  - When user is the last admin, both "Active" and "Delete user"
    checkboxes are disabled.

Closes #2451.

[sunil]

- Refactor the JS code:

  - Ensure that DOM elements are lookup after DOM content is loaded.

  - Styling changes. Reduce the number of globals, name the global names
  somewhat more unique.

  - Click the button instead of submitting the form to disable the button.

- Template changes:

  - Add a body for the confirmation dialog to talk about disabling the user and
  deleting the home directory.

  - Change the label of the confirm button to make it more
  explicit (recommendation from many UX guides).

  - Styling.

- Functional tests:

  - Fix visibility checking of an element to use the correct splinter API.

  - Simplify clicking the edit user link.

- Minor update to form checkbox help text.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-10-23 21:13:25 -07:00
Sunil Mohan Adapa
9459ef4be4
middleware: Show translated error messages when operation completes
Tests:

- Change locale to Spanish. Raise an exception in bepasty.privileged.setup().
Try to install bepasty. Without the patch, error is not translated. With the
patch, it is.

- Successful installation of an app shows translated success message.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-10-21 12:47:10 -04:00
Sunil Mohan Adapa
fbed7e93e8
operation: Use safe formatter for translating messages
- When an app install fails, there is a small chance that the failure message is
show in the area where operation spinner is shown. If that happens,
operation.translated_message is accessed from the HTML template. This throws an
exception if the error message that made contains excepted formatting keys.
Example:
"{include_once("/var/www/html/config/config.php");print($CONFIG["dbpassword"] ??
""); }".

- Also change the formatting key {exception_message} to {exception} as this
would help in translation when Notification is shown which has {exception} as
data dictionary value.

Tests:

- In the operation update message such as 'Installing app', insert unexpected
formatting strings. 'Installing app {foo}'. Notice the error without the patch
and how the patch fixes it.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-10-21 12:47:08 -04:00