Exemple #1
0
def test_default_fxa_register_url_with_state():
    path = "/en-US/addons/abp/?source=ddg"
    request = RequestFactory().get(path)
    request.session = {"fxa_state": "myfxastate"}
    raw_url = utils.default_fxa_register_url(request)
    url = urlparse.urlparse(raw_url)
    base = "{scheme}://{netloc}{path}".format(scheme=url.scheme, netloc=url.netloc, path=url.path)
    assert base == "https://accounts.firefox.com/oauth/authorization"
    query = urlparse.parse_qs(url.query)
    next_path = urlsafe_b64encode(path).rstrip("=")
    assert query == {
        "action": ["signup"],
        "client_id": ["foo"],
        "redirect_url": ["https://testserver/fxa"],
        "scope": ["profile"],
        "state": ["myfxastate:{next_path}".format(next_path=next_path)],
    }
Exemple #2
0
def test_default_fxa_register_url_with_state():
    path = '/en-US/addons/abp/?source=ddg'
    request = RequestFactory().get(path)
    request.session = {'fxa_state': 'myfxastate'}
    raw_url = utils.default_fxa_register_url(request)
    url = urlparse(raw_url)
    base = '{scheme}://{netloc}{path}'.format(
        scheme=url.scheme, netloc=url.netloc, path=url.path
    )
    assert base == 'https://accounts.firefox.com/oauth/authorization'
    query = parse_qs(url.query)
    next_path = urlsafe_b64encode(force_bytes(path)).rstrip(b'=')
    assert query == {
        'action': ['signup'],
        'client_id': ['foo'],
        'scope': ['profile openid'],
        'state': ['myfxastate:{next_path}'.format(next_path=force_str(next_path))],
    }
def test_default_fxa_register_url_with_state():
    path = '/en-US/addons/abp/?source=ddg'
    request = RequestFactory().get(path)
    request.session = {'fxa_state': 'myfxastate'}
    raw_url = utils.default_fxa_register_url(request)
    url = urlparse.urlparse(raw_url)
    base = '{scheme}://{netloc}{path}'.format(
        scheme=url.scheme, netloc=url.netloc, path=url.path)
    assert base == 'https://accounts.firefox.com/oauth/authorization'
    query = urlparse.parse_qs(url.query)
    next_path = urlsafe_b64encode(path).rstrip('=')
    assert query == {
        'action': ['signup'],
        'client_id': ['foo'],
        'redirect_url': ['https://testserver/fxa'],
        'scope': ['profile'],
        'state': ['myfxastate:{next_path}'.format(next_path=next_path)],
    }
Exemple #4
0
def register_link(context):
    return utils.default_fxa_register_url(context['request'])