-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6630 from stsewd/proxi-api-on-docs-domain
Proxy footer api on docs' domains
- Loading branch information
Showing
8 changed files
with
107 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Proxied API URLs. | ||
Served from the same domain docs are served, | ||
so they can make use of features that require to have access to their cookies. | ||
""" | ||
|
||
from django.conf.urls import include, url | ||
|
||
from .views.proxied import ProxiedFooterHTML | ||
from readthedocs.search.proxied_api import ProxiedPageSearchAPIView | ||
|
||
api_footer_urls = [ | ||
url(r'footer_html/', ProxiedFooterHTML.as_view(), name='footer_html'), | ||
url(r'docsearch/$', ProxiedPageSearchAPIView.as_view(), name='doc_search'), | ||
] | ||
|
||
urlpatterns = api_footer_urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from readthedocs.core.utils.extend import SettingsOverrideObject | ||
|
||
from .footer_views import BaseFooterHTML | ||
|
||
|
||
class BaseProxiedFooterHTML(BaseFooterHTML): | ||
|
||
# DRF has BasicAuthentication and SessionAuthentication as default classes. | ||
# We don't support neither in the community site. | ||
authentication_classes = [] | ||
|
||
|
||
class ProxiedFooterHTML(SettingsOverrideObject): | ||
|
||
_default_class = BaseProxiedFooterHTML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.test import TestCase, override_settings | ||
|
||
from readthedocs.rtd_tests.tests.test_footer import BaseTestFooterHTML | ||
|
||
|
||
@override_settings( | ||
PUBLIC_DOMAIN='readthedocs.io', | ||
ROOT_URLCONF='readthedocs.proxito.urls', | ||
) | ||
class TestProxiedFooterHTML(BaseTestFooterHTML, TestCase): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.host = 'pip.readthedocs.io' | ||
|
||
def render(self): | ||
r = self.client.get(self.url, HTTP_HOST=self.host) | ||
return r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from readthedocs.core.utils.extend import SettingsOverrideObject | ||
from .api import PageSearchAPIView | ||
|
||
|
||
class BaseProxiedPageSearchAPIView(PageSearchAPIView): | ||
|
||
pass | ||
|
||
|
||
class ProxiedPageSearchAPIView(SettingsOverrideObject): | ||
|
||
_default_class = BaseProxiedPageSearchAPIView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
from readthedocs.search.tests.test_api import BaseTestDocumentSearch | ||
|
||
|
||
@pytest.mark.urls('readthedocs.proxito.urls') | ||
@pytest.mark.search | ||
class TestProxiedSearchAPI(BaseTestDocumentSearch): | ||
|
||
host = 'pip.readthedocs.io' | ||
|
||
def get_search(self, api_client, search_params): | ||
return api_client.get(self.url, search_params, HTTP_HOST=self.host) |