Пример #1
0
def test__run_next_challenge_not_supported():
    challenges_response = copy.deepcopy(CHALLENGES_RESPONSE_TEMPLATE)
    challenges_response["challenges"][0][
        "challengeType"] = "CHALLENGE_TYPE_UNSPECIFIED"
    with pytest.raises(exceptions.ReauthFailError) as excinfo:
        reauth._run_next_challenge(challenges_response, MOCK_REQUEST, "token")
    assert excinfo.match(
        r"Unsupported challenge type CHALLENGE_TYPE_UNSPECIFIED")
Пример #2
0
def test__run_next_challenge_not_locally_eligible():
    mock_challenge = MockChallenge("PASSWORD", False, "challenge_input")
    with mock.patch("google.oauth2.challenges.AVAILABLE_CHALLENGES",
                    {"PASSWORD": mock_challenge}):
        with pytest.raises(exceptions.ReauthFailError) as excinfo:
            reauth._run_next_challenge(CHALLENGES_RESPONSE_TEMPLATE,
                                       MOCK_REQUEST, "token")
        assert excinfo.match(r"Challenge PASSWORD is not locally eligible")
Пример #3
0
def test__run_next_challenge_success():
    mock_challenge = MockChallenge("PASSWORD", True,
                                   {"credential": "password"})
    with mock.patch("google.oauth2.challenges.AVAILABLE_CHALLENGES",
                    {"PASSWORD": mock_challenge}):
        with mock.patch("google.oauth2.reauth._send_challenge_result"
                        ) as mock_send_challenge_result:
            reauth._run_next_challenge(CHALLENGES_RESPONSE_TEMPLATE,
                                       MOCK_REQUEST, "token")
            mock_send_challenge_result.assert_called_with(
                MOCK_REQUEST, "123", 1, {"credential": "password"}, "token")
Пример #4
0
def test__run_next_challenge_no_challenge_input():
    mock_challenge = MockChallenge("PASSWORD", True, None)
    with mock.patch("google.oauth2.challenges.AVAILABLE_CHALLENGES",
                    {"PASSWORD": mock_challenge}):
        assert (reauth._run_next_challenge(CHALLENGES_RESPONSE_TEMPLATE,
                                           MOCK_REQUEST, "token") is None)
Пример #5
0
def test__run_next_challenge_not_ready():
    challenges_response = copy.deepcopy(CHALLENGES_RESPONSE_TEMPLATE)
    challenges_response["challenges"][0]["status"] = "STATUS_UNSPECIFIED"
    assert (reauth._run_next_challenge(challenges_response, MOCK_REQUEST,
                                       "token") is None)