17 Commits

Author SHA1 Message Date
Veiko Aasa
e9f9d33abc
samba: tests: Fix enable share view test
Closes #2327.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2023-02-26 19:07:20 +05:30
Sunil Mohan Adapa
d4b21ef1e4
views: Use dedicated view when showing an app with operations
Closes: #2309.

- This prevents processing of AppView when the app is being uninstalled. For at
least two apps, this has failed because the AppView assumes that app and its
dependencies are installed.

- Use a dedicated template as well is simplify app template.

Tests:

- Installing and uninstalling an app works.

- Refreshing the app page during uninstall does not lead to an error for samba
and email apps.

- Unit tests pass.

- Functional tests for samba and email work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-01-30 20:08:11 -05:00
Sunil Mohan Adapa
49e4ebf8f9
samba: Use privileged decorator for actions
Tests:

- Functional tests work (uninstall fails)
- Initial setup works
  - File /etc/default/samba is updated
- Dump and restore share during backup/restore works
  - Setup run successfully during restore
  - /var/lib/plinth/backups-data/samba-shares-dump.conf
- Adding/deleting a share works
  - Not tested: Add a share on ntfs or vfat file system works
- Showing list of shares in app view works
- Getting list of samba users in app view works
- Handling errors during add/delete share works

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:53:47 -04:00
Veiko Aasa
78a2b26132
samba: Fix functional tests when user is not logged in at start
Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-04-26 11:19:29 -07:00
James Valleroy
a27333c0b3
samba: Use BaseAppTests for functional tests
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-11-08 11:51:36 -08:00
Sunil Mohan Adapa
a3e21adc8b
*: Various isort fixes
- Done automatically by running isort . in top level directory.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-20 16:50:37 -04:00
Veiko Aasa
e31053eb92
samba: tests: Convert functional tests to non-BDD python format
- Also, fix an issue where share writability tests were performed always as an admin user.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-09-18 17:05:08 -07:00
Veiko Aasa
fcc4a933d2
Samba: UI: Show toggle buttons and share names
Closes #1989

I checked that all Samba tests pass.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Minor indentation and styling fixes in template]
[sunil: Prevent multiple HTML attributes with same name in case of vfat]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-11-30 13:27:50 -08:00
Sunil Mohan Adapa
7fbc9fc625
samba: cosmetic: Minor yapf fixes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-07-21 17:16:14 -07:00
Veiko Aasa
31eb35cb9e
samba: Hide common system partitions
Hide some common partitions where users shouldn't create a share -
/.snapshots, /boot and /boot/firmware.

Tested that mount points 'boot' and '.snapshots' do not appear in the
list of shareable disks on Pioneer Freedombox.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Add /boot/efi to list of ignored mount points]
[sunil: Update test to check if mounts points are ignored]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-07-21 17:14:43 -07:00
Sunil Mohan Adapa
10b46f1968
storage: Use UDisks information as primary source
Rename get_disks() to get_mounts() and use it in for backups and samba shares.

Create a new get_disks() similar to get_mounts() but use df information only for
showing free space. This inverts the importance of 'df' and UDisks. Use UDisks
as primary source of information for showing list of disks and then use df to
fill in the free space information.

- Retrieve all the mount points of a device and return them as part of
get_disks() in an extra 'mount_points' property.

- For storage listing, this fixes showing up of /.snapshots as separate disk and
showing of vboxsf, network mounts etc. Only shows mounts that are related to
block devices.

- Update various uses of get_disks() within storage module to use
'mounts_points' instead of 'mount_point' to be accurate in cases where there are
multiple mounts for a given device. Use get_mounts() where appropriate instead.

- Display all the mount points against a devices in multiple lines.

- Also show devices that are not currently mounted.

Tests performed:

- Filling up a disk shows a disk space warning properly. Warning contains the
  free disk space correctly.

- Calling get_root_device(get_disks()) return the correct root device.

- In Deluge, the download directory contains a list of all samba current shares.
  If a disk with samba share is unmouted, it does not show up in the list.

- In the Samba app page, all disks are shown properly. Root disk is shown as
  'disk'. All other mount points such as .snapshots and /vagrant also show up.

- In the Samba app page, unavailable shares list shows up when a disk with a
  share is unmounted.

- Upload a backup, warning on the form shows available disk space properly.

- When adding a backup location. The list includes all mount points. Duplicated
  mount points are not shown. Root disk is not shown in the list. When all the
  disks are used up for backup location, a warning that no additional disks are
  available is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-24 07:23:29 -04:00
Sunil Mohan Adapa
80dff7bf9c
tests: functional: Re-organize step definitions and helper methods
- Move non-reusable app specific step definitions and helper methods into
<app>/tests/test_functional.py.

- Merge reusable helper methods into plinth.tests.functional

- Merge reusable step definitions into plinth.tests.functional.step_definitions

- avahi, datetime, ikiwiki: Reuse common methods to avoid repetition. Avoid
mapping from app nicknames to actual app names.

- deluge, transmission: Make a copy of sample.torrent for each app to avoid
clogging common place.

- Implement functional.visit() to simplify a lot of browser.visit() calls.

- Ensure that name of the mark on functional tests for an app is same as name of
the app. This will help with predicting the mark when running tests for a
particular app.

Tests performed:

- Run all functional tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2020-05-22 22:52:40 +05:30
Sunil Mohan Adapa
80d67c2054
tests: functional: Merge into main source hierarchy
- Add pytest hooks to ignore all functional tests if pytest_bdd is not
installed.

- Update pytest hooks to skip tests in file named 'test_functional.py' if
--include-functional argument is not provided.

- Move functional_tests/install.py into plinth/tests/functional and update
reference in Vagrantfile.

- Move scenario files into individual app folders. Rename them after the app
they are testing. Merge TODO items listed in todo.org into corresponding feature
files.

- Add test_functional.py in each app to build tests from the features file using
pytest_bdd.

- Move all step_definitions, support and data into plinth/tests/functional/.
Include all step_definitions from conftest.py. Update to relative imports
instead of absolute imports.

Tests performed:

- Run py.test-3 --collect-only shows all functional tests and lists 574 tests.
No errors show that name of feature files are correct. The number says that all
functional test features are included.

- Remove pytest_bdd (or modify the import name) and run py.test-3 --collect-only
skips collecting all functional tests and shows only 300+ tests.

- Run functional tests for a few apps with py.test-3 --include-functional -m
app. For storage, deluge.

- Run unit tests with py.test-3. Functional tests are listed by skipped.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2020-05-22 21:26:05 +05:30
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Veiko Aasa
0f16a0fbee
storage: Show disks if FreedomBox is running in an unprivileged container
- Get disks info from df command and add info from udisks, if available.
  Before, it was other way round.
- Add a functional test that asserts root disk is available
- Remove unused key file_system_type from disks info

Closes #1765

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-02-02 09:40:12 -05:00
Veiko Aasa
3a202af843
samba: Add unit and functional tests
- Add functional tests
- Add unit tests for samba views
- New dependency for running functional tests: smbclient
- Make port configurable for the smbclient

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2020-01-17 02:47:06 +05:30
Veiko Aasa
eaaa764387
samba: Users can enable a guest share
Related to  #1681

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-01 11:30:25 -05:00