Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion social_core/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_user_names(self, fullname="", first_name="", last_name=""):
except ValueError:
first_name = first_name or fullname or ""
last_name = last_name or ""
fullname = fullname or " ".join((first_name, last_name))
fullname = fullname or f"{first_name} {last_name}"
return fullname.strip(), first_name.strip(), last_name.strip()

def get_user(self, user_id):
Expand Down
4 changes: 1 addition & 3 deletions social_core/backends/lastfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def auth_complete(self, *args, **kwargs):
token = self.data["token"]

signature = hashlib.md5(
"".join(
("api_key", key, "methodauth.getSession", "token", token, secret)
).encode()
f"api_key{key}methodauth.getSessiontoken{token}{secret}".encode()
).hexdigest()

response = self.get_json(
Expand Down
2 changes: 1 addition & 1 deletion social_core/backends/yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class YahooOAuth2(BaseOAuth2):

def get_user_names(self, first_name, last_name):
if first_name or last_name:
return " ".join((first_name, last_name)), first_name, last_name
return f"{first_name} {last_name}", first_name, last_name
return None, None, None

def get_user_details(self, response):
Expand Down
44 changes: 17 additions & 27 deletions social_core/tests/backends/test_livejournal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@
class LiveJournalOpenIdTest(OpenIdTest):
backend_path = "social_core.backends.livejournal.LiveJournalOpenId"
expected_username = "foobar"
discovery_body = "".join(
[
'<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">',
"<XRD>",
'<Service priority="0">',
"<Type>http://specs.openid.net/auth/2.0/signon</Type>",
"<URI>http://www.livejournal.com/openid/server.bml</URI>",
"<LocalID>http://foobar.livejournal.com/</LocalID>",
"</Service>",
"</XRD>",
"</xrds:XRDS>",
]
)
discovery_body = """<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/signon</Type>
<URI>http://www.livejournal.com/openid/server.bml</URI>
<LocalID>http://foobar.livejournal.com/</LocalID>
</Service>
</XRD>
</xrds:XRDS>"""
server_response = urlencode(
{
"janrain_nonce": JANRAIN_NONCE,
Expand All @@ -44,20 +40,14 @@ class LiveJournalOpenIdTest(OpenIdTest):
"openid.sig": "Z8MOozVPTOBhHG5ZS1NeGofxs1Q=",
}
)
server_bml_body = "\n".join(
[
"assoc_handle:1364935340:ZhruPQ7DJ9eGgUkeUA9A:27f8c32464",
"assoc_type:HMAC-SHA1",
"dh_server_public:WzsRyLomvAV3vwvGUrfzXDgfqnTF+m1l3JWb55fyHO7visPT4tmQ"
"iTjqFFnSVAtAOvQzoViMiZQisxNwnqSK4lYexoez1z6pP5ry3pqxJAEYj60vFGvRztict"
"Eo0brjhmO1SNfjK1ppjOymdykqLpZeaL5fsuLtMCwTnR/JQZVA=",
"enc_mac_key:LiOEVlLJSVUqfNvb5zPd76nEfvc=",
"expires_in:1207060",
"ns:http://specs.openid.net/auth/2.0",
"session_type:DH-SHA1",
"",
]
)
server_bml_body = """assoc_handle:1364935340:ZhruPQ7DJ9eGgUkeUA9A:27f8c32464
assoc_type:HMAC-SHA1
dh_server_public:WzsRyLomvAV3vwvGUrfzXDgfqnTF+m1l3JWb55fyHO7visPT4tmQiTjqFFnSVAtAOvQzoViMiZQisxNwnqSK4lYexoez1z6pP5ry3pqxJAEYj60vFGvRztictEo0brjhmO1SNfjK1ppjOymdykqLpZeaL5fsuLtMCwTnR/JQZVA=
enc_mac_key:LiOEVlLJSVUqfNvb5zPd76nEfvc=
expires_in:1207060
ns:http://specs.openid.net/auth/2.0
session_type:DH-SHA1
"""

def openid_url(self):
return super().openid_url() + "/data/yadis"
Expand Down
41 changes: 17 additions & 24 deletions social_core/tests/backends/test_ngpvan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,23 @@ class NGPVANActionIDOpenIDTest(OpenIdTest):

backend_path = "social_core.backends.ngpvan.ActionIDOpenID"
expected_username = "[email protected]"
discovery_body = " ".join(
[
'<?xml version="1.0" encoding="UTF-8"?>',
"<xrds:XRDS",
'xmlns:xrds="xri://$xrds"',
'xmlns:openid="http://openid.net/xmlns/1.0"',
'xmlns="xri://$xrd*($v*2.0)">',
"<XRD>",
'<Service priority="10">',
"<Type>http://specs.openid.net/auth/2.0/signon</Type>",
"<Type>http://openid.net/extensions/sreg/1.1</Type>",
"<Type>http://axschema.org/contact/email</Type>",
"<URI>https://accounts.ngpvan.com/OpenId/Provider</URI>",
"</Service>",
'<Service priority="20">',
"<Type>http://openid.net/signon/1.0</Type>",
"<Type>http://openid.net/extensions/sreg/1.1</Type>",
"<Type>http://axschema.org/contact/email</Type>",
"<URI>https://accounts.ngpvan.com/OpenId/Provider</URI>",
"</Service>",
"</XRD>",
"</xrds:XRDS>",
]
)
discovery_body = """<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns:openid="http://openid.net/xmlns/1.0" xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="10">
<Type>http://specs.openid.net/auth/2.0/signon</Type>
<Type>http://openid.net/extensions/sreg/1.1</Type>
<Type>http://axschema.org/contact/email</Type>
<URI>https://accounts.ngpvan.com/OpenId/Provider</URI>
</Service>
<Service priority="20">
<Type>http://openid.net/signon/1.0</Type>
<Type>http://openid.net/extensions/sreg/1.1</Type>
<Type>http://axschema.org/contact/email</Type>
<URI>https://accounts.ngpvan.com/OpenId/Provider</URI>
</Service>
</XRD>
</xrds:XRDS>"""
server_response = urlencode(
{
"openid.claimed_id": "https://accounts.ngpvan.com/user/abcd123",
Expand Down
2 changes: 1 addition & 1 deletion social_core/tests/backends/test_open_id_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def prepare_access_token_body(
header, msg, sig = body["id_token"].split(".")
id_token["sub"] = "1235"
msg = base64.encodebytes(json.dumps(id_token).encode()).decode()
body["id_token"] = ".".join([header, msg, sig])
body["id_token"] = f"{header}.{msg}.{sig}"

return json.dumps(body)

Expand Down
44 changes: 18 additions & 26 deletions social_core/tests/backends/test_steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,24 @@
class SteamOpenIdTest(OpenIdTest):
backend_path = "social_core.backends.steam.SteamOpenId"
expected_username = "foobar"
discovery_body = "".join(
[
'<?xml version="1.0" encoding="UTF-8"?>',
'<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">',
"<XRD>",
'<Service priority="0">',
"<Type>http://specs.openid.net/auth/2.0/server</Type>",
"<URI>https://steamcommunity.com/openid/login</URI>",
"</Service>",
"</XRD>",
"</xrds:XRDS>",
]
)
user_discovery_body = "".join(
[
'<?xml version="1.0" encoding="UTF-8"?>',
'<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">',
"<XRD>",
'<Service priority="0">',
"<Type>http://specs.openid.net/auth/2.0/signon</Type> ",
"<URI>https://steamcommunity.com/openid/login</URI>",
"</Service>",
"</XRD>",
"</xrds:XRDS>",
]
)
discovery_body = """<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/server</Type>
<URI>https://steamcommunity.com/openid/login</URI>
</Service>
</XRD>
</xrds:XRDS>"""
user_discovery_body = """<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/signon</Type>
<URI>https://steamcommunity.com/openid/login</URI>
</Service>
</XRD>
</xrds:XRDS>"""
server_response = urlencode(
{
"janrain_nonce": JANRAIN_NONCE,
Expand Down
Loading