Ondřej Svoboda has uploaded a new change for review. Change subject: netmodelsTests: Test IPv6.validateAddress and IPv6.validatePrefixlen ......................................................................
netmodelsTests: Test IPv6.validateAddress and IPv6.validatePrefixlen Use addresses with prefixes to test the latter function. Change-Id: I9e39fd9d36f5ceb4967b41d611faa8eedcfe3e1b Signed-off-by: Ondřej Svoboda <[email protected]> --- M tests/netmodelsTests.py M vdsm/network/models.py 2 files changed, 15 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/29906/1 diff --git a/tests/netmodelsTests.py b/tests/netmodelsTests.py index 47a061f..61b9d00 100644 --- a/tests/netmodelsTests.py +++ b/tests/netmodelsTests.py @@ -24,7 +24,7 @@ from vdsm import netinfo from network import errors -from network.models import Bond, Bridge, IPv4, Nic, Vlan +from network.models import Bond, Bridge, IPv4, IPv6, Nic, Vlan from network.models import _nicSort from testrunner import VdsmTestCase as TestCaseBase @@ -121,6 +121,18 @@ for mask in masks: self.assertEqual(IPv4.validateNetmask(mask), None) + def testIsIpv6Valid(self): + addresses = ('::', '::1', 'fe80::83b1:447f:fe2a:3dbd', 'fe80::/16') + badAddresses = ('::abcd::', 'ff:abcde::1', 'fe80::/132') + + for address in badAddresses: + with self.assertRaises(errors.ConfigNetworkError) as cneContext: + IPv6.validateAddress(address) + self.assertEqual(cneContext.exception.errCode, errors.ERR_BAD_ADDR) + + for address in addresses: + self.assertEqual(IPv6.validateAddress(address), None) + @MonkeyPatch(netinfo, 'getMtu', lambda *x: 1500) @MonkeyPatch(Bond, 'validateOptions', lambda *x: 0) def testTextualRepr(self): diff --git a/vdsm/network/models.py b/vdsm/network/models.py index b26e05e..402a4b5 100644 --- a/vdsm/network/models.py +++ b/vdsm/network/models.py @@ -387,8 +387,8 @@ if gateway: self.validateGateway(gateway) elif gateway: - raise ConfigNetworkError(ne.ERR_BAD_ADDR, 'Specified prefixlen ' - 'or gateway but not ip address.') + raise ConfigNetworkError(ne.ERR_BAD_ADDR, 'Specified gateway but ' + 'not ip address.') self.address = address self.gateway = gateway self.defaultRoute = defaultRoute -- To view, visit http://gerrit.ovirt.org/29906 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9e39fd9d36f5ceb4967b41d611faa8eedcfe3e1b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ondřej Svoboda <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
