Exemple #1
0
def test_get_token_error(mock_requests):
    mock_requests.get.return_value.ok = True
    mock_requests.get.return_value.json.return_value = {
        "error": "Bad verification code"
    }
    provider = OAuthProvider("microsoft", config)
    state = "one"

    with pytest.raises(BadVerification):
        provider.get_token("xxxxxx", state)
def test_get_token(mock_requests, token):
    mock_requests.post.return_value.ok = True
    mock_requests.post.return_value.json.return_value = token
    code = "__testcode__"
    provider = OAuthProvider("google", config)
    auth_token = provider.get_token(code)

    if auth_token.get("access_token") != "123":
        raise AssertionError

    if auth_token.get("token_type") != "Bearer":
        raise AssertionError
Exemple #3
0
def test_get_token(mock_requests):
    mock_requests.post.return_value.ok = True
    mock_requests.post.return_value.json.return_value = {
        "access_token": "xb56ksf",
    }
    provider = OAuthProvider("bitbucket", config)
    code = "one"
    state = "user_state"
    token = provider.get_token(code, state)

    if token.get("access_token") != "xb56ksf":
        raise AssertionError
def test_get_token(mock_requests):
    mock_requests.get.return_value.ok = True
    mock_requests.get.return_value.json.return_value = {
        "access_token": "******",
        "id": "token_id",
        "expires": "timestamp",
    }
    provider = OAuthProvider("facebook", config)
    state = "one"
    code = "oauth_code"
    token = provider.get_token(code, state)

    if token.get("access_token") != "******":
        raise AssertionError