Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore case of sysname in IP device info #3277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3262.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore case of sysname in IP device info
6 changes: 3 additions & 3 deletions python/nav/web/ipdevinfo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def get_netbox(name=None, addr=None):
if name:
try:
if is_valid_ip(name, strict=True):
netbox = netboxes.get(Q(sysname=name) | Q(ip=name))
netbox = netboxes.get(Q(sysname__iexact=name) | Q(ip=name))
else:
netbox = netboxes.get(sysname=name)
netbox = netboxes.get(sysname__iexact=name)
except Netbox.DoesNotExist:
pass
elif addr:
Expand All @@ -178,7 +178,7 @@ def get_netbox(name=None, addr=None):
for address in host_information['addresses']:
if 'name' in address:
try:
netbox = netboxes.get(sysname=address['name'])
netbox = netboxes.get(sysname__iexact=address['name'])
break # Exit loop at first match
except Netbox.DoesNotExist:
pass
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/web/ipdevinfo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ def test_device_details_should_include_sysname(client, netbox):
assert netbox.sysname in smart_str(response.content)


def test_device_details_should_match_sysname_case_insensitively(client, netbox):
url = reverse('ipdevinfo-details-by-name', args=(netbox.sysname.upper(),))
response = client.get(url)
assert netbox.sysname in smart_str(response.content)


def test_port_search_should_match_case_insensitively(client, netbox):
ifc = netbox.interfaces.all()[0]
url = reverse(
Expand Down
Loading