def test_should_keep_get_query_string_from_redirect_uri_when_adding_code_parameter():
    url = build_authorize_url({'client_id': 'client-id',
                               'response_type': 'code',
                               'redirect_uri': 'http://callback?param1=value1'})
    resp = requests.get(url, allow_redirects=False)
    assert_status_code(resp, 302)

    url_parts = urlparse.urlparse(resp.headers['location'])
    assert 'callback' == url_parts.netloc
    assert ['code','param1'] == urlparse.parse_qs(url_parts.query).keys()
Пример #2
0
def test_should_keep_get_query_string_from_redirect_uri_when_adding_code_parameter(
):
    url = build_authorize_url({
        'client_id': 'client-id',
        'response_type': 'code',
        'redirect_uri': 'http://callback?param1=value1'
    })
    resp = requests.get(url, allow_redirects=False)
    assert_status_code(resp, 302)

    url_parts = urlparse.urlparse(resp.headers['location'])
    assert 'callback' == url_parts.netloc
    assert ['code', 'param1'] == urlparse.parse_qs(url_parts.query).keys()
def test_should_redirect_to_redirect_uri_with_authorization_code_from_plugin():
    http = requests.session()
    url = build_authorize_url({'client_id': 'client-id-verify-access',
                               'response_type': 'code',
                               'redirect_uri': 'http://callback'})
    resp = http.get(url)

    assert 200 == resp.status_code
    assert 'Hello resource owner, do you allow this client to access your resources?' in resp.content

    resp = http.post(url, data={'allow': 'yes'})

    assert_status_code(resp, 302)
    assert resp.headers['Location'].startswith('http://callback?code=authorization-code-')
Пример #4
0
def test_should_redirect_to_redirect_uri_with_authorization_code_from_plugin():
    http = requests.session()
    url = build_authorize_url({
        'client_id': 'client-id-verify-access',
        'response_type': 'code',
        'redirect_uri': 'http://callback'
    })
    resp = http.get(url)

    assert 200 == resp.status_code
    assert 'Hello resource owner, do you allow this client to access your resources?' in resp.content

    resp = http.post(url, data={'allow': 'yes'})

    assert_status_code(resp, 302)
    assert resp.headers['Location'].startswith(
        'http://callback?code=authorization-code-')