29 Commits

Author SHA1 Message Date
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
2abf2dc88c
networks: Add support for DNS-over-TLS for individual connections
- Expose Network Manager per-connection setting for DNS-over-TLS. Support all
four values: default, no, opportunistic, and yes.

- Create a new collapsible section all 'Privacy' for this setting the connection
create/edit form. Strictly speaking this is related to security and censorship
resistance too.

- Don't show the DoT field for PPPoE connection types are DNS servers are not
relevant.

- Show the status of DoT for a connection in the connection status page.

Tests:

- In all Add New Connection forms except PPPoE form, the privacy
section shows up as expected.

- For each value for DoT, create a new connection and set the value for DoT to the
desired value and observe that the connection status page shows DoT to the set
value.

- For each value for DoT, edit an existing connection and set the value for the
DoT to the desired value and observe that the connection status page shows DoT
to the set value.

- Connection status page shows the values for DoT as expected.

- Update the primary Internet connection for the machine. Set the value to 'yes'
and notice that DNS resolutions fail. Set the value to 'opportunistic' or 'no'
and the DNS resolutions pass. In each case, 'resolvectl' shows the correct DoT
value for the connection. When 1.1.1.1 is set as DNS server, all values of DoT
in the connection succeed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-07 12:23:07 +03:00
Fioddor Superconcentrado
7ee2b385c9
network: Minor refactoring in a test
Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-25 15:40:35 -08:00
Sunil Mohan Adapa
86829a29c1
network: test: Fix race condition when deleting connections
When deleting connections after editing, sometimes the connection is not found.
Wait until the connection settles down to avoid connection not found errors
during cleanup. Seems to work for now but still not the best way to handle this.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:02: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
42569d75ec
network: Allow setting the auto-connect property on a connection
Also don't require updating all the common properties of a connection when
updating only some properties such as 'autoconnect'.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-01-18 13:52:30 -05:00
Sunil Mohan Adapa
4ad3a9ee8f
networks: Fix crashing when accessing network manager D-Bus API
Network Manager client fetches the basic information from Network Manager,
caches it and updates the cache whenever it receives the signal. So, create only
a single instance of it and reuse it. Reusing from different threads is
apparently fine because the underlying DBusConnection is a singleton[1] that is
meant to be used from multiple threads.

The glib main loop context that is related to the client must run even after the
network manager client object goes away[2]. So, create the network manager
client instance from a thread that continues to run the glib main thread.

This fixes an infrequent crash when accessing network manager page. The problem
was reproducible from very early version of Network Manager and FreedomBox.
However, in more recent versions of NetworkManager 1.20 with recent DBus changes
in FreedomBox, the problem is more prominent. The problem reduces to a simple
warning in NetworkManager 1.22.

Closes: #1724
Closes: #382

Tests:

- Reproduce the problem by accessing the networks app index page repeatedly.

- Create a simple test case file to reproduce the problem and ensure that the
  fix works there.

- On Network Manager 1.20 repeatedly access the networks app index page and
  create/delete/activate/deactivate/show connections.

- On Network Manager 1.22 repeatedly access the networks app index page and
  create/delete/activate/deactivate/show connections.

Links:

1) https://developer.gnome.org/gio/unstable/GDBusConnection.html#g-bus-get-sync

2) https://developer.gnome.org/libnm/stable/NMClient.html#nm-client-get-main-context

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-01-13 17:22:39 -05:00
Alice Kile
eb83e00011
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-07 13:08:35 -05:00
Nikolas Nyby
ace339eabf
Introduce flake8 checking - #58
This introduces flake8 and fixes a bunch of flake8 errors.

flake8 is run with: ./venv/bin/flake8 plinth
if you're using a python3 venv.

We can eventually further integrate this with gitlab ci.

https://salsa.debian.org/freedombox-team/plinth/issues/58

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-07-24 14:01:54 -07:00
Sunil Mohan Adapa
67539e05fc
network: Convert tests to pytest style
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-05-12 17:16:39 +05:30
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
Vignan Lavu
beb74526f3
networks: Fix failing network test 2017-04-10 14:58:23 +05:30
Sunil Mohan Adapa
dce51fd6d7
networks: Support configuring IPv6 networks
- Very similar to configuration of IPv4 networks.

- Supports 'auto', 'dhcp', 'manual' and 'ignored' modes as supported by
  network manager.  'shared' mode is not yet implemented by network
  manager.
2016-10-01 07:09:03 -04:00
Nikhil Rayaprolu
c0dc3ec8ca
modified network tests 2016-07-24 09:26:40 -04:00
Sunil Mohan Adapa
082c5ee1ce
networks: Minor trimming to tests
- To focus only on what is being tested.
2016-02-09 09:35:14 +05:30
James Valleroy
1851b15836
networks: Fix tests, move settings to a dict 2016-02-09 09:35:01 +05:30
Sunil Mohan Adapa
0280d22c12 networks: Update tests for setting manual address 2015-12-23 10:09:49 +05:30
James Valleroy
1927eac06c Update network tests to work with added parameters. 2015-12-22 16:21:45 -05:00
Sunil Mohan Adapa
1e10fb76fc networks: Add test case for PPPoE
- Update ethernet and Wi-Fi tests to make sure interface name is
  properly set.
2015-08-22 20:18:51 +05:30
James Valleroy
e060960fed Also add IPv4 manual address test for wifi. 2015-07-29 22:29:01 -04:00
James Valleroy
110d50d7e2 Make separate network test for IPv4 manual address. 2015-07-29 21:56:24 -04:00
James Valleroy
6c06799320 Specify interfaces for network tests where needed. 2015-07-29 21:38:20 -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
James Valleroy
b00a634647 Update network tests, minor fixes to network.py.
Return UUID when adding a connection.
Have get_connection raise an exception instead of returning None.
2015-05-16 15:39:26 -04:00
Sunil Mohan Adapa
13e0707b09 network: Skip network tests when running as non-root 2015-04-06 23:11:26 +05:30
Sunil Mohan Adapa
f00f65f484 network: Update tests to work with UUIDs and add a few more checks 2015-04-06 22:21:29 +05:30
James Valleroy
2441caf647 Add AP and adhoc wifi modes, and shared IPv4 addressing mode. 2015-04-06 22:21:29 +05:30
James Valleroy
8d9b388375 Fix network tests, add form help and validator. 2015-04-06 22:21:29 +05:30
James Valleroy
9b201a2daf Rename network module to networks.
Move networkmanager helper functions into a new file.
Add some network tests.
2015-04-06 22:21:28 +05:30