def test_invalid_content(self):
        url = "http://example.com/foo"
        key = "mykey"
        payload = b"0"
        cmdline = "ro %s=%s bar=1" % (key, url)

        with mock.patch("cloudinit.url_helper.readurl", return_value=url_helper.StringResponse(payload)):
            self.assertEqual(util.get_cmdline_url(names=[key], starts="xxxxxx", cmdline=cmdline), (key, url, None))
    def test_no_key_found(self):
        url = "http://example.com/foo"
        key = "mykey"
        cmdline = "ro %s=%s bar=1" % (key, url)

        with mock.patch("cloudinit.url_helper.readurl", return_value=url_helper.StringResponse(b"")):
            self.assertEqual(
                util.get_cmdline_url(names=["does-not-appear"], starts="#cloud-config", cmdline=cmdline),
                (None, None, None),
            )
Exemple #3
0
    def test_no_key_found(self):
        url = "http://example.com/foo"
        key = "mykey"
        cmdline = "ro %s=%s bar=1" % (key, url)

        with mock.patch('cloudinit.url_helper.readurl',
                        return_value=url_helper.StringResponse(b'')):
            self.assertEqual(
                util.get_cmdline_url(names=["does-not-appear"],
                                     starts="#cloud-config",
                                     cmdline=cmdline), (None, None, None))
Exemple #4
0
    def test_valid_content(self):
        url = "http://example.com/foo"
        key = "mykey"
        payload = b"xcloud-config\nmydata: foo\nbar: wark\n"
        cmdline = "ro %s=%s bar=1" % (key, url)

        with mock.patch('cloudinit.url_helper.readurl',
                        return_value=url_helper.StringResponse(payload)):
            self.assertEqual(
                util.get_cmdline_url(names=[key],
                                     starts=b"xcloud-config",
                                     cmdline=cmdline), (key, url, payload))
    def test_no_key_found(self):
        url = "http://example.com/foo"
        key = "mykey"
        cmdline = "ro %s=%s bar=1" % (key, url)

        self.mocker.replace(url_helper.readurl, passthrough=False)
        self.mocker.result(util.StringResponse(""))
        self.mocker.replay()

        self.assertEqual((None, None, None),
            util.get_cmdline_url(names=["does-not-appear"],
                starts="#cloud-config", cmdline=cmdline))
    def test_valid_content(self):
        url = "http://example.com/foo"
        key = "mykey"
        payload = b"xcloud-config\nmydata: foo\nbar: wark\n"
        cmdline = "ro %s=%s bar=1" % (key, url)

        with mock.patch('cloudinit.url_helper.readurl',
                        return_value=url_helper.StringResponse(payload)):
            self.assertEqual(
                util.get_cmdline_url(names=[key], starts=b"xcloud-config",
                                     cmdline=cmdline),
                (key, url, payload))
Exemple #7
0
    def test_invalid_content(self):
        url = "http://example.com/foo"
        key = "mykey"
        payload = "0"
        cmdline = "ro %s=%s bar=1" % (key, url)

        mock_readurl = self.mocker.replace(url_helper.readurl, passthrough=False)
        mock_readurl(url, ARGS, KWARGS)
        self.mocker.result(url_helper.StringResponse(payload))
        self.mocker.replay()

        self.assertEqual((key, url, None), util.get_cmdline_url(names=[key], starts="xxxxxx", cmdline=cmdline))
    def test_no_key_found(self):
        url = "http://example.com/foo"
        key = "mykey"
        cmdline = "ro %s=%s bar=1" % (key, url)

        self.mocker.replace(url_helper.readurl, passthrough=False)
        self.mocker.result(url_helper.StringResponse(""))
        self.mocker.replay()

        self.assertEqual((None, None, None),
                         util.get_cmdline_url(names=["does-not-appear"],
                                              starts="#cloud-config",
                                              cmdline=cmdline))
    def test_valid_content(self):
        url = "http://example.com/foo"
        key = "mykey"
        payload = "xcloud-config\nmydata: foo\nbar: wark\n"
        cmdline = "ro %s=%s bar=1" % (key, url)

        mock_readurl = self.mocker.replace(url_helper.readurl,
                                           passthrough=False)
        mock_readurl(url, ARGS, KWARGS)
        self.mocker.result(url_helper.StringResponse(payload))
        self.mocker.replay()

        self.assertEqual((key, url, payload),
                         util.get_cmdline_url(names=[key],
                                              starts="xcloud-config",
                                              cmdline=cmdline))