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)
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)
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))