Skip to content

Commit f058915

Browse files
committed
Embed: Allow to override embed view for proxied use
And fix tests in .com. Currently we are using the same view for the normal api and the proxied api. This isn't correct as we don't have the auth backends in the normal view. There is a change in .com as well.
1 parent e8dc9f1 commit f058915

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

readthedocs/api/v2/proxied_urls.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
from django.conf.urls import include, url
1010

1111
from readthedocs.analytics.proxied_api import AnalyticsView
12+
from readthedocs.api.v2.views.proxied import ProxiedEmbedAPI, ProxiedFooterHTML
1213
from readthedocs.search.proxied_api import ProxiedPageSearchAPIView
1314

14-
from .views.proxied import ProxiedFooterHTML
15-
1615
api_footer_urls = [
1716
url(r'footer_html/', ProxiedFooterHTML.as_view(), name='footer_html'),
1817
url(r'search/$', ProxiedPageSearchAPIView.as_view(), name='search_api'),
19-
url(r'embed/', include('readthedocs.embed.urls')),
18+
url(r'embed/', ProxiedEmbedAPI.as_view(), name='embed_api'),
2019
url(r'analytics/$', AnalyticsView.as_view(), name='analytics_api'),
2120
]
2221

readthedocs/api/v2/views/proxied.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from readthedocs.api.v2.views.footer_views import BaseFooterHTML
12
from readthedocs.core.utils.extend import SettingsOverrideObject
2-
3-
from .footer_views import BaseFooterHTML
3+
from readthedocs.embed.views import EmbedAPIBase
44

55

66
class BaseProxiedFooterHTML(BaseFooterHTML):
@@ -13,3 +13,15 @@ class BaseProxiedFooterHTML(BaseFooterHTML):
1313
class ProxiedFooterHTML(SettingsOverrideObject):
1414

1515
_default_class = BaseProxiedFooterHTML
16+
17+
18+
class ProxiedEmbedAPIBase(EmbedAPIBase):
19+
20+
# DRF has BasicAuthentication and SessionAuthentication as default classes.
21+
# We don't support neither in the community site.
22+
authentication_classes = []
23+
24+
25+
class ProxiedEmbedAPI(SettingsOverrideObject):
26+
27+
_default_class = ProxiedEmbedAPIBase

readthedocs/rtd_tests/tests/test_imported_file.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ def test_update_content(self):
180180
self.assertNotEqual(ImportedFile.objects.get(name='test.html').md5, 'c7532f22a052d716f7b2310fb52ad981')
181181
self.assertEqual(ImportedFile.objects.count(), 2)
182182

183+
@override_settings(PRODUCTION_DOMAIN='readthedocs.org')
184+
@override_settings(RTD_INTERSPHINX_URL='https://readthedocs.org')
183185
@mock.patch('readthedocs.projects.tasks.os.path.exists')
184186
def test_create_intersphinx_data(self, mock_exists):
185187
mock_exists.return_Value = True
@@ -254,7 +256,7 @@ def test_create_intersphinx_data(self, mock_exists):
254256
mock_fetch_inventory.assert_called_once()
255257
self.assertRegex(
256258
mock_fetch_inventory.call_args[0][2],
257-
'^https://{}/media/.*/objects.inv$'.format(settings.PRODUCTION_DOMAIN)
259+
r'^https://readthedocs\.org/media/.*/objects\.inv$'
258260
)
259261
self.assertEqual(ImportedFile.objects.count(), 2)
260262

0 commit comments

Comments
 (0)