1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #9177: Add tenant assignment for wireless LANs & links

This commit is contained in:
jeremystretch
2022-06-27 11:30:52 -04:00
parent f6c52e0616
commit 7dd5f9e720
21 changed files with 265 additions and 83 deletions

View File

@@ -1,10 +1,11 @@
from django.urls import reverse
from wireless.choices import *
from wireless.models import *
from dcim.choices import InterfaceTypeChoices
from dcim.models import Interface
from tenancy.models import Tenant
from utilities.testing import APITestCase, APIViewTestCases, create_test_device
from wireless.choices import *
from wireless.models import *
class AppTest(APITestCase):
@@ -52,6 +53,12 @@ class WirelessLANTest(APIViewTestCases.APIViewTestCase):
@classmethod
def setUpTestData(cls):
tenants = (
Tenant(name='Tenant 1', slug='tenant-1'),
Tenant(name='Tenant 2', slug='tenant-2'),
)
Tenant.objects.bulk_create(tenants)
groups = (
WirelessLANGroup(name='Group 1', slug='group-1'),
WirelessLANGroup(name='Group 2', slug='group-2'),
@@ -71,21 +78,25 @@ class WirelessLANTest(APIViewTestCases.APIViewTestCase):
{
'ssid': 'WLAN4',
'group': groups[0].pk,
'tenant': tenants[0].pk,
'auth_type': WirelessAuthTypeChoices.TYPE_OPEN,
},
{
'ssid': 'WLAN5',
'group': groups[1].pk,
'tenant': tenants[0].pk,
'auth_type': WirelessAuthTypeChoices.TYPE_WPA_PERSONAL,
},
{
'ssid': 'WLAN6',
'tenant': tenants[0].pk,
'auth_type': WirelessAuthTypeChoices.TYPE_WPA_ENTERPRISE,
},
]
cls.bulk_update_data = {
'group': groups[2].pk,
'tenant': tenants[1].pk,
'description': 'New description',
'auth_type': WirelessAuthTypeChoices.TYPE_WPA_PERSONAL,
'auth_cipher': WirelessAuthCipherChoices.CIPHER_AES,
@@ -115,10 +126,16 @@ class WirelessLinkTest(APIViewTestCases.APIViewTestCase):
]
Interface.objects.bulk_create(interfaces)
tenants = (
Tenant(name='Tenant 1', slug='tenant-1'),
Tenant(name='Tenant 2', slug='tenant-2'),
)
Tenant.objects.bulk_create(tenants)
wireless_links = (
WirelessLink(ssid='LINK1', interface_a=interfaces[0], interface_b=interfaces[1]),
WirelessLink(ssid='LINK2', interface_a=interfaces[2], interface_b=interfaces[3]),
WirelessLink(ssid='LINK3', interface_a=interfaces[4], interface_b=interfaces[5]),
WirelessLink(ssid='LINK1', interface_a=interfaces[0], interface_b=interfaces[1], tenant=tenants[0]),
WirelessLink(ssid='LINK2', interface_a=interfaces[2], interface_b=interfaces[3], tenant=tenants[0]),
WirelessLink(ssid='LINK3', interface_a=interfaces[4], interface_b=interfaces[5], tenant=tenants[0]),
)
WirelessLink.objects.bulk_create(wireless_links)
@@ -127,15 +144,18 @@ class WirelessLinkTest(APIViewTestCases.APIViewTestCase):
'interface_a': interfaces[6].pk,
'interface_b': interfaces[7].pk,
'ssid': 'LINK4',
'tenant': tenants[1].pk,
},
{
'interface_a': interfaces[8].pk,
'interface_b': interfaces[9].pk,
'ssid': 'LINK5',
'tenant': tenants[1].pk,
},
{
'interface_a': interfaces[10].pk,
'interface_b': interfaces[11].pk,
'ssid': 'LINK6',
'tenant': tenants[1].pk,
},
]