36 Commits

Author SHA1 Message Date
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
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
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
cd2b2f5f2c
*: Use django.urls.re_path() instead of its alias url()
- In Django 2.2 django.conf.urls.url() is an alias to django.urls.re_path().

- In Django 4.0, url() function will be removed. On Django 3.2, it throws a
warning that this function will be removed in future.

Tests:

- Run unit tests with Django 3.2 and Django 2.2.

- With Django 3.2 there are no warnings when running unit tests and when running
FreedomBox Service.

- Visit a few affected apps with both Django versions.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-20 16:50:47 -04:00
Sunil Mohan Adapa
28c1d5eda3
web_framework, tests: Workaround captcha 0.5.6 vs. Django 3.2
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-18 08:36:46 -04:00
Sunil Mohan Adapa
a2281aaf07
cfg: Remove comments in test data
The file is not meant for human reading. The comments are already part of the
code.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:01:50 -04:00
Sunil Mohan Adapa
3dfceda785
frontpage: Read from .d files too
Read from following paths:

/etc/freedombox/custom-shortcuts.json
/etc/freedombox/custom-shortcuts.json.d/*.json
/etc/plinth/custom-shortcuts.json
/etc/plinth/custom-shortcuts.json.d/*.json
/var/lib/freedombox/custom-shortcuts.json
/var/lib/freedombox/custom-shortcuts.json.d/*.json
/usr/share/freedombox/custom-shortcuts.json
/usr/share/freedombox/custom-shortcuts.json.d/*.json

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:01:45 -04:00
Sunil Mohan Adapa
aaa306aef5
cfg: Read configuration from .d files and multiple locations
- Read configuration files from three different locations.
/usr/share/freedombox/freedombox.config, /etc/plinth/plinth.config and
/etc/freedombox/freedombox.conf. Later listed has higher priority.

- Provide backward compatibility for /etc/plinth/plinth.config files. With lower
priority than /etc/freedombox but higher priority than /usr/share/.

- Read sorted files from config.d directories with the same suffix as original
configuration file. Parse them by priority. This allows administrator/programs
to drop in configuration bits without worry about editing files.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:01:40 -04:00
Sunil Mohan Adapa
6b1622bcec
cfg: Rename configuration file to freedombox.config
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:01:35 -04:00
Sunil Mohan Adapa
62fc33e12c
cfg: Eliminate the need for 'root' directory in configuration
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:01:31 -04:00
Sunil Mohan Adapa
4263f9e2c8
cfg: Drop the default configuration file
- The configuration module defaults to values in the production configuration
file.

- If the file is found, it is read and the read values overwrite the defaults.
If the file is not found, no error is raised. This allows us to not ship the
configuration file. User may create the configuration if they want to change the
defaults. This eases upgrades when configuration is edited. This also make
FreedomBox robust to deployments where /etc/ is not populated by default such as
OSTree. It is also a good practice for daemons as followed by the likes of
systemd.

- If the file partly populated only the values read override the defaults and
the remaining values don't change. This allows the user to write simpler
configuration file.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:01:15 -04:00
Sunil Mohan Adapa
5a126e62a8
notifications: Fix issue with redirection on dismiss
The request variable is not available when a custom template is used to render a
notification. Fix this by passing the template rendering context additional
request variable.

Closes: #1887.

Tests:

- Reduce the version number in data for 'upgrades-new-release' notification
in the plinth_storednotification table in the DB. Start FreedomBox. New release
message will appear. Go to page other than home page. The dismiss button has
next= parameter filled properly with current URL. Dismiss the notification and
notice that page URL stays the same.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-27 16:03:12 -04:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Sunil Mohan Adapa
2a8c8c42ca
notification: Add tests for notification API
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-02-10 18:13:21 -05:00
Sunil Mohan Adapa
f1c4b2235a
tests: Allow adding test templates
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-02-10 18:13:12 -05:00
Sunil Mohan Adapa
cff9a61f09
pagekite: Remove first wizard step for danube edition
- The code was never used by end users.

- The code was expected to be used long back but the plans didn't materialize.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-10-02 17:21:39 -04:00
Sunil Mohan Adapa
0f807bcd48
sso: Use new features of axes, log axes messages
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-07-21 09:05:58 -04:00
Sunil Mohan Adapa
463c620c65
backups: Remove known_hosts file from config file
- There is no compelling reason to make the file configurable. Simplifies
  configuration file if we make it relative to FreedomBox data directory.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-07-03 12:44:34 +05:30
Joseph Nuthalapati
2c97e1e02e
backups: Read file path of known_hosts directly from plinth.config
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-07-03 12:43:02 +05:30
Joseph Nuthalapati
3a6dcbe7a7
Verify SSH hostkey before mounting
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-07-03 12:42:41 +05:30
Sunil Mohan Adapa
0eee8ddf65
menu: Removed unused templates, methods and properties
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-06-07 11:48:01 -07:00
Sunil Mohan Adapa
9040b26b4e
custom_shortcuts: Fix issue with writing tests as different user
- Don't write to files in test data directory. Instead write to temporary
  directory patch the code to work with the temporary directory. This prevents a
  problem with running tests when the user owning the source directory is not
  the same as the user running the tests.

- Use fixtures.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-05-12 17:12:54 +05:30
Sunil Mohan Adapa
dc9ab52edc
axes: Minor fixes to configuration for IP blocking
- Use the X-Forwarded-For header only if specified in the configuration. This
  makes FreedomBox safe to use when not behind a reverse proxy server (although
  we are unlikely to do this).

- When fetching the IP address to reset after successful login, use the
  X-Forwarded-For header only if specified in the configuration.

- Minor flake8 refactorings.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-01-28 17:17:32 -05:00
Sunil Mohan Adapa
35c70861dc
logging: Remove references to old log files
- Remove access/error log references in configuration files and tests.

- Ensure that /var/log/plinth directory is not created anymore.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-12-30 13:45:23 -05:00
Joseph Nuthalapati
1307e474da
customization: Show custom shortcuts on frontpage
Closes #1379

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-10-08 20:30:29 -04:00
Joseph Nuthalapati
5e06017e5c
customization: Serve custom shortcuts through the REST API
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-10-08 20:30:24 -04:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Joseph Nuthalpati
ab235be2fc
captcha: fix tests failing to start
Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:08:17 -04:00
fonfon
eda3488bea
Updated tests about accessing the setup page
- anonymous users should not be able to access the setup page
- registered should be able to do so
2016-12-28 19:35:11 -05:00
Sunil Mohan Adapa
bbef41af7a Fix missing option in test configuration
Add danube_edition option to the Misc section of the configuration file.
Without this option, this 'missing section' test case will fail with
'missing option' instead of 'missing section'.  Coupled with the
unpredictable order of reading options, this only happens sometimes.
2015-12-05 09:51:50 -05:00
fonfon
125cb88336 Removed cfg.product_name entry and tests
The name 'Plinth' (cfg.product_name) is not used anymore after my previous
commits.
Reason for the complete removal: I do not think that users should know or have
to care about the internal name of the web interface of the FreedomBox.
2015-10-28 19:52:14 -04:00
Sunil Mohan Adapa
cf1bb65a0c tests: Minor styling fixes and updates
- Add module level comments.

- Add comments to reflect docstring styling.

- Since most tests can no longer be run directly, remove __main__
  invocation uniformly from all the tests.

- Remove unnecessary test settings and let them take default values.

- Add license header to test settings module.

- Fix a minor issue actions test tear down.

- Improve key/value store tests.
2015-05-24 12:16:51 +05:30
Bob Girard
c16bff7fec Add plinth/tests/data/__init__.py to fix ImportError 2015-05-23 13:59:49 +05:30
Bob Girard
5cadd223d5 Add support for testing Django-dependent modules
- Add django-test-settings.py for Django settings
- Add runtests.py for setting up Django test environment
- Add Django test setup support to setup.py and coverage.py
- Add new test module test_kvstore.py
- Enable existing Django-dependent tests in test_context_processors.py and test_menu.py
2015-05-23 13:59:49 +05:30
Bob Girard
f184c23c31 Add unit tests (#1)
* Add unit tests for cfg.py, context_processors.py, and menu.py
* Add new plinth/tests/data directory for miscellaneous test data
* In cfg.py, add an explicit check to verify the existence of the secondary
  (non-default) plinth.config file
* In cfg.py, replace deprecated configparser.SafeConfigParser with
  configparser.ConfigParser
2015-01-30 18:11:36 +05:30