[Python-modules-commits] [python-social-auth] 09/15: PEP8
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:13:34 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.11
in repository python-social-auth.
commit d064794204a424a28fc7ab6f6964dba40e573ad6
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date: Wed Jun 17 02:51:19 2015 -0300
PEP8
---
social/backends/saml.py | 218 ++++++++++++++++++++---------------
social/strategies/base.py | 10 +-
social/strategies/django_strategy.py | 10 +-
social/tests/backends/test_saml.py | 89 ++++++++------
social/tests/models.py | 6 +-
5 files changed, 193 insertions(+), 140 deletions(-)
diff --git a/social/backends/saml.py b/social/backends/saml.py
index 0ea11c0..745451b 100644
--- a/social/backends/saml.py
+++ b/social/backends/saml.py
@@ -4,10 +4,12 @@ Backend for SAML 2.0 support
Terminology:
"Service Provider" (SP): Your web app
-"Identity Provider" (IdP): The third-party site that is authenticating users via SAML
+"Identity Provider" (IdP): The third-party site that is authenticating
+ users via SAML
"""
from onelogin.saml2.auth import OneLogin_Saml2_Auth
from onelogin.saml2.settings import OneLogin_Saml2_Settings
+
from social.backends.base import BaseAuth
from social.exceptions import AuthFailed
@@ -22,88 +24,104 @@ OID_USERID = "urn:oid:0.9.2342.19200300.100.1.1"
class SAMLIdentityProvider(object):
- """
- Wrapper around configuration for a SAML Identity provider
- """
-
+ """Wrapper around configuration for a SAML Identity provider"""
def __init__(self, name, **kwargs):
- """ Load and parse configuration """
+ """Load and parse configuration"""
self.name = name
- # name should be a slug and must not contain a colon, which could conflict with uid prefixing:
- assert ':' not in self.name and ' ' not in self.name, "IdP 'name' should be a slug (short, no spaces)"
+ # name should be a slug and must not contain a colon, which
+ # could conflict with uid prefixing:
+ assert ':' not in self.name and ' ' not in self.name, \
+ 'IdP "name" should be a slug (short, no spaces)'
self.conf = kwargs
def get_user_permanent_id(self, attributes):
"""
- The most important method: Get a permanent, unique identifier for this user from the
- attributes supplied by the IdP.
+ The most important method: Get a permanent, unique identifier
+ for this user from the attributes supplied by the IdP.
- If you want to use the NameID, it's available via attributes['name_id']
+ If you want to use the NameID, it's available via
+ attributes['name_id']
"""
- return attributes[self.conf.get('attr_user_permanent_id', OID_USERID)][0]
+ return attributes[
+ self.conf.get('attr_user_permanent_id', OID_USERID)
+ ][0]
# Attributes processing:
def get_user_details(self, attributes):
"""
- Given the SAML attributes extracted from the SSO response, get the user data like name.
+ Given the SAML attributes extracted from the SSO response, get
+ the user data like name.
"""
return {
- 'fullname': self.get_attr(attributes, 'attr_full_name', OID_COMMON_NAME),
- 'first_name': self.get_attr(attributes, 'attr_first_name', OID_GIVEN_NAME),
- 'last_name': self.get_attr(attributes, 'attr_last_name', OID_SURNAME),
- 'username': self.get_attr(attributes, 'attr_username', OID_USERID),
- 'email': self.get_attr(attributes, 'attr_email', OID_MAIL),
+ 'fullname': self.get_attr(attributes, 'attr_full_name',
+ OID_COMMON_NAME),
+ 'first_name': self.get_attr(attributes, 'attr_first_name',
+ OID_GIVEN_NAME),
+ 'last_name': self.get_attr(attributes, 'attr_last_name',
+ OID_SURNAME),
+ 'username': self.get_attr(attributes, 'attr_username',
+ OID_USERID),
+ 'email': self.get_attr(attributes, 'attr_email',
+ OID_MAIL),
}
def get_attr(self, attributes, conf_key, default_attribute):
"""
Internal helper method.
- Get the attribute 'default_attribute' out of the attributes, unless self.conf[conf_key]
- overrides the default by specifying another attribute to use.
+ Get the attribute 'default_attribute' out of the attributes,
+ unless self.conf[conf_key] overrides the default by specifying
+ another attribute to use.
"""
key = self.conf.get(conf_key, default_attribute)
return attributes[key][0] if key in attributes else None
@property
def entity_id(self):
- """ Get the entity ID for this IdP """
- return self.conf['entity_id'] # Required. e.g. "https://idp.testshib.org/idp/shibboleth"
+ """Get the entity ID for this IdP"""
+ # Required. e.g. "https://idp.testshib.org/idp/shibboleth"
+ return self.conf['entity_id']
@property
def sso_url(self):
- """ Get the SSO URL for this IdP """
- return self.conf['url'] # Required. e.g. "https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO"
+ """Get the SSO URL for this IdP"""
+ # Required. e.g.
+ # "https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO"
+ return self.conf['url']
@property
def x509cert(self):
- """ X.509 Public Key Certificate for this IdP """
+ """X.509 Public Key Certificate for this IdP"""
return self.conf['x509cert']
@property
def saml_config_dict(self):
- """ Get the IdP configuration dict in the format required by python-saml """
+ """Get the IdP configuration dict in the format required by
+ python-saml"""
return {
- "entityId": self.entity_id,
- "singleSignOnService": {
- "url": self.sso_url,
- "binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect", # python-saml only supports Redirect
+ 'entityId': self.entity_id,
+ 'singleSignOnService': {
+ 'url': self.sso_url,
+ # python-saml only supports Redirect
+ 'binding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
},
- "x509cert": self.x509cert,
+ 'x509cert': self.x509cert,
}
class DummySAMLIdentityProvider(SAMLIdentityProvider):
"""
- A placeholder IdP used when we must specify something, e.g. when generating SP metadata.
+ A placeholder IdP used when we must specify something, e.g. when
+ generating SP metadata.
- If OneLogin_Saml2_Auth is modified to not always require IdP config, this can be removed.
+ If OneLogin_Saml2_Auth is modified to not always require IdP
+ config, this can be removed.
"""
def __init__(self):
super(DummySAMLIdentityProvider, self).__init__(
- "dummy",
- entity_id="https://dummy.none/saml2",
- url="https://dummy.none/SSO",
- x509cert='',
+ 'dummy',
+ entity_id='https://dummy.none/saml2',
+ url='https://dummy.none/SSO',
+ x509cert=''
)
@@ -123,15 +141,26 @@ class SAMLAuth(BaseAuth):
SOCIAL_AUTH_SAML_SP_PUBLIC_CERT = "... X.509 certificate string ..."
SOCIAL_AUTH_SAML_SP_PRIVATE_KEY = "... private key ..."
SOCIAL_AUTH_SAML_ORG_INFO = {
- "en-US": {"name": "example", "displayname": "Example Inc.", "url": "http://example.com", },
+ "en-US": {
+ "name": "example",
+ "displayname": "Example Inc.",
+ "url": "http://example.com"
+ }
+ }
+ SOCIAL_AUTH_SAML_TECHNICAL_CONTACT = {
+ "givenName": "Tech Gal",
+ "emailAddress": "technical at example.com"
+ }
+ SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
+ "givenName": "Support Guy",
+ "emailAddress": "support at example.com"
}
- SOCIAL_AUTH_SAML_TECHNICAL_CONTACT = {"givenName": "Tech Gal", "emailAddress": "technical at example.com", }
- SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {"givenName": "Support Guy", "emailAddress": "support at example.com", }
SOCIAL_AUTH_SAML_ENABLED_IDPS = {
"testshib": {
"entity_id": "https://idp.testshib.org/idp/shibboleth",
"url": "https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO",
- "x509cert": "MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0B ... 8Bbnl+ev0peYzxFyF5sQA==",
+ "x509cert": "MIIEDjCCAvagAwIBAgIBADANBgkqhkiG9w0B...
+ ...8Bbnl+ev0peYzxFyF5sQA==",
}
}
@@ -143,40 +172,41 @@ class SAMLAuth(BaseAuth):
name = "saml"
def get_idp(self, idp_name):
- """ Given the name of an IdP, get a SAMLIdentityProvider instance """
- idp_config = self.setting("ENABLED_IDPS")[idp_name]
+ """Given the name of an IdP, get a SAMLIdentityProvider instance"""
+ idp_config = self.setting('ENABLED_IDPS')[idp_name]
return SAMLIdentityProvider(idp_name, **idp_config)
def generate_saml_config(self, idp):
"""
Generate the configuration required to instantiate OneLogin_Saml2_Auth
"""
- # The shared absolute URL that all IdPs redirect back to - this is specified in our metadata.xml:
+ # The shared absolute URL that all IdPs redirect back to -
+ # this is specified in our metadata.xml:
abs_completion_url = self.redirect_uri
-
config = {
- "contactPerson": {
- "technical": self.setting("TECHNICAL_CONTACT"),
- "support": self.setting("SUPPORT_CONTACT"),
+ 'contactPerson': {
+ 'technical': self.setting('TECHNICAL_CONTACT'),
+ 'support': self.setting('SUPPORT_CONTACT')
},
- "debug": True,
- "idp": idp.saml_config_dict,
- "organization": self.setting("ORG_INFO"),
- "security": {
+ 'debug': True,
+ 'idp': idp.saml_config_dict,
+ 'organization': self.setting('ORG_INFO'),
+ 'security': {
'metadataValidUntil': '',
'metadataCacheDuration': 'P10D', # metadata valid for ten days
},
- "sp": {
- "assertionConsumerService": {
- "url": abs_completion_url,
- "binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST", # python-saml only supports HTTP-POST
+ 'sp': {
+ 'assertionConsumerService': {
+ 'url': abs_completion_url,
+ # python-saml only supports HTTP-POST
+ 'binding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'
},
- "entityId": self.setting("SP_ENTITY_ID"),
- "NameIDFormats": self.setting("SP_NAMEID_FORMATS", []),
- "x509cert": self.setting("SP_PUBLIC_CERT"),
- "privateKey": self.setting("SP_PRIVATE_KEY"),
+ 'entityId': self.setting('SP_ENTITY_ID'),
+ 'NameIDFormats': self.setting('SP_NAMEID_FORMATS', []),
+ 'x509cert': self.setting('SP_PUBLIC_CERT'),
+ 'privateKey': self.setting('SP_PRIVATE_KEY'),
},
- "strict": True, # We must force strict mode - for security
+ 'strict': True, # We must force strict mode - for security
}
config["security"].update(self.setting("SECURITY_CONFIG", {}))
config["sp"].update(self.setting("SP_EXTRA", {}))
@@ -184,22 +214,28 @@ class SAMLAuth(BaseAuth):
def generate_metadata_xml(self):
"""
- Helper method that can be used from your web app to generate the XML metadata required
- to link your web app as a Service Provider with each IdP you wish to use.
+ Helper method that can be used from your web app to generate the XML
+ metadata required to link your web app as a Service Provider with
+ each IdP you wish to use.
Returns (metadata XML string, list of errors)
Example usage (Django):
- from social.apps.django_app.utils import load_strategy, load_backend
+ from social.apps.django_app.utils import load_strategy, \
+ load_backend
def saml_metadata_view(request):
complete_url = reverse('social:complete', args=("saml", ))
- saml_backend = load_backend(load_strategy(request), "saml", complete_url)
+ saml_backend = load_backend(load_strategy(request), "saml",
+ complete_url)
metadata, errors = saml_backend.generate_metadata_xml()
if not errors:
- return HttpResponse(content=metadata, content_type='text/xml')
+ return HttpResponse(content=metadata,
+ content_type='text/xml')
return HttpResponseServerError(content=', '.join(errors))
"""
- idp = DummySAMLIdentityProvider() # python-saml requires us to specify something here even though it's not used
+ # python-saml requires us to specify something here even
+ # though it's not used
+ idp = DummySAMLIdentityProvider()
config = self.generate_saml_config(idp)
saml_settings = OneLogin_Saml2_Settings(config)
metadata = saml_settings.get_sp_metadata()
@@ -207,9 +243,7 @@ class SAMLAuth(BaseAuth):
return metadata, errors
def _create_saml_auth(self, idp):
- """
- Get an instance of OneLogin_Saml2_Auth
- """
+ """Get an instance of OneLogin_Saml2_Auth"""
config = self.generate_saml_config(idp)
request_info = {
'https': 'on' if self.strategy.request_is_secure() else 'off',
@@ -222,26 +256,27 @@ class SAMLAuth(BaseAuth):
return OneLogin_Saml2_Auth(request_info, config)
def auth_url(self):
- """ Get the URL to which we must redirect in order to authenticate the user """
+ """Get the URL to which we must redirect in order to
+ authenticate the user"""
idp_name = self.strategy.request_data()['idp']
auth = self._create_saml_auth(idp=self.get_idp(idp_name))
- # Below, return_to sets the RelayState, which can contain arbitrary data.
- # We use it to store the specific SAML IdP name, since we multiple IdPs
- # share the same auth_complete URL.
+ # Below, return_to sets the RelayState, which can contain
+ # arbitrary data. We use it to store the specific SAML IdP
+ # name, since we multiple IdPs share the same auth_complete
+ # URL.
return auth.login(return_to=idp_name)
def get_user_details(self, response):
- """
- Get user details like full name, email, etc. from the response - see auth_complete
- """
+ """Get user details like full name, email, etc. from the
+ response - see auth_complete"""
idp = self.get_idp(response['idp_name'])
return idp.get_user_details(response['attributes'])
def get_user_id(self, details, response):
"""
Get the permanent ID for this user from the response.
- We prefix each ID with the name of the IdP so that we can connect multiple IdPs to this
- user.
+ We prefix each ID with the name of the IdP so that we can
+ connect multiple IdPs to this user.
"""
idp = self.get_idp(response['idp_name'])
uid = idp.get_user_permanent_id(response['attributes'])
@@ -249,8 +284,8 @@ class SAMLAuth(BaseAuth):
def auth_complete(self, *args, **kwargs):
"""
- The user has been redirected back from the IdP and we should now log them in, if
- everything checks out.
+ The user has been redirected back from the IdP and we should
+ now log them in, if everything checks out.
"""
idp_name = self.strategy.request_data()['RelayState']
idp = self.get_idp(idp_name)
@@ -259,31 +294,32 @@ class SAMLAuth(BaseAuth):
errors = auth.get_errors()
if errors or not auth.is_authenticated():
reason = auth.get_last_error_reason()
- raise AuthFailed(self, 'SAML login failed: {} ({})'.format(errors, reason))
+ raise AuthFailed(
+ self, 'SAML login failed: {} ({})'.format(errors, reason)
+ )
attributes = auth.get_attributes()
attributes['name_id'] = auth.get_nameid()
-
self._check_entitlements(idp, attributes)
-
response = {
'idp_name': idp_name,
'attributes': attributes,
'session_index': auth.get_session_index(),
}
-
kwargs.update({'response': response, 'backend': self})
-
return self.strategy.authenticate(*args, **kwargs)
def _check_entitlements(self, idp, attributes):
"""
- Additional verification of a SAML response before authenticating the user.
+ Additional verification of a SAML response before
+ authenticating the user.
- Subclasses can override this method if they need custom validation code,
- such as requiring the presence of an eduPersonEntitlement.
+ Subclasses can override this method if they need custom
+ validation code, such as requiring the presence of an
+ eduPersonEntitlement.
- raise social.exceptions.AuthForbidden if the user should not be authenticated,
- or do nothing to allow the login pipeline to continue.
+ raise social.exceptions.AuthForbidden if the user should not
+ be authenticated, or do nothing to allow the login pipeline to
+ continue.
"""
pass
diff --git a/social/strategies/base.py b/social/strategies/base.py
index 09ef9fa..ce66af0 100644
--- a/social/strategies/base.py
+++ b/social/strategies/base.py
@@ -190,21 +190,21 @@ class BaseStrategy(object):
raise NotImplementedError('Implement in subclass')
def request_is_secure(self):
- """ Is the request using HTTPS? """
+ """Is the request using HTTPS?"""
raise NotImplementedError('Implement in subclass')
def request_path(self):
- """ path of the current request """
+ """path of the current request"""
raise NotImplementedError('Implement in subclass')
def request_port(self):
- """ Port in use for this request """
+ """Port in use for this request"""
raise NotImplementedError('Implement in subclass')
def request_get(self):
- """ Request GET data """
+ """Request GET data"""
raise NotImplementedError('Implement in subclass')
def request_post(self):
- """ Request POST data """
+ """Request POST data"""
raise NotImplementedError('Implement in subclass')
diff --git a/social/strategies/django_strategy.py b/social/strategies/django_strategy.py
index b3b66b7..2cfc828 100644
--- a/social/strategies/django_strategy.py
+++ b/social/strategies/django_strategy.py
@@ -54,23 +54,23 @@ class DjangoStrategy(BaseStrategy):
return self.request.get_host()
def request_is_secure(self):
- """ Is the request using HTTPS? """
+ """Is the request using HTTPS?"""
return self.request.is_secure()
def request_path(self):
- """ path of the current request """
+ """path of the current request"""
return self.request.path
def request_port(self):
- """ Port in use for this request """
+ """Port in use for this request"""
return self.request.META['SERVER_PORT']
def request_get(self):
- """ Request GET data """
+ """Request GET data"""
return self.request.GET.copy()
def request_post(self):
- """ Request POST data """
+ """Request POST data"""
return self.request.POST.copy()
def redirect(self, url):
diff --git a/social/tests/backends/test_saml.py b/social/tests/backends/test_saml.py
index abe2569..057fe18 100644
--- a/social/tests/backends/test_saml.py
+++ b/social/tests/backends/test_saml.py
@@ -1,89 +1,99 @@
-import base64
-import datetime
-from httpretty import HTTPretty
+import re
import json
+import sys
+import unittest2
+import os.path
+import requests
+
from mock import patch
+from httpretty import HTTPretty
+
try:
from onelogin.saml2.utils import OneLogin_Saml2_Utils
except ImportError:
- pass # Only available for python 2.7 at the moment, so don't worry if this fails
-import os.path
-import re
-import requests
-from social.p3 import urlparse
-from social.utils import parse_qs, url_add_parameters
-from social.tests.models import User
+ # Only available for python 2.7 at the moment, so don't worry if this fails
+ pass
+
+from social.utils import parse_qs
from social.tests.backends.base import BaseBackendTest
-import sys
-import unittest2
-try:
- from urllib.parse import urlencode, urlparse, urlunparse, parse_qs
-except ImportError:
- from urllib import urlencode
- from urlparse import urlparse, urlunparse, parse_qs
+from social.p3 import urlparse, urlunparse, urlencode
+
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
@unittest2.skipUnless(
sys.version_info[:2] == (2, 7),
- "python-saml currently depends on 2.7; 3+ support coming soon")
- at unittest2.skipIf('__pypy__' in sys.builtin_module_names, "dm.xmlsec not compatible with pypy")
+ 'python-saml currently depends on 2.7; 3+ support coming soon')
+ at unittest2.skipIf('__pypy__' in sys.builtin_module_names,
+ 'dm.xmlsec not compatible with pypy')
class SAMLTest(BaseBackendTest):
backend_path = 'social.backends.saml.SAMLAuth'
expected_username = 'myself'
def extra_settings(self):
- with open(os.path.join(DATA_DIR, 'saml_config.json'), 'r') as config_file:
+ name = os.path.join(DATA_DIR, 'saml_config.json')
+ with open(name, 'r') as config_file:
config_str = config_file.read()
return json.loads(config_str)
def setUp(self):
- """ Patch the time so that we can replay canned request/response pairs """
+ """Patch the time so that we can replay canned
+ request/response pairs"""
super(SAMLTest, self).setUp()
@staticmethod
def fixed_time():
- return OneLogin_Saml2_Utils.parse_SAML_to_time("2015-05-09T03:57:22Z")
+ return OneLogin_Saml2_Utils.parse_SAML_to_time(
+ '2015-05-09T03:57:22Z'
+ )
now_patch = patch.object(OneLogin_Saml2_Utils, 'now', fixed_time)
now_patch.start()
self.addCleanup(now_patch.stop)
def install_http_intercepts(self, start_url, return_url):
- # When we request start_url (https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO...)
- # we will eventually get a redirect back, with SAML assertion data in the query string.
- # A pre-recorded correct response is kept in this .txt file:
- with open(os.path.join(DATA_DIR, 'saml_response.txt'), 'r') as response_file:
+ # When we request start_url
+ # (https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO...)
+ # we will eventually get a redirect back, with SAML assertion
+ # data in the query string. A pre-recorded correct response
+ # is kept in this .txt file:
+ name = os.path.join(DATA_DIR, 'saml_response.txt')
+ with open(name, 'r') as response_file:
response_url = response_file.read()
- HTTPretty.register_uri(HTTPretty.GET, start_url, status=301, location=response_url)
- HTTPretty.register_uri(HTTPretty.GET, return_url, status=200, body='foobar')
+ HTTPretty.register_uri(HTTPretty.GET, start_url, status=301,
+ location=response_url)
+ HTTPretty.register_uri(HTTPretty.GET, return_url, status=200,
+ body='foobar')
def do_start(self):
# pretend we've started with a URL like /login/saml/?idp=testshib:
self.strategy.set_request_data({'idp': 'testshib'}, self.backend)
start_url = self.backend.start().url
- # Modify the start URL to make the SAML request consistent from test to test:
+ # Modify the start URL to make the SAML request consistent
+ # from test to test:
start_url = self.modify_start_url(start_url)
- # If the SAML Identity Provider recognizes the user, we will be redirected back to:
+ # If the SAML Identity Provider recognizes the user, we will
+ # be redirected back to:
return_url = self.backend.redirect_uri
self.install_http_intercepts(start_url, return_url)
response = requests.get(start_url)
self.assertTrue(response.url.startswith(return_url))
self.assertEqual(response.text, 'foobar')
- query_values = dict((k, v[0]) for k, v in parse_qs(urlparse(response.url).query).items())
+ query_values = dict((k, v[0]) for k, v in
+ parse_qs(urlparse(response.url).query).items())
self.assertNotIn(' ', query_values['SAMLResponse'])
self.strategy.set_request_data(query_values, self.backend)
return self.backend.complete()
def test_metadata_generation(self):
- """ Test that we can generate the metadata without error """
+ """Test that we can generate the metadata without error"""
xml, errors = self.backend.generate_metadata_xml()
self.assertEqual(len(errors), 0)
self.assertEqual(xml[0], '<')
def test_login(self):
- """ Test that we can authenticate with a SAML IdP (TestShib) """
- user = self.do_login()
+ """Test that we can authenticate with a SAML IdP (TestShib)"""
+ self.do_login()
def modify_start_url(self, start_url):
"""
@@ -92,13 +102,18 @@ class SAMLTest(BaseBackendTest):
"""
# Parse the SAML Request URL to get the XML being sent to TestShib
url_parts = urlparse(start_url)
- query = dict((k, v[0]) for (k, v) in parse_qs(url_parts.query).iteritems())
- xml = OneLogin_Saml2_Utils.decode_base64_and_inflate(query['SAMLRequest'])
+ query = dict((k, v[0]) for (k, v) in
+ parse_qs(url_parts.query).iteritems())
+ xml = OneLogin_Saml2_Utils.decode_base64_and_inflate(
+ query['SAMLRequest']
+ )
# Modify the XML:
xml, changed = re.subn(r'ID="[^"]+"', 'ID="TEST_ID"', xml)
self.assertEqual(changed, 1)
# Update the URL to use the modified query string:
- query['SAMLRequest'] = OneLogin_Saml2_Utils.deflate_and_base64_encode(xml)
+ query['SAMLRequest'] = OneLogin_Saml2_Utils.deflate_and_base64_encode(
+ xml
+ )
url_parts = list(url_parts)
url_parts[4] = urlencode(query)
return urlunparse(url_parts)
diff --git a/social/tests/models.py b/social/tests/models.py
index 80bf687..d5d193c 100644
--- a/social/tests/models.py
+++ b/social/tests/models.py
@@ -1,7 +1,7 @@
import base64
from social.storage.base import UserMixin, NonceMixin, AssociationMixin, \
- CodeMixin, BaseStorage
+ CodeMixin, BaseStorage
class BaseModel(object):
@@ -117,7 +117,9 @@ class TestUserSocialAuth(UserMixin, BaseModel):
@classmethod
def get_social_auth_for_user(cls, user, provider=None, id=None):
- return [usa for usa in user.social if provider in (None, usa.provider) and id in (None, usa.id)]
+ return [usa for usa in user.social
+ if provider in (None, usa.provider) and
+ id in (None, usa.id)]
@classmethod
def create_social_auth(cls, user, uid, provider):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git
More information about the Python-modules-commits
mailing list