def test_partial(self): site_value = '10.0.0.0/8\n172.16.0.0/12\n192.168.100.0/16' actual = validate_pna_networks(site_value) expected = '10.0.0.0/8 172.16.0.0/12 192.168.0.0/16' self.assertEqual(actual, expected) site_value = '10.0.0.0;8\n172.16.0.0/12\n192.168.100.0/16' actual = validate_pna_networks(site_value) expected = '172.16.0.0/12 192.168.0.0/16' self.assertEqual(actual, expected) site_value = '10.0.0.0/8\n2001:db8::ff00:42:8329/24' actual = validate_pna_networks(site_value) expected = '10.0.0.0/8' self.assertEqual(actual, expected) site_value = '10.0.0.0/8\n172.16.0.0.0/12' actual = validate_pna_networks(site_value) expected = '10.0.0.0/8' self.assertEqual(actual, expected) site_value = '10.0.0.0/8\n172.16.256.0/12' actual = validate_pna_networks(site_value) expected = '10.0.0.0/8' self.assertEqual(actual, expected)
def test_none(self): site_value = '10.0.0.0;8' actual = validate_pna_networks(site_value) self.assertEqual(actual, '') site_value = 'adduser something evil' actual = validate_pna_networks(site_value) self.assertEqual(actual, '') site_value = None actual = validate_pna_networks(site_value) self.assertEqual(actual, '')
def test_valid(self): site_value = '10.0.0.0/8\n172.16.0.0/12\n192.168.0.0/16' actual = validate_pna_networks(site_value) expected = '10.0.0.0/8 172.16.0.0/12 192.168.0.0/16' self.assertEqual(actual, expected)