Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil: Use the verb 'assert' instead of 'confirm']
[sunil: More documentation for base app tests class]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
[fioddor: squash create and remove commits as parts of the same move]
Reviewed-by: Fioddor Superconcentrado <fioddor@gmail.com>
- Maintain consistency with rest of the apps and do what the user will mostly
expect.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Fioddor Superconcentrado <fioddor@gmail.com>
This is an improvement over !2069, which solved #2094.
Tests:
- Install an app. Success result is shown.
- Install an app and kill the apt-get process in the middle. Error result is
shown.
- Click install on an app (email_server). Close the window without seeing the
result. Access the app page (like email_server/my_aliases) as a non-admin user.
No success/file message is shown. The page is shown properly. Access the page as
admin, success message is shown.
- Access an uninstalled/installed app page as anonymous user. User is redirected
to login page.
- Access an uninstalled/installed app page as non-admin user. Forbidden page is
shown.
- Access an uninstalled app page meant for non-admin users (such as
email_server/my_aliases) as non-admin user. Forbidden page is shown.
- Access an installed app page as admin. Success.
- Access an installed app page meant for non-admin users (such as
email_server/my_aliases) as admin. Success.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Fioddor Superconcentrado <fioddor@gmail.com>
→ Overall exposure level for tt-rss.service: 1.1 OK 🙂
Tests:
- Run ./setup.py install. systemctl daemon-reload. Subscribe to a new feed and
don't wait for it load the feed. Then start/restart the daemon. The daemon
successfully fetches the feed. When tt-rss interface is loaded again the feed
items are available.
- For getting output of the daemon add StandardOutput=journal option to the
service file.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Sometimes when postgres is not available, the daemon fails to create a
database connection. In this case the daemon permanently exits with code 101
instead of trying again.
- This happens more prominently when booting the system and postgres may not be
available. Although tt-rss.service has Wants= and After= on postgres.service, it
appears that postgres does not have proper startup notification with systemd.
- This may also happen in other situations such as when temporarily restarting
postgres during upgrades or backup/restore operations.
- Fix the issue by make the daemon restart after a failure. This seems
appropriate because the daemon is coded like a web page to fail and exit on
all, even temporary, errors.
Tests:
- Without the patch, stop postgres@13-main.service. Start tt-rss.service. It
will fail permanently and not try to restart.
- With the patch, daemon-reload systemd. Notice that the intended changes
reflect with systemd status. Start the service. It fails. But retries 2 minutes
later with failure again. When postgres is started again, the next attempt
succeeds.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Avoid flake8 warnings.
- Makes the call more explicitly readable in case an exception is expected but
check=True is not passed by mistake.
Tests:
- Many tests are skipped since the changes are considered trivial.
check=False is already the default for subprocess.run() method.
- actions/package: Install an app when it is not installed.
- actions/upgrade: Run manual upgrades.
- actions/users: Change a user password. Login. Create/remove a user.
- actions/zoph: Restore a database.
- container: On a fresh repository, run ./container up,ssh,stop,destroy for a
testing container.
- plinth/action_utils.py: Enable/disable an app that has a running service.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
Bullseye and higher has version 239 or higher.
Tests:
- From performance app, launch the web interface in a testing container. Web
interface shows up properly.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
Warn of installed conflicting packages before installing apps.
[sunil: Rename 'advice' to 'action']
[sunil: Action will be string constant, for better API and i18n]
[sunil: Don't show conflict warning if action is 'ignore']
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Functions needed to spot and remove installed conflicting packages
before installation of apps.
- Remove all packages in a single operation as this way apt can search for
solutions to conflicts more easily.
- Use type hints rather than a lot of type checking. Type hints shall later be
enforced using offline checking (with mypy) or at runtime (with enforce, etc.).
Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
[sunil: Run single remove operation on all packages]
[sunil: Use type hints instead of extensive type checking]
[sunil: Trim down the test case as it would only succeed after install]
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
package
- Create the 'heavy' mark for tests that take long to run.
- Skip the tests marked as 'heavy' by default.
- Enable functional and heavy tests by setting the environment variable
EXTENDED_TESTING=1.
- Update HACKING.md accordingly.
Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
[sunil: Minor indentation]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
- The method to check if we are running inside a container is not being called.
Call it.
- Also fix the assumption that tests and freedombox service run on the same
machine. Be conservative and assume running in container if we can't determine
the accurate state.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Fioddor Superconcentrado <fioddor@gmail.com>
Close: #1982.
This eliminates the issue with calibre and wordpress services getting run even
before the app is installed. These services are enabled when the app is
installed. On disadvantage is that services are no longer restarted when a newer
service file is installed.
Users for whom caibre and wordpress have already been enabled. Nothing changes
on upgrade and service will still be enabled. However, the services won't be
attempted to be started without the app's being installed. This is good enough
without having to write custom logic to disable these services.
Tests:
- Install freedombox package on a fresh setup. wordpress and calibre service
files are not enabled.
- When wordpress and calibre apps are installed, these services are enabled and
run as expected.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- This avoids attempting to run the service soon after FreedomBox is installed.
Tests:
- When old freedombox.deb is installed, the service is enabled. When upgraded to
newer .deb with the changes, the service is still enabled but no start attempt
is made by systemd.
- After installation of calibre, the service is running as expected.
- On a fresh installation, calibre service is working as expected.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- This avoids attempting to run the service soon after FreedomBox is installed.
Tests:
- When old freedombox.deb is installed, the service is enabled. When upgraded to
newer .deb with the changes, the service is still enabled but no start attempt
is made by systemd.
- After installation of WordPress, the service is running as expected.
- On a fresh installation, WordPress service is working as expected.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This is now the preferred location in Debian. See:
https://lintian.debian.org/tags/systemd-service-in-odd-locationhttps://bugs.debian.org/992465https://bugs.debian.org/987989d70caa69c6https://lists.debian.org/debian-devel/2021/08/msg00275.html
Tests:
- Lintian no longer shows errors:
E: freedombox: systemd-service-in-odd-location lib/.../calibre-server-freedombox.service
- Comparing the old .deb and newly generated .deb with these changes. All the
systemd files show that they are moved from /lib to /usr/lib/systemd.
- After upgrading the deb from older version to a version these changes,
services installed by the package are available (tested after restart with
wordpress and claibre). Services tweaked by the package have the changed
configuration reflected as shown by systemctl show
{service-name}.service (tested after restart with quassel).
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
Django 3.0 will now always set the language cookie. It will stop setting the
session language in Django 4.0. To avoid breaking current behavior, always set
the language cookie when switching language.
"To limit creation of sessions and hence favor some caching strategies,
django.views.i18n.set_language() will stop setting the user’s language in the
session in Django 4.0. Since Django 2.1, the language is always stored in the
LANGUAGE_COOKIE_NAME cookie."
Tests:
- All relevant functional tests run.
- Repeat login and user page editing tests.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This patch only ensures that response object is send along with set_language()
call. In later changes, response object can be used by set_language() to set the
language cookie.
Tests:
- Relevant functional tests pass.
- Login, user's language is set when the language is set to non-browser sent
language.
- Logout, user's language is retained when set to non-browser sent language.
- Login, user's language is set when the language is set to browser sent
language.
- Logout, user's language is retained when set to browser sent language.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This patch only ensures that response object is send along with set_language()
call. In later changes, response object can be used by set_language() to set the
language cookie.
Tests:
- Relevant functional tests pass.
- Edit current user's language. The language is immediately set.
- Edit another user's language. The language of the current session is not changed.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Remove an unnecessary eventually block that's always reaching timeout (30 sec).
- Simplify selection of hamburger menu. The CSS classname used for selection is
the same in buster and bullseye.
- Create a constant for String 'ttrss'
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Invoking pytest from setup.py seems to be deprecated. It offers no real
advantages other than being predictable way of invoking tests for someone who
don't know that we use pytest for testing. Let's rely on our documentation
instead. Further this clears up the need to have setup.cfg.
Tests:
- Build debian package in using pbuilder. Tests are run and succeed during the
build.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Django 3.2 has a argon2 password hashing complexity unsuitable for single
board computers. Choose parameters suitable for Olimex Lime2 boards.
Tests:
- In a browser, login to a user without these changes. Notice the hash
parameters in sqlite3 auth_user table. Login with the changes. Notice that the
hash has been updated with latest has parameters.
- Login in Django 2.2 and Django 3.2. Login succeeds and hash parameters are
updated.
- As measured by the browser. Notice that change in login request time with and
without these changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
- Before Django 3.1, iterating the .choices for a field would yield (id, label)
tuples directly suitable for use with ChoiceFields. From Django 3.1, id is an
instance of ModelChoiceIteratorValue which helps to easily find the model
instance. In most cases, using the proxy works, but in our case, the value is
being hashed. Access the actual value of the field from the object to avoid this
issue.
- Cleanup widget for disabling individual checkboxes in a group
- When a form is submitted, 'disabled' input field is omitted by the browser
irrespective of its value. So, the last admin user, automatically add the
'admin' group to form values.
Tests:
- On Django 2.2 and Django 3.2 access the user edit page. The form should render
as before the change without errors.
- Test with the current user as the last admin user. The 'admin' checkbox should
be read-only.
- Test with the current user not as the last admin user. The 'admin' checkbox
should not be read-only.
- Add/remove non-admin groups and save the current/different user.
- Access the user edit page as non-admin user, the groups should be disabled.
- Give/take admin permission to/from a user other than current user.
- Take admin permission from current user.
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
python3-all:any means that python3 interpreter of any architecture could be used
to build the package. python3-all means that same architecture as the build
process would be needed. This is a stricter restriction and is unnecessary for
the case of freedombox package.
See discussion in: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=995498
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>