networks: Fix error during creation of PPPoE connections

- Currently, when trying to create PPPoE connection, we get an exception that
dns_over_tls key is not found in the form's cleaned_data. Fix this by not
expecting the field to be present only for PPPoE connections.

Tests:

- Edit a regular Ethernet connection and change the value of DNS-over-TLS to all
the different values and notice that the value is updated as expected.

- Create a regular Ethernet connection with non-default value for DNS-over-TLS.
The value for DNS-over-TLS on the connection set as expected.

- Create/edit/delete of a PPPoE connection works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-12-29 14:41:30 -08:00 committed by James Valleroy
parent e20e27c0fd
commit c4b21b014b
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -195,12 +195,16 @@ class ConnectionForm(forms.Form):
'name': self.cleaned_data['name'],
'interface': self.cleaned_data['interface'],
'zone': self.cleaned_data['zone'],
'dns_over_tls': self.cleaned_data['dns_over_tls'],
}
settings['common'] |= self.get_privacy_settings()
settings['ipv4'] = self.get_ipv4_settings()
settings['ipv6'] = self.get_ipv6_settings()
return settings
def get_privacy_settings(self) -> dict[str, object]:
"""Return privacy dict from cleaned data."""
return {'dns_over_tls': self.cleaned_data['dns_over_tls']}
def get_ipv4_settings(self):
"""Return IPv4 dict from cleaned data."""
ipv4 = {
@ -290,6 +294,10 @@ class PPPoEForm(EthernetForm):
}
return settings
def get_privacy_settings(self) -> dict[str, object]:
"""Return privacy dict from cleaned data."""
return {}
def get_ipv4_settings(self):
"""Return IPv4 settings from cleaned data."""
return None