-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into send_notification_e…
- Loading branch information
Showing
15 changed files
with
174 additions
and
36 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
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
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from django.apps import AppConfig | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from allauth import app_settings | ||
|
||
|
||
class SocialAccountConfig(AppConfig): | ||
name = "allauth.socialaccount" | ||
verbose_name = _("Social Accounts") | ||
default_auto_field = "django.db.models.AutoField" | ||
default_auto_field = app_settings.DEFAULT_AUTO_FIELD or "django.db.models.AutoField" |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from unittest.mock import patch | ||
from unittest.mock import Mock, patch | ||
from urllib.parse import parse_qs, urlparse | ||
|
||
from django.urls import reverse | ||
|
@@ -7,6 +7,7 @@ | |
import pytest | ||
|
||
from allauth.account.models import EmailAddress | ||
from allauth.socialaccount.adapter import get_adapter | ||
from allauth.socialaccount.models import SocialAccount | ||
from allauth.socialaccount.providers.saml.utils import build_saml_config | ||
|
||
|
@@ -166,3 +167,36 @@ def test_build_saml_config(rf, provider_config): | |
assert config["idp"]["x509cert"] == "cert" | ||
assert config["idp"]["singleSignOnService"] == {"url": "https://idp.org/sso/"} | ||
assert config["idp"]["singleLogoutService"] == {"url": "https://idp.saml.org/slo/"} | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, result, uid", | ||
[ | ||
( | ||
{"urn:oasis:names:tc:SAML:attribute:subject-id": ["123"]}, | ||
{"uid": "123", "email": "[email protected]"}, | ||
"123", | ||
), | ||
({}, {"email": "[email protected]"}, "[email protected]"), | ||
], | ||
) | ||
def test_extract_attributes(db, data, result, uid, settings): | ||
settings.SOCIALACCOUNT_PROVIDERS = { | ||
"saml": { | ||
"APPS": [ | ||
{ | ||
"client_id": "org", | ||
"provider_id": "urn:dev-123.us.auth0.com", | ||
} | ||
] | ||
} | ||
} | ||
provider = get_adapter().get_provider(request=None, provider="saml") | ||
onelogin_data = Mock() | ||
onelogin_data.get_attributes.return_value = data | ||
onelogin_data.get_nameid.return_value = "[email protected]" | ||
onelogin_data.get_nameid_format.return_value = ( | ||
"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | ||
) | ||
assert provider._extract(onelogin_data) == result | ||
assert provider.extract_uid(onelogin_data) == uid |
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 |
---|---|---|
|
@@ -11,18 +11,15 @@ def get_mocked_response(self): | |
return MockedResponse( | ||
200, | ||
""" | ||
{"access_token": "12345678abcdef", | ||
"refresh_token": "12345678abcdef", | ||
"token_type": "bearer", | ||
"expires_in": 28800, | ||
"appcp": "sharefile.com", | ||
"apicp": "sharefile.com", | ||
"subdomain": "example", | ||
"access_files_folders": true, | ||
"modify_files_folders": true, | ||
"admin_users": true, | ||
"admin_accounts": true, | ||
"change_my_settings": true, | ||
"web_app_login": true} | ||
""", | ||
{ | ||
"Id": "123", | ||
"Email":"[email protected]", | ||
"FirstName":"Name", | ||
"LastName":"Last Name", | ||
"Company":"Company", | ||
"DefaultZone": | ||
{ | ||
"Id":"zoneid" | ||
} | ||
} """, | ||
) |
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,8 @@ | ||
Configuration | ||
============= | ||
|
||
Available settings: | ||
|
||
``ALLAUTH_DEFAULT_AUTO_FIELD`` | ||
Can be set to configure the primary key of all models. For | ||
example: ``"hashid_field.HashidAutoField"``. |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ Common Functionality | |
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
configuration | ||
templates | ||
messages | ||
|
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