def test_re_config_file_matches_classic_pxelinux_cfg(self): # The default config path is simply "pxelinux.cfg" (without # leading slash). The regex matches this. mac = factory.make_mac_address("-").encode("ascii") match = re_config_file.match(b"s390x/pxelinux.cfg/01-%s" % mac) self.assertIsNotNone(match) self.assertEqual({"mac": mac}, match.groupdict())
def test_re_config_file_is_compatible_with_config_path_generator(self): # The regular expression for extracting components of the file path is # compatible with the PXE config path generator. for iteration in range(10): config_path, args = get_example_path_and_components() match = re_config_file.match(config_path) self.assertIsNotNone(match, config_path) self.assertEqual(args, match.groupdict())
def test_re_config_file_without_leading_slash(self): # The regular expression for extracting components of the file path # doesn't care if there's no leading forward slash; the TFTP server is # easy on this point, so it makes sense to be also. config_path, args = get_example_path_and_components() # Ensure there's no leading slash. config_path = config_path.lstrip(b"/") match = re_config_file.match(config_path) self.assertIsNotNone(match, config_path) self.assertEqual(args, match.groupdict())
def test_re_config_file_with_default(self): match = re_config_file.match(b"s390x/pxelinux.cfg/default") self.assertIsNotNone(match) self.assertEqual({"mac": None}, match.groupdict())
def test_re_config_file_does_not_match_file_not_in_pxelinux_cfg(self): self.assertIsNone(re_config_file.match(b"foo/01-aa-bb-cc-dd-ee-ff"))
def test_re_config_file_does_not_match_file_in_root(self): self.assertIsNone(re_config_file.match(b"01-aa-bb-cc-dd-ee-ff"))
def test_re_config_file_does_not_match_non_config_file(self): self.assertIsNone(re_config_file.match(b"s390x/pxelinux.cfg/kernel"))
def test_re_config_file_matches_pxelinux_cfg_without_pxelinux_cfg(self): mac = factory.make_mac_address("-").encode("ascii") match = re_config_file.match(b"/s390x/01-%s" % mac) self.assertIsNotNone(match) self.assertEqual({"mac": mac}, match.groupdict())
def test_re_config_file_matches_pxelinux_cfg_with_leading_slash(self): mac = factory.make_mac_address("-").encode("ascii") match = re_config_file.match(b'/s390x/pxelinux.cfg/01-%s' % mac) self.assertIsNotNone(match) self.assertEqual({'mac': mac}, match.groupdict())