コード例 #1
0
ファイル: oauth.py プロジェクト: jmblakl/test-suite
def step_impl(context):
    config = context.vendor_config['auth']
    if 'cancel_steps' not in config:
        context.scenario.skip(reason=ERROR_NO_CANCEL)
        return

    config['authorize_steps'] = config['cancel_steps']
    urls = fhir.get_oauth_uris(context.conformance)
    authorizer = authorize.Authorizer(config=context.vendor_config['auth'],
                                      authorize_url=urls['authorize'])
    with authorizer:
        parameters = authorizer.launch_params

        try:
            authorizer.ask_for_authorization(parameters)
            response = authorizer.provide_user_input()
        except authorize.ReturnedErrorException as err:
            # This is actually what we want to happen
            response = authorizer.runner.get_query()
        except authorize.AuthorizationException as err:
            error = ERROR_SELENIUM_SCREENSHOT.format(
                err.args[0],
                err.args[1],
                err.args[2],
                context.vendor_config['host'],
            )
            assert False, error

    context.authorizer = authorizer
    context.authorization_sent = parameters
    context.authorization_received = response
コード例 #2
0
ファイル: oauth.py プロジェクト: jmblakl/test-suite
def step_impl(context, action, resource_type):

    assert action in AUTHORIZATION_ACTIONS
    assert resource_type in s4s.MU_CCDS_MAPPINGS

    # Filter the steps to only what is required for this authorization
    condition = '{0}.{1}'.format(action, resource_type)
    steps = context.vendor_config['auth'].get('steps', [])
    steps = [
        step for step in steps
        if 'when' not in step or step['when'] == condition
    ]
    context.vendor_config['auth']['steps'] = steps

    # Construct a modified authorizer
    urls = fhir.get_oauth_uris(context.conformance)
    authorizer = authorize.Authorizer(config=context.vendor_config['auth'],
                                      authorize_url=urls['authorize'])
    context.oauth.authorizer = authorizer

    # Authorize the app as usual
    try:
        context.code = context.oauth.request_authorization()
    except authorize.AuthorizationException as err:
        error = ERROR_SELENIUM_SCREENSHOT.format(
            err.args[0],
            err.args[1],
            err.args[2],
            context.vendor_config['host'],
        )
        assert False, error
コード例 #3
0
ファイル: oauth.py プロジェクト: kpshek/test-suite
def step_impl(context):
    urls = fhir.get_oauth_uris(context.conformance)
    authorizer = authorize.Authorizer(config=context.vendor_config['auth'],
                                      authorize_url=urls['authorize'])
    with authorizer:
        parameters = authorizer.launch_params
        parameters.update(dict(context.table))

        try:
            authorizer.ask_for_authorization(parameters)
            response = authorizer.provide_user_input()
        except authorize.AuthorizationException as err:
            error = ERROR_SELENIUM_SCREENSHOT.format(
                err.args[0],
                err.args[1],
                context.vendor_config['host'],
            )
            assert False, error

    context.authorizer = authorizer
    context.authorization_sent = parameters
    context.authorization_received = response