| |
@@ -1,120 +0,0 @@
|
| |
- From 98bc71cabf0b6677d391d99d82949b86bb8591a7 Mon Sep 17 00:00:00 2001
|
| |
- From: Chenxiong Qi <qcxhome@gmail.com>
|
| |
- Date: Mon, 14 Jun 2021 12:29:10 +0800
|
| |
- Subject: [PATCH 2/4] Do not allow tests to connect network
|
| |
-
|
| |
- By disabling the network connection, also fix some tests to add missed
|
| |
- URI regisgration.
|
| |
-
|
| |
- Signed-off-by: Chenxiong Qi <qcxhome@gmail.com>
|
| |
- ---
|
| |
- social_core/tests/backends/base.py | 2 +-
|
| |
- social_core/tests/backends/open_id.py | 2 +-
|
| |
- social_core/tests/backends/test_amazon.py | 10 ++++++++++
|
| |
- social_core/tests/backends/test_github.py | 4 ++++
|
| |
- social_core/tests/backends/test_github_enterprise.py | 5 +++++
|
| |
- social_core/tests/backends/test_yahoo.py | 4 ++++
|
| |
- 6 files changed, 25 insertions(+), 2 deletions(-)
|
| |
-
|
| |
- diff --git a/social_core/tests/backends/base.py b/social_core/tests/backends/base.py
|
| |
- index fe2b7aa0..daf4aa7b 100644
|
| |
- --- a/social_core/tests/backends/base.py
|
| |
- +++ b/social_core/tests/backends/base.py
|
| |
- @@ -18,7 +18,7 @@ class BaseBackendTest(unittest.TestCase):
|
| |
- raw_complete_url = '/complete/{0}'
|
| |
-
|
| |
- def setUp(self):
|
| |
- - HTTPretty.enable()
|
| |
- + HTTPretty.enable(allow_net_connect=False)
|
| |
- Backend = module_member(self.backend_path)
|
| |
- self.strategy = TestStrategy(TestStorage)
|
| |
- self.backend = Backend(self.strategy, redirect_uri=self.complete_url)
|
| |
- diff --git a/social_core/tests/backends/open_id.py b/social_core/tests/backends/open_id.py
|
| |
- index 830e05a6..8a4efdf3 100644
|
| |
- --- a/social_core/tests/backends/open_id.py
|
| |
- +++ b/social_core/tests/backends/open_id.py
|
| |
- @@ -44,7 +44,7 @@ class OpenIdTest(BaseBackendTest):
|
| |
- raw_complete_url = '/complete/{0}/'
|
| |
-
|
| |
- def setUp(self):
|
| |
- - HTTPretty.enable()
|
| |
- + HTTPretty.enable(allow_net_connect=False)
|
| |
- Backend = module_member(self.backend_path)
|
| |
- self.strategy = TestStrategy(TestStorage)
|
| |
- self.complete_url = self.raw_complete_url.format(Backend.name)
|
| |
- diff --git a/social_core/tests/backends/test_amazon.py b/social_core/tests/backends/test_amazon.py
|
| |
- index f78c4ea2..c1573b02 100644
|
| |
- --- a/social_core/tests/backends/test_amazon.py
|
| |
- +++ b/social_core/tests/backends/test_amazon.py
|
| |
- @@ -1,5 +1,7 @@
|
| |
- import json
|
| |
-
|
| |
- +from httpretty import HTTPretty
|
| |
- +
|
| |
- from .oauth import OAuth2Test
|
| |
-
|
| |
-
|
| |
- @@ -41,6 +43,14 @@ class AmazonOAuth2BrokenServerResponseTest(OAuth2Test):
|
| |
- }
|
| |
- })
|
| |
-
|
| |
- + def setUp(self):
|
| |
- + super().setUp()
|
| |
- + HTTPretty.register_uri(HTTPretty.GET,
|
| |
- + 'https://api.amazon.com/user/profile',
|
| |
- + status=200,
|
| |
- + body=self.user_data_body,
|
| |
- + content_type='application/json')
|
| |
- +
|
| |
- def test_login(self):
|
| |
- self.do_login()
|
| |
-
|
| |
- diff --git a/social_core/tests/backends/test_github.py b/social_core/tests/backends/test_github.py
|
| |
- index 53009f69..eb06b5fe 100644
|
| |
- --- a/social_core/tests/backends/test_github.py
|
| |
- +++ b/social_core/tests/backends/test_github.py
|
| |
- @@ -104,6 +104,10 @@ class GithubOAuth2NoEmailTest(GithubOAuth2Test):
|
| |
- self.do_login()
|
| |
-
|
| |
- def test_partial_pipeline(self):
|
| |
- + url = 'https://api.github.com/user/emails'
|
| |
- + HTTPretty.register_uri(HTTPretty.GET, url, status=200,
|
| |
- + body=json.dumps([{'email': 'foo@bar.com'}]),
|
| |
- + content_type='application/json')
|
| |
- self.do_partial_pipeline()
|
| |
-
|
| |
-
|
| |
- diff --git a/social_core/tests/backends/test_github_enterprise.py b/social_core/tests/backends/test_github_enterprise.py
|
| |
- index 12f67997..6196558f 100644
|
| |
- --- a/social_core/tests/backends/test_github_enterprise.py
|
| |
- +++ b/social_core/tests/backends/test_github_enterprise.py
|
| |
- @@ -124,6 +124,11 @@ class GithubEnterpriseOAuth2NoEmailTest(GithubEnterpriseOAuth2Test):
|
| |
- 'SOCIAL_AUTH_GITHUB_ENTERPRISE_URL': 'https://www.example.com'})
|
| |
- self.strategy.set_settings({
|
| |
- 'SOCIAL_AUTH_GITHUB_ENTERPRISE_API_URL': 'https://www.example.com/api/v3'})
|
| |
- + HTTPretty.register_uri(HTTPretty.GET,
|
| |
- + 'https://www.example.com/api/v3/user/emails',
|
| |
- + status=200,
|
| |
- + body=json.dumps([{'email': 'foo@bar.com'}]),
|
| |
- + content_type='application/json')
|
| |
- self.do_partial_pipeline()
|
| |
-
|
| |
-
|
| |
- diff --git a/social_core/tests/backends/test_yahoo.py b/social_core/tests/backends/test_yahoo.py
|
| |
- index cd7c3778..96cad929 100644
|
| |
- --- a/social_core/tests/backends/test_yahoo.py
|
| |
- +++ b/social_core/tests/backends/test_yahoo.py
|
| |
- @@ -67,6 +67,10 @@ class YahooOAuth1Test(OAuth1Test):
|
| |
- self.do_login()
|
| |
-
|
| |
- def test_partial_pipeline(self):
|
| |
- + HTTPretty.register_uri(HTTPretty.GET,
|
| |
- + 'https://social.yahooapis.com/v1/me/guid?format=json',
|
| |
- + status=200,
|
| |
- + body=self.guid_body)
|
| |
- self.do_partial_pipeline()
|
| |
-
|
| |
- def test_get_user_details(self):
|
| |
- --
|
| |
- 2.31.1
|
| |
-
|
| |
Signed-off-by: Chenxiong Qi qcxhome@gmail.com