Esempio n. 1
0
def test_get_user(mock_requests):
    mock_requests.get.return_value.ok = True
    mock_requests.get.return_value.json.return_value = {
        "account_id":
        "xb56ksf",
        "name":
        "John Doe",
        "values": [
            {
                "is_primary": True,
                "type": "email",
                "email": "*****@*****.**",
            },
        ],
    }
    provider = OAuthProvider("bitbucket", config)
    user = provider.get_user("xxxxxx")

    if user.get("provider") != "bitbucket":
        raise AssertionError

    if user.get("id") != "xb56ksf":
        raise AssertionError

    if user.get("email") != "*****@*****.**":
        raise AssertionError
def test_get_user_google(mock_requests):
    mock_requests.get.return_value.ok = True
    mock_requests.get.return_value.json.return_value = {
        "sub": "103",
        "name": "John Doe",
        "email": "*****@*****.**",
    }
    provider = OAuthProvider("google", config)
    user = provider.get_user("xxxxxx")

    if user.get("provider") != "google":
        raise AssertionError

    if user.get("id") != "103":
        raise AssertionError

    if user.get("email") != "*****@*****.**":
        raise AssertionError
Esempio n. 3
0
def test_get_user(mock_requests):
    mock_requests.get.return_value.ok = True
    mock_requests.get.return_value.json.return_value = {
        "id": "xb56ksf",
        "name": "John Doe",
        "userPrincipalName": "*****@*****.**",
    }
    provider = OAuthProvider("microsoft", config)
    user = provider.get_user("xxxxxx")

    if user.get("provider") != "microsoft":
        raise AssertionError

    if user.get("id") != "xb56ksf":
        raise AssertionError

    if user.get("email") != "*****@*****.**":
        raise AssertionError
Esempio n. 4
0
def test_get_user(mock_requests):
    mock_requests.get.return_value.ok = True
    mock_requests.get.return_value.json.return_value = {
        "id": "103",
        "name": "John Doe",
        "login": "******",
        "email": None,
    }
    provider = OAuthProvider("github", config)
    user = provider.get_user("xxxxxx")

    if user.get("provider") != "github":
        raise AssertionError

    if user.get("id") != "103":
        raise AssertionError

    if user.get("username") != "johndoe":
        raise AssertionError