mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-15 19:52:52 -06:00
parent
d5c1cb0ef6
commit
d930c4e36e
@ -50,7 +50,7 @@ class WebhookFilterSet(NetBoxModelFilterSet):
|
||||
model = Webhook
|
||||
fields = [
|
||||
'id', 'name', 'payload_url', 'http_method', 'http_content_type', 'secret', 'ssl_verification',
|
||||
'ca_file_path',
|
||||
'ca_file_path', 'description',
|
||||
]
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
|
@ -182,18 +182,21 @@ class WebhookTestCase(TestCase, BaseFilterSetTests):
|
||||
payload_url='http://example.com/?1',
|
||||
http_method='GET',
|
||||
ssl_verification=True,
|
||||
description='foobar1'
|
||||
),
|
||||
Webhook(
|
||||
name='Webhook 2',
|
||||
payload_url='http://example.com/?2',
|
||||
http_method='POST',
|
||||
ssl_verification=True,
|
||||
description='foobar2'
|
||||
),
|
||||
Webhook(
|
||||
name='Webhook 3',
|
||||
payload_url='http://example.com/?3',
|
||||
http_method='PATCH',
|
||||
ssl_verification=False,
|
||||
description='foobar3'
|
||||
),
|
||||
Webhook(
|
||||
name='Webhook 4',
|
||||
@ -211,13 +214,17 @@ class WebhookTestCase(TestCase, BaseFilterSetTests):
|
||||
Webhook.objects.bulk_create(webhooks)
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'Webhook 1'}
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Webhook 1', 'Webhook 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_http_method(self):
|
||||
params = {'http_method': ['GET', 'POST']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
@ -276,6 +283,7 @@ class EventRuleTestCase(TestCase, BaseFilterSetTests):
|
||||
type_job_start=False,
|
||||
type_job_end=False,
|
||||
action_type=EventRuleActionChoices.WEBHOOK,
|
||||
description='foobar1'
|
||||
),
|
||||
EventRule(
|
||||
name='Event Rule 2',
|
||||
@ -287,6 +295,7 @@ class EventRuleTestCase(TestCase, BaseFilterSetTests):
|
||||
type_job_start=False,
|
||||
type_job_end=False,
|
||||
action_type=EventRuleActionChoices.WEBHOOK,
|
||||
description='foobar2'
|
||||
),
|
||||
EventRule(
|
||||
name='Event Rule 3',
|
||||
@ -298,6 +307,7 @@ class EventRuleTestCase(TestCase, BaseFilterSetTests):
|
||||
type_job_start=False,
|
||||
type_job_end=False,
|
||||
action_type=EventRuleActionChoices.WEBHOOK,
|
||||
description='foobar3'
|
||||
),
|
||||
EventRule(
|
||||
name='Event Rule 4',
|
||||
@ -329,10 +339,18 @@ class EventRuleTestCase(TestCase, BaseFilterSetTests):
|
||||
event_rules[3].content_types.add(content_types[3])
|
||||
event_rules[4].content_types.add(content_types[4])
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Event Rule 1', 'Event Rule 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_content_types(self):
|
||||
params = {'content_types': 'dcim.region'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
@ -669,12 +669,16 @@ class VirtualDiskTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
VirtualMachine.objects.bulk_create(vms)
|
||||
|
||||
disks = (
|
||||
VirtualDisk(virtual_machine=vms[0], name='Disk 1', size=1, description='A'),
|
||||
VirtualDisk(virtual_machine=vms[1], name='Disk 2', size=2, description='B'),
|
||||
VirtualDisk(virtual_machine=vms[2], name='Disk 3', size=3, description='C'),
|
||||
VirtualDisk(virtual_machine=vms[0], name='Disk 1', size=1, description='foobar1'),
|
||||
VirtualDisk(virtual_machine=vms[1], name='Disk 2', size=2, description='foobar2'),
|
||||
VirtualDisk(virtual_machine=vms[2], name='Disk 3', size=3, description='foobar3'),
|
||||
)
|
||||
VirtualDisk.objects.bulk_create(disks)
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_virtual_machine(self):
|
||||
vms = VirtualMachine.objects.all()[:2]
|
||||
params = {'virtual_machine_id': [vms[0].pk, vms[1].pk]}
|
||||
@ -691,5 +695,5 @@ class VirtualDiskTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['A', 'B']}
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
@ -62,7 +62,7 @@ class TunnelFilterSet(NetBoxModelFilterSet, TenancyFilterSet):
|
||||
|
||||
class Meta:
|
||||
model = Tunnel
|
||||
fields = ['id', 'name', 'tunnel_id']
|
||||
fields = ['id', 'name', 'tunnel_id', 'description']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
@ -139,7 +139,7 @@ class IKEProposalFilterSet(NetBoxModelFilterSet):
|
||||
|
||||
class Meta:
|
||||
model = IKEProposal
|
||||
fields = ['id', 'name', 'sa_lifetime']
|
||||
fields = ['id', 'name', 'sa_lifetime', 'description']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
@ -167,7 +167,7 @@ class IKEPolicyFilterSet(NetBoxModelFilterSet):
|
||||
|
||||
class Meta:
|
||||
model = IKEPolicy
|
||||
fields = ['id', 'name', 'preshared_key']
|
||||
fields = ['id', 'name', 'preshared_key', 'description']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
@ -189,7 +189,7 @@ class IPSecProposalFilterSet(NetBoxModelFilterSet):
|
||||
|
||||
class Meta:
|
||||
model = IPSecProposal
|
||||
fields = ['id', 'name', 'sa_lifetime_seconds', 'sa_lifetime_data']
|
||||
fields = ['id', 'name', 'sa_lifetime_seconds', 'sa_lifetime_data', 'description']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
@ -214,7 +214,7 @@ class IPSecPolicyFilterSet(NetBoxModelFilterSet):
|
||||
|
||||
class Meta:
|
||||
model = IPSecPolicy
|
||||
fields = ['id', 'name']
|
||||
fields = ['id', 'name', 'description']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
@ -253,7 +253,7 @@ class IPSecProfileFilterSet(NetBoxModelFilterSet):
|
||||
|
||||
class Meta:
|
||||
model = IPSecProfile
|
||||
fields = ['id', 'name']
|
||||
fields = ['id', 'name', 'description']
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
|
@ -24,6 +24,10 @@ class TunnelGroupTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
TunnelGroup(name='Tunnel Group 3', slug='tunnel-group-3'),
|
||||
))
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Tunnel Group 1']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
@ -96,7 +100,8 @@ class TunnelTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
group=tunnel_groups[0],
|
||||
encapsulation=TunnelEncapsulationChoices.ENCAP_GRE,
|
||||
ipsec_profile=ipsec_profiles[0],
|
||||
tunnel_id=100
|
||||
tunnel_id=100,
|
||||
description='foobar1'
|
||||
),
|
||||
Tunnel(
|
||||
name='Tunnel 2',
|
||||
@ -104,7 +109,8 @@ class TunnelTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
group=tunnel_groups[1],
|
||||
encapsulation=TunnelEncapsulationChoices.ENCAP_IP_IP,
|
||||
ipsec_profile=ipsec_profiles[0],
|
||||
tunnel_id=200
|
||||
tunnel_id=200,
|
||||
description='foobar2'
|
||||
),
|
||||
Tunnel(
|
||||
name='Tunnel 3',
|
||||
@ -112,11 +118,16 @@ class TunnelTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
group=tunnel_groups[2],
|
||||
encapsulation=TunnelEncapsulationChoices.ENCAP_IPSEC_TUNNEL,
|
||||
ipsec_profile=None,
|
||||
tunnel_id=300
|
||||
tunnel_id=300,
|
||||
description='foobar3'
|
||||
),
|
||||
)
|
||||
Tunnel.objects.bulk_create(tunnels)
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Tunnel 1', 'Tunnel 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
@ -147,6 +158,10 @@ class TunnelTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
params = {'tunnel_id': [100, 200]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
|
||||
class TunnelTerminationTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
queryset = TunnelTermination.objects.all()
|
||||
@ -292,7 +307,8 @@ class IKEProposalTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
encryption_algorithm=EncryptionAlgorithmChoices.ENCRYPTION_AES128_CBC,
|
||||
authentication_algorithm=AuthenticationAlgorithmChoices.AUTH_HMAC_SHA1,
|
||||
group=DHGroupChoices.GROUP_1,
|
||||
sa_lifetime=1000
|
||||
sa_lifetime=1000,
|
||||
description='foobar1'
|
||||
),
|
||||
IKEProposal(
|
||||
name='IKE Proposal 2',
|
||||
@ -300,7 +316,8 @@ class IKEProposalTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
encryption_algorithm=EncryptionAlgorithmChoices.ENCRYPTION_AES192_CBC,
|
||||
authentication_algorithm=AuthenticationAlgorithmChoices.AUTH_HMAC_SHA256,
|
||||
group=DHGroupChoices.GROUP_2,
|
||||
sa_lifetime=2000
|
||||
sa_lifetime=2000,
|
||||
description='foobar2'
|
||||
),
|
||||
IKEProposal(
|
||||
name='IKE Proposal 3',
|
||||
@ -308,15 +325,24 @@ class IKEProposalTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
encryption_algorithm=EncryptionAlgorithmChoices.ENCRYPTION_AES256_CBC,
|
||||
authentication_algorithm=AuthenticationAlgorithmChoices.AUTH_HMAC_SHA512,
|
||||
group=DHGroupChoices.GROUP_5,
|
||||
sa_lifetime=3000
|
||||
sa_lifetime=3000,
|
||||
description='foobar3'
|
||||
),
|
||||
)
|
||||
IKEProposal.objects.bulk_create(ike_proposals)
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['IKE Proposal 1', 'IKE Proposal 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_authentication_method(self):
|
||||
params = {'authentication_method': [
|
||||
AuthenticationMethodChoices.PRESHARED_KEYS, AuthenticationMethodChoices.CERTIFICATES
|
||||
@ -380,16 +406,19 @@ class IKEPolicyTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
name='IKE Policy 1',
|
||||
version=IKEVersionChoices.VERSION_1,
|
||||
mode=IKEModeChoices.MAIN,
|
||||
description='foobar1'
|
||||
),
|
||||
IKEPolicy(
|
||||
name='IKE Policy 2',
|
||||
version=IKEVersionChoices.VERSION_1,
|
||||
mode=IKEModeChoices.MAIN,
|
||||
description='foobar2'
|
||||
),
|
||||
IKEPolicy(
|
||||
name='IKE Policy 3',
|
||||
version=IKEVersionChoices.VERSION_2,
|
||||
mode=IKEModeChoices.AGGRESSIVE,
|
||||
description='foobar3'
|
||||
),
|
||||
)
|
||||
IKEPolicy.objects.bulk_create(ike_policies)
|
||||
@ -397,10 +426,18 @@ class IKEPolicyTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
ike_policies[1].proposals.add(ike_proposals[1])
|
||||
ike_policies[2].proposals.add(ike_proposals[2])
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['IKE Policy 1', 'IKE Policy 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_version(self):
|
||||
params = {'version': [IKEVersionChoices.VERSION_1]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
@ -429,29 +466,40 @@ class IPSecProposalTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
encryption_algorithm=EncryptionAlgorithmChoices.ENCRYPTION_AES128_CBC,
|
||||
authentication_algorithm=AuthenticationAlgorithmChoices.AUTH_HMAC_SHA1,
|
||||
sa_lifetime_seconds=1000,
|
||||
sa_lifetime_data=1000
|
||||
sa_lifetime_data=1000,
|
||||
description='foobar1'
|
||||
),
|
||||
IPSecProposal(
|
||||
name='IPSec Proposal 2',
|
||||
encryption_algorithm=EncryptionAlgorithmChoices.ENCRYPTION_AES192_CBC,
|
||||
authentication_algorithm=AuthenticationAlgorithmChoices.AUTH_HMAC_SHA256,
|
||||
sa_lifetime_seconds=2000,
|
||||
sa_lifetime_data=2000
|
||||
sa_lifetime_data=2000,
|
||||
description='foobar2'
|
||||
),
|
||||
IPSecProposal(
|
||||
name='IPSec Proposal 3',
|
||||
encryption_algorithm=EncryptionAlgorithmChoices.ENCRYPTION_AES256_CBC,
|
||||
authentication_algorithm=AuthenticationAlgorithmChoices.AUTH_HMAC_SHA512,
|
||||
sa_lifetime_seconds=3000,
|
||||
sa_lifetime_data=3000
|
||||
sa_lifetime_data=3000,
|
||||
description='foobar3'
|
||||
),
|
||||
)
|
||||
IPSecProposal.objects.bulk_create(ipsec_proposals)
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['IPSec Proposal 1', 'IPSec Proposal 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_encryption_algorithm(self):
|
||||
params = {'encryption_algorithm': [
|
||||
EncryptionAlgorithmChoices.ENCRYPTION_AES128_CBC, EncryptionAlgorithmChoices.ENCRYPTION_AES192_CBC
|
||||
@ -501,15 +549,18 @@ class IPSecPolicyTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
ipsec_policies = (
|
||||
IPSecPolicy(
|
||||
name='IPSec Policy 1',
|
||||
pfs_group=DHGroupChoices.GROUP_1
|
||||
pfs_group=DHGroupChoices.GROUP_1,
|
||||
description='foobar1'
|
||||
),
|
||||
IPSecPolicy(
|
||||
name='IPSec Policy 2',
|
||||
pfs_group=DHGroupChoices.GROUP_2
|
||||
pfs_group=DHGroupChoices.GROUP_2,
|
||||
description='foobar2'
|
||||
),
|
||||
IPSecPolicy(
|
||||
name='IPSec Policy 3',
|
||||
pfs_group=DHGroupChoices.GROUP_5
|
||||
pfs_group=DHGroupChoices.GROUP_5,
|
||||
description='foobar3'
|
||||
),
|
||||
)
|
||||
IPSecPolicy.objects.bulk_create(ipsec_policies)
|
||||
@ -517,10 +568,18 @@ class IPSecPolicyTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
ipsec_policies[1].proposals.add(ipsec_proposals[1])
|
||||
ipsec_policies[2].proposals.add(ipsec_proposals[2])
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['IPSec Policy 1', 'IPSec Policy 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_pfs_group(self):
|
||||
params = {'pfs_group': [DHGroupChoices.GROUP_1, DHGroupChoices.GROUP_2]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
@ -596,27 +655,38 @@ class IPSecProfileTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
name='IPSec Profile 1',
|
||||
mode=IPSecModeChoices.ESP,
|
||||
ike_policy=ike_policies[0],
|
||||
ipsec_policy=ipsec_policies[0]
|
||||
ipsec_policy=ipsec_policies[0],
|
||||
description='foobar1'
|
||||
),
|
||||
IPSecProfile(
|
||||
name='IPSec Profile 2',
|
||||
mode=IPSecModeChoices.ESP,
|
||||
ike_policy=ike_policies[1],
|
||||
ipsec_policy=ipsec_policies[1]
|
||||
ipsec_policy=ipsec_policies[1],
|
||||
description='foobar2'
|
||||
),
|
||||
IPSecProfile(
|
||||
name='IPSec Profile 3',
|
||||
mode=IPSecModeChoices.AH,
|
||||
ike_policy=ike_policies[2],
|
||||
ipsec_policy=ipsec_policies[2]
|
||||
ipsec_policy=ipsec_policies[2],
|
||||
description='foobar3'
|
||||
),
|
||||
)
|
||||
IPSecProfile.objects.bulk_create(ipsec_profiles)
|
||||
|
||||
def test_q(self):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['IPSec Profile 1', 'IPSec Profile 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_description(self):
|
||||
params = {'description': ['foobar1', 'foobar2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
def test_mode(self):
|
||||
params = {'mode': [IPSecModeChoices.ESP]}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
Loading…
Reference in New Issue
Block a user