Always use urljoin to construct Blender ID URLs
This commit is contained in:
@@ -220,7 +220,7 @@ def fetch_blenderid_user() -> dict:
|
|||||||
|
|
||||||
my_log = log.getChild('fetch_blenderid_user')
|
my_log = log.getChild('fetch_blenderid_user')
|
||||||
|
|
||||||
bid_url = '%s/api/user' % current_app.config['BLENDER_ID_ENDPOINT']
|
bid_url = urljoin(current_app.config['BLENDER_ID_ENDPOINT'], 'api/user')
|
||||||
my_log.debug('Fetching user info from %s', bid_url)
|
my_log.debug('Fetching user info from %s', bid_url)
|
||||||
|
|
||||||
credentials = current_app.config['OAUTH_CREDENTIALS']['blender-id']
|
credentials = current_app.config['OAUTH_CREDENTIALS']['blender-id']
|
||||||
|
@@ -140,7 +140,7 @@ class BlenderIdSignIn(OAuthSignIn):
|
|||||||
client_secret=self.consumer_secret,
|
client_secret=self.consumer_secret,
|
||||||
authorize_url=urljoin(base_url, 'oauth/authorize'),
|
authorize_url=urljoin(base_url, 'oauth/authorize'),
|
||||||
access_token_url=urljoin(base_url, 'oauth/token'),
|
access_token_url=urljoin(base_url, 'oauth/token'),
|
||||||
base_url='%s/api/' % base_url
|
base_url=urljoin(base_url, 'api/'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def authorize(self):
|
def authorize(self):
|
||||||
|
@@ -11,11 +11,7 @@ import pathlib
|
|||||||
import sys
|
import sys
|
||||||
import typing
|
import typing
|
||||||
import unittest.mock
|
import unittest.mock
|
||||||
|
from urllib.parse import urlencode, urljoin
|
||||||
try:
|
|
||||||
from urllib.parse import urlencode
|
|
||||||
except ImportError:
|
|
||||||
from urllib.parse import urlencode
|
|
||||||
|
|
||||||
from bson import ObjectId, tz_util
|
from bson import ObjectId, tz_util
|
||||||
|
|
||||||
@@ -433,7 +429,7 @@ class AbstractPillarTest(TestMinimal):
|
|||||||
"""Sets up Responses to mock unhappy validation flow."""
|
"""Sets up Responses to mock unhappy validation flow."""
|
||||||
|
|
||||||
responses.add(responses.POST,
|
responses.add(responses.POST,
|
||||||
'%s/u/validate_token' % self.app.config['BLENDER_ID_ENDPOINT'],
|
urljoin(self.app.config['BLENDER_ID_ENDPOINT'], 'u/validate_token'),
|
||||||
json={'status': 'fail'},
|
json={'status': 'fail'},
|
||||||
status=403)
|
status=403)
|
||||||
|
|
||||||
@@ -441,7 +437,7 @@ class AbstractPillarTest(TestMinimal):
|
|||||||
"""Sets up Responses to mock happy validation flow."""
|
"""Sets up Responses to mock happy validation flow."""
|
||||||
|
|
||||||
responses.add(responses.POST,
|
responses.add(responses.POST,
|
||||||
'%s/u/validate_token' % self.app.config['BLENDER_ID_ENDPOINT'],
|
urljoin(self.app.config['BLENDER_ID_ENDPOINT'], 'u/validate_token'),
|
||||||
json=BLENDER_ID_USER_RESPONSE,
|
json=BLENDER_ID_USER_RESPONSE,
|
||||||
status=200)
|
status=200)
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
"""Flask configuration file for unit testing."""
|
"""Flask configuration file for unit testing."""
|
||||||
|
|
||||||
BLENDER_ID_ENDPOINT = 'http://id.local:8001' # Non existant server
|
BLENDER_ID_ENDPOINT = 'http://id.local:8001/' # Non existant server
|
||||||
|
|
||||||
SERVER_NAME = 'localhost.local'
|
SERVER_NAME = 'localhost.local'
|
||||||
PILLAR_SERVER_ENDPOINT = 'http://localhost.local/api/'
|
PILLAR_SERVER_ENDPOINT = 'http://localhost.local/api/'
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
import pillar.tests.common_test_data as ctd
|
import pillar.tests.common_test_data as ctd
|
||||||
import responses
|
import responses
|
||||||
@@ -761,7 +762,7 @@ class UserCreationTest(AbstractPillarTest):
|
|||||||
'token_expires': 'Mon, 1 Jan 2218 01:02:03 GMT'}
|
'token_expires': 'Mon, 1 Jan 2218 01:02:03 GMT'}
|
||||||
|
|
||||||
responses.add(responses.POST,
|
responses.add(responses.POST,
|
||||||
'%s/u/validate_token' % self.app.config['BLENDER_ID_ENDPOINT'],
|
urljoin(self.app.config['BLENDER_ID_ENDPOINT'], 'u/validate_token'),
|
||||||
json=bid_resp,
|
json=bid_resp,
|
||||||
status=200)
|
status=200)
|
||||||
|
|
||||||
@@ -791,7 +792,7 @@ class UserCreationTest(AbstractPillarTest):
|
|||||||
'id': ctd.BLENDER_ID_TEST_USERID},
|
'id': ctd.BLENDER_ID_TEST_USERID},
|
||||||
'token_expires': 'Mon, 1 Jan 2218 01:02:03 GMT'}
|
'token_expires': 'Mon, 1 Jan 2218 01:02:03 GMT'}
|
||||||
responses.add(responses.POST,
|
responses.add(responses.POST,
|
||||||
'%s/u/validate_token' % self.app.config['BLENDER_ID_ENDPOINT'],
|
urljoin(self.app.config['BLENDER_ID_ENDPOINT'], 'u/validate_token'),
|
||||||
json=bid_resp,
|
json=bid_resp,
|
||||||
status=200)
|
status=200)
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
import responses
|
import responses
|
||||||
from bson import ObjectId
|
from bson import ObjectId
|
||||||
@@ -19,7 +20,7 @@ class BlenderIdSubclientTest(AbstractPillarTest):
|
|||||||
def test_store_scst_new_user_without_full_name(self):
|
def test_store_scst_new_user_without_full_name(self):
|
||||||
|
|
||||||
responses.add(responses.POST,
|
responses.add(responses.POST,
|
||||||
'%s/u/validate_token' % self.app.config['BLENDER_ID_ENDPOINT'],
|
urljoin(self.app.config['BLENDER_ID_ENDPOINT'], 'u/validate_token'),
|
||||||
json={'status': 'success',
|
json={'status': 'success',
|
||||||
'user': {'email': TEST_EMAIL_ADDRESS,
|
'user': {'email': TEST_EMAIL_ADDRESS,
|
||||||
'full_name': None,
|
'full_name': None,
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import typing
|
import typing
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
import bson
|
import bson
|
||||||
from bson import tz_util
|
from bson import tz_util
|
||||||
@@ -757,7 +758,7 @@ class UserCreationTest(AbstractPillarTest):
|
|||||||
'token_expires': 'Mon, 1 Jan 2218 01:02:03 GMT'}
|
'token_expires': 'Mon, 1 Jan 2218 01:02:03 GMT'}
|
||||||
|
|
||||||
responses.add(responses.POST,
|
responses.add(responses.POST,
|
||||||
'%s/u/validate_token' % self.app.config['BLENDER_ID_ENDPOINT'],
|
urljoin(self.app.config['BLENDER_ID_ENDPOINT'], 'u/validate_token'),
|
||||||
json=blender_id_response,
|
json=blender_id_response,
|
||||||
status=200)
|
status=200)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user