예제 #1
0
    def test_publish_to_web(self):
        """Publish the repository to the web, and fetch the ISO file.

        The ISO file should be available over both HTTP and HTTPS. Fetch it
        from both locations, and assert that the fetch was successful.
        """
        # Publish the repository, and re-read the distributor.
        client = api.Client(self.cfg, api.json_handler)
        path = urljoin(self.repo['_href'], 'actions/publish/')
        client.post(path, {'id': self.distributor['id']})
        distributor = client.get(self.distributor['_href'])

        # Build the path to the ISO file. By default, the file is named like
        # so: {repo_id}-{iso_creation_time}-{iso_number}.iso
        iso_creation_time = parse(
            distributor['last_publish']
        ).strftime('%Y-%m-%dT%H.%M')
        iso_name = '{}-{}-01.iso'.format(self.repo['id'], iso_creation_time)
        path = '/pulp/exports/repos/'
        path = urljoin(path, distributor['config']['relative_url'])
        iso_path = urljoin(path, iso_name)

        # Fetch the ISO file via HTTP and HTTPS.
        client.response_handler = api.safe_handler
        url = urljoin(self.cfg.base_url, iso_path)
        for scheme in ('http', 'https'):
            url = urlunparse((scheme,) + urlparse(url)[1:])
            with self.subTest(url=url):
                self.assertEqual(client.get(url).status_code, 200)