Esempio n. 1
0
def test_authenticate_cli_passed_credentials_success(secret_mock):
    fortify_auth = FortifyAuth()
    username, password = fortify_auth.authenticate("cli_username",
                                                   "cli_password")

    assert username == "cli_username"
    assert password == "cli_password"
Esempio n. 2
0
def test_authenticate_read_from_config_success(secret_mock):
    # have the config read the following values
    secret_mock.return_value.get.side_effect = [
        "config_username", "config_password"
    ]
    fortify_auth = FortifyAuth()

    # None, None means no cli passed credentials
    username, password = fortify_auth.authenticate(None, None)

    assert username == "config_username"
    assert password == "config_password"
Esempio n. 3
0
def test_authenticate_prompt_user_success(secret_mock, auth_prompt_mock):
    # When
    secret_mock.return_value.get.side_effect = [None, None]
    auth_prompt_mock.return_value = ("prompt_username", "prompt_password")

    # Given
    fortify_auth = FortifyAuth()
    # None, None means no cli passed credentials
    username, password = fortify_auth.authenticate(None, None)

    # Expect
    assert username == "prompt_username"
    assert password == "prompt_password"