mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Fixes #14847: Relax requirement for IKE policy * Docs tweak --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
@ -14,7 +14,7 @@ The IKE version employed (v1 or v2).
|
|||||||
|
|
||||||
### Mode
|
### Mode
|
||||||
|
|
||||||
The IKE mode employed (main or aggressive).
|
The mode employed (main or aggressive) when IKEv1 is in use. This setting is not supported for IKEv2.
|
||||||
|
|
||||||
### Proposals
|
### Proposals
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ class IKEPolicyBulkEditForm(NetBoxModelBulkEditForm):
|
|||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
nullable_fields = (
|
nullable_fields = (
|
||||||
'preshared_key', 'description', 'comments',
|
'mode', 'preshared_key', 'description', 'comments',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +174,8 @@ class IKEPolicyImportForm(NetBoxModelImportForm):
|
|||||||
)
|
)
|
||||||
mode = CSVChoiceField(
|
mode = CSVChoiceField(
|
||||||
label=_('Mode'),
|
label=_('Mode'),
|
||||||
choices=IKEModeChoices
|
choices=IKEModeChoices,
|
||||||
|
required=False
|
||||||
)
|
)
|
||||||
proposals = CSVModelMultipleChoiceField(
|
proposals = CSVModelMultipleChoiceField(
|
||||||
queryset=IKEProposal.objects.all(),
|
queryset=IKEProposal.objects.all(),
|
||||||
|
18
netbox/vpn/migrations/0004_alter_ikepolicy_mode.py
Normal file
18
netbox/vpn/migrations/0004_alter_ikepolicy_mode.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.9 on 2024-01-20 09:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('vpn', '0003_ipaddress_multiple_tunnel_terminations'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ikepolicy',
|
||||||
|
name='mode',
|
||||||
|
field=models.CharField(blank=True),
|
||||||
|
),
|
||||||
|
]
|
@ -79,7 +79,8 @@ class IKEPolicy(PrimaryModel):
|
|||||||
)
|
)
|
||||||
mode = models.CharField(
|
mode = models.CharField(
|
||||||
verbose_name=_('mode'),
|
verbose_name=_('mode'),
|
||||||
choices=IKEModeChoices
|
choices=IKEModeChoices,
|
||||||
|
blank=True
|
||||||
)
|
)
|
||||||
proposals = models.ManyToManyField(
|
proposals = models.ManyToManyField(
|
||||||
to='vpn.IKEProposal',
|
to='vpn.IKEProposal',
|
||||||
@ -109,6 +110,17 @@ class IKEPolicy(PrimaryModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('vpn:ikepolicy', args=[self.pk])
|
return reverse('vpn:ikepolicy', args=[self.pk])
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
super().clean()
|
||||||
|
|
||||||
|
# Mode is required
|
||||||
|
if self.version == IKEVersionChoices.VERSION_1 and not self.mode:
|
||||||
|
raise ValidationError(_("Mode is required for selected IKE version"))
|
||||||
|
|
||||||
|
# Mode cannot be used
|
||||||
|
if self.version == IKEVersionChoices.VERSION_2 and self.mode:
|
||||||
|
raise ValidationError(_("Mode cannot be used for selected IKE version"))
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# IPSec
|
# IPSec
|
||||||
|
@ -305,7 +305,6 @@ class IKEPolicyTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
cls.form_data = {
|
cls.form_data = {
|
||||||
'name': 'IKE Policy X',
|
'name': 'IKE Policy X',
|
||||||
'version': IKEVersionChoices.VERSION_2,
|
'version': IKEVersionChoices.VERSION_2,
|
||||||
'mode': IKEModeChoices.AGGRESSIVE,
|
|
||||||
'proposals': [p.pk for p in ike_proposals],
|
'proposals': [p.pk for p in ike_proposals],
|
||||||
'tags': [t.pk for t in tags],
|
'tags': [t.pk for t in tags],
|
||||||
}
|
}
|
||||||
@ -313,9 +312,9 @@ class IKEPolicyTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
ike_proposal_names = ','.join([p.name for p in ike_proposals])
|
ike_proposal_names = ','.join([p.name for p in ike_proposals])
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
"name,version,mode,proposals",
|
"name,version,mode,proposals",
|
||||||
f"IKE Proposal 4,2,aggressive,\"{ike_proposal_names}\"",
|
f"IKE Proposal 4,1,main,\"{ike_proposal_names}\"",
|
||||||
f"IKE Proposal 5,2,aggressive,\"{ike_proposal_names}\"",
|
f"IKE Proposal 5,1,aggressive,\"{ike_proposal_names}\"",
|
||||||
f"IKE Proposal 6,2,aggressive,\"{ike_proposal_names}\"",
|
f"IKE Proposal 6,2,,\"{ike_proposal_names}\"",
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.csv_update_data = (
|
cls.csv_update_data = (
|
||||||
@ -327,7 +326,7 @@ class IKEPolicyTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
'version': IKEVersionChoices.VERSION_2,
|
'version': IKEVersionChoices.VERSION_1,
|
||||||
'mode': IKEModeChoices.AGGRESSIVE,
|
'mode': IKEModeChoices.AGGRESSIVE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user