misc: use frontoffice_url to compute orig parameter (#12381)
This commit is contained in:
parent
ed0a4c49a5
commit
16ce4fc880
|
@ -23,7 +23,7 @@ from wcs.data_sources import NamedDataSource
|
|||
from wcs.workflows import Workflow, EditableWorkflowStatusItem, WorkflowBackofficeFieldsFormDef
|
||||
from wcs.wf.jump import JumpWorkflowStatusItem
|
||||
from wcs import fields, qommon
|
||||
from wcs.api_utils import sign_url
|
||||
from wcs.api_utils import sign_url, get_secret_and_orig
|
||||
|
||||
from utilities import get_app, create_temporary_pub, clean_temporary_pub
|
||||
|
||||
|
@ -1334,3 +1334,20 @@ def test_workflow_trigger(pub, local_user):
|
|||
formdata.store() # (will get back to wf-st1)
|
||||
resp = get_app(pub).post(sign_uri(formdata.get_url() + 'jump/trigger/XXX'),
|
||||
status=403)
|
||||
|
||||
@pytest.fixture(params=['sql', 'pickle'])
|
||||
def no_request_pub(request):
|
||||
pub = create_temporary_pub(sql_mode=bool(request.param == 'sql'))
|
||||
pub.app_dir = os.path.join(pub.APP_DIR, 'example.net')
|
||||
pub.set_config()
|
||||
|
||||
open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w').write('''
|
||||
[wscall-secrets]
|
||||
api.example.com = 1234
|
||||
''')
|
||||
return pub
|
||||
|
||||
def test_get_secret_and_orig(no_request_pub):
|
||||
secret, orig = get_secret_and_orig('https://api.example.com/endpoint/')
|
||||
assert secret == '1234'
|
||||
assert orig == 'example.net'
|
||||
|
|
|
@ -131,7 +131,8 @@ class MissingSecret(Exception):
|
|||
|
||||
|
||||
def get_secret_and_orig(url):
|
||||
orig = get_request().get_server().split(':')[0]
|
||||
frontoffice_url = get_publisher().get_frontoffice_url()
|
||||
orig = urlparse.urlparse(frontoffice_url).netloc.rsplit('@', 1)[-1].rsplit(':', 1)[0]
|
||||
target_orig = urlparse.urlparse(url).netloc.rsplit('@', 1)[-1].rsplit(':', 1)[0]
|
||||
secret = get_publisher().get_site_option(target_orig, 'wscall-secrets')
|
||||
if not secret:
|
||||
|
|
Loading…
Reference in New Issue