-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
205 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from nav.enterprise.ids import VENDOR_ID_H3C | ||
from nav.models.manage import NetboxType | ||
|
||
|
||
class TestNetboxType(object): | ||
def test_get_enterprise_id_returns_correctly_for_sysobjectid_with_leading_period( | ||
self, | ||
): | ||
sysobjectid = ".1.3.6.1.4.1.25506.1.517" | ||
netbox_type = NetboxType( | ||
vendor_id="hp", | ||
name="A5120-48P-EI-2", | ||
description="HP Procurve A5120 V2", | ||
sysobjectid=sysobjectid, | ||
) | ||
|
||
assert netbox_type.get_enterprise_id() == VENDOR_ID_H3C | ||
|
||
def test_get_enterprise_id_returns_correctly_for_sysobjectid_without_leading_period( | ||
self, | ||
): | ||
sysobjectid = "1.3.6.1.4.1.25506.1.517" | ||
netbox_type = NetboxType( | ||
vendor_id="hp", | ||
name="A5120-48P-EI-2", | ||
description="HP Procurve A5120 V2", | ||
sysobjectid=sysobjectid, | ||
) | ||
|
||
assert netbox_type.get_enterprise_id() == VENDOR_ID_H3C | ||
|
||
def test_get_enterprise_id_returns_none_for_sysobjectid_of_wrong_format( | ||
self, | ||
): | ||
sysobjectid = "abc" | ||
netbox_type = NetboxType( | ||
vendor_id="hp", | ||
name="A5120-48P-EI-2", | ||
description="HP Procurve A5120 V2", | ||
sysobjectid=sysobjectid, | ||
) | ||
|
||
assert netbox_type.get_enterprise_id() is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from mock import Mock | ||
from twisted.names import dns | ||
|
||
from nav.asyncdns import ForwardResolver | ||
|
||
BUICK_NAME = "buick.lab.uninett.no" | ||
|
||
|
||
def test_forward_lookup_should_work_with_ipv4_results(): | ||
record = Mock() | ||
record.name = BUICK_NAME | ||
record.type = dns.A | ||
record.payload.address = b"\xac\x00\x00\x01" | ||
result = [[record]] | ||
result_name, address_list = ForwardResolver._extract_records(result, BUICK_NAME) | ||
|
||
assert result_name == BUICK_NAME | ||
assert address_list == ["172.0.0.1"] | ||
|
||
|
||
def test_forward_lookup_should_work_with_ipv6_results(): | ||
record = Mock() | ||
record.name = BUICK_NAME | ||
record.type = dns.AAAA | ||
record.payload.address = b" \x01\r\xb833DDUUffww\x88\x88" | ||
result = [[record]] | ||
result_name, address_list = ForwardResolver._extract_records(result, BUICK_NAME) | ||
|
||
assert result_name == BUICK_NAME | ||
assert address_list == ["2001:db8:3333:4444:5555:6666:7777:8888"] | ||
|
||
|
||
def test_forward_lookup_should_work_with_different_case_name_results(): | ||
record = Mock() | ||
record.name = "bUiCk.LaB.uNiNeTt.No" | ||
record.type = dns.A | ||
record.payload.address = b"\x9e&\x98\xa2" | ||
result = [[record]] | ||
result_name, address_list = ForwardResolver._extract_records(result, BUICK_NAME) | ||
|
||
assert result_name == BUICK_NAME | ||
assert address_list == ["158.38.152.162"] |