Esempio n. 1
0
    def test_explicit_port(self, mock_url, mock_conf):
        """Assert URLs are correctly formed with ports."""
        expected_unsigned_url = 'https://pulp.example.com:1234/streamer/path/to/content'
        mock_key = Mock()
        mock_conf.get = lambda s, k: self.config[k]
        self.config['redirect_port'] = '1234'

        content_controller._get_streamer_url(self.catalog, mock_key)
        mock_url.assert_called_once_with(expected_unsigned_url)
Esempio n. 2
0
    def test_http_url(self, mock_url, mock_conf):
        """Assert HTTP URLs are made if configured."""
        expected_unsigned_url = 'http://pulp.example.com/streamer/path/to/content'
        mock_key = Mock()
        mock_conf.get = lambda s, k: self.config[k]
        self.config['https_retrieval'] = 'false'

        content_controller._get_streamer_url(self.catalog, mock_key)
        mock_url.assert_called_once_with(expected_unsigned_url)
Esempio n. 3
0
    def test_explicit_port(self, mock_url, mock_conf):
        """Assert URLs are correctly formed with ports."""
        expected_unsigned_url = 'https://pulp.example.com:1234/streamer/path/to/content'
        mock_key = Mock()
        mock_conf.get = lambda s, k: self.config[k]
        self.config['redirect_port'] = '1234'

        content_controller._get_streamer_url(self.catalog, mock_key)
        mock_url.assert_called_once_with(expected_unsigned_url)
Esempio n. 4
0
    def test_http_url(self, mock_url, mock_conf):
        """Assert HTTP URLs are made if configured."""
        expected_unsigned_url = 'http://pulp.example.com/streamer/path/to/content'
        mock_key = Mock()
        mock_conf.get = lambda s, k: self.config[k]
        self.config['https_retrieval'] = 'false'

        content_controller._get_streamer_url(self.catalog, mock_key)
        mock_url.assert_called_once_with(expected_unsigned_url)
Esempio n. 5
0
    def test_https_url(self, mock_url, mock_conf):
        """Assert HTTPS URLs are made if configured."""
        expected_unsigned_url = 'https://pulp.example.com/streamer/path/to/content'
        mock_key = Mock()
        mock_conf.get = lambda s, k: self.config[k]

        url = content_controller._get_streamer_url(self.catalog, mock_key)
        mock_url.assert_called_once_with(expected_unsigned_url)
        mock_url.return_value.sign.assert_called_once_with(
            mock_key, expiration=(60 * 60 * 24 * 365))
        signed_url = mock_url.return_value.sign.return_value
        self.assertEqual(url, str(signed_url))
Esempio n. 6
0
    def test_https_url(self, mock_url, mock_conf):
        """Assert HTTPS URLs are made if configured."""
        expected_unsigned_url = 'https://pulp.example.com/streamer/path/to/content'
        mock_key = Mock()
        mock_conf.get = lambda s, k: self.config[k]

        url = content_controller._get_streamer_url(self.catalog, mock_key)
        mock_url.assert_called_once_with(expected_unsigned_url)
        mock_url.return_value.sign.assert_called_once_with(
            mock_key, expiration=(60 * 60 * 24 * 365))
        signed_url = mock_url.return_value.sign.return_value
        self.assertEqual(url, str(signed_url))