def test_non_existent_credentials(filename, expected_retval):
    # with a non-existent credentials file
    ret = main([
        get_resource_path(filename),
        "--credentials-file=testing/resources/credentailsfilethatdoesntexist"
    ])
    assert ret == expected_retval
def test_detect_aws_credentials(filename, expected_retval):
    # with a valid credentials file
    ret = main((
        get_resource_path(filename),
        "--credentials-file=testing/resources/sample_aws_credentials",
    ))
    assert ret == expected_retval
def test_detect_aws_credentials(filename, expected_retval):
    # with a valid credentials file
    ret = main((
        get_resource_path(filename),
        '--credentials-file',
        'testing/resources/aws_config_with_multiple_sections.ini',
    ))
    assert ret == expected_retval
def test_detect_aws_credentials(filename, expected_retval):
    # with a valid credentials file
    ret = main((
        get_resource_path(filename),
        '--credentials-file',
        'testing/resources/aws_config_with_multiple_sections.ini',
    ))
    assert ret == expected_retval
def test_detect_aws_credentials(filename, expected_retval):
    """Test if getting configured AWS secrets from files to be checked in works."""

    # with a valid credentials file
    ret = main((
        get_resource_path(filename),
        "--credentials-file=testing/resources/aws_config_with_multiple_sections.ini",
    ))
    assert ret == expected_retval
def test_detect_aws_credentials(filename, expected_retval):
    """Test if getting configured AWS secrets from files to be checked in works."""

    # with a valid credentials file
    ret = main((
        get_resource_path(filename),
        "--credentials-file=testing/resources/aws_config_with_multiple_sections.ini",
    ))
    assert ret == expected_retval
def test_non_existent_credentials_with_allow_flag(mock_secrets_env,
                                                  mock_secrets_file):
    """Test behavior with no configured AWS secrets and flag to allow when missing."""
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main(
        (get_resource_path('aws_config_without_secrets.ini'),
         "--credentials-file=testing/resources/credentailsfilethatdoesntexist",
         "--allow-missing-credentials"))
    assert ret == 0
def test_non_existent_credentials_with_allow_flag(mock_secrets_env, mock_secrets_file):
    """Test behavior with no configured AWS secrets and flag to allow when missing."""
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main((
        get_resource_path('aws_config_without_secrets.ini'),
        "--credentials-file=testing/resources/credentailsfilethatdoesntexist",
        "--allow-missing-credentials",
    ))
    assert ret == 0
def test_allows_arbitrarily_encoded_files(tmpdir):
    src_ini = tmpdir.join('src.ini')
    src_ini.write(
        '[default]\n'
        'aws_access_key_id=AKIASDFASDF\n'
        'aws_secret_Access_key=9018asdf23908190238123\n', )
    arbitrary_encoding = tmpdir.join('f')
    arbitrary_encoding.write_binary(b'\x12\x9a\xe2\xf2')
    ret = main((str(arbitrary_encoding), '--credentials-file', str(src_ini)))
    assert ret == 0
Beispiel #10
0
def test_non_existent_credentials_with_allow_flag(
        mock_secrets_env, mock_secrets_file,
):
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main((
        get_resource_path('aws_config_without_secrets.ini'),
        '--credentials-file=testing/resources/credentailsfilethatdoesntexist',
        '--allow-missing-credentials',
    ))
    assert ret == 0
def test_non_existent_credentials_with_allow_flag(
        mock_secrets_env, mock_secrets_file,
):
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main((
        get_resource_path('aws_config_without_secrets.ini'),
        '--credentials-file=testing/resources/credentailsfilethatdoesntexist',
        '--allow-missing-credentials',
    ))
    assert ret == 0
def test_non_existent_credentials(capsys):
    # with a non-existent credentials file
    ret = main(
        (get_resource_path("with_secrets.txt"), "--credentials-file=testing/resources/credentailsfilethatdoesntexist")
    )
    assert ret == 2
    out, _ = capsys.readouterr()
    assert out == (
        "No aws keys were configured at "
        "testing/resources/credentailsfilethatdoesntexist\n"
        "Configure them with --credentials-file\n"
    )
def test_non_existent_credentials(mock_secrets_env, mock_secrets_file, capsys):
    """Test behavior with no configured AWS secrets."""
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main((
        get_resource_path('aws_config_without_secrets.ini'),
        "--credentials-file=testing/resources/credentailsfilethatdoesntexist"))
    assert ret == 2
    out, _ = capsys.readouterr()
    assert out == ('No AWS keys were found in the configured credential files '
                   'and environment variables.\nPlease ensure you have the '
                   'correct setting for --credentials-file\n')
def test_non_existent_credentials(capsys):
    # with a non-existent credentials file
    ret = main((
        get_resource_path('with_secrets.txt'),
        "--credentials-file=testing/resources/credentailsfilethatdoesntexist"
    ))
    assert ret == 2
    out, _ = capsys.readouterr()
    assert out == (
        'No aws keys were configured at '
        'testing/resources/credentailsfilethatdoesntexist\n'
        'Configure them with --credentials-file\n'
    )
def test_non_existent_credentials(mock_secrets_env, mock_secrets_file, capsys):
    """Test behavior with no configured AWS secrets."""
    mock_secrets_env.return_value = set()
    mock_secrets_file.return_value = set()
    ret = main((
        get_resource_path('aws_config_without_secrets.ini'),
        "--credentials-file=testing/resources/credentailsfilethatdoesntexist",
    ))
    assert ret == 2
    out, _ = capsys.readouterr()
    assert out == (
        'No AWS keys were found in the configured credential files '
        'and environment variables.\nPlease ensure you have the '
        'correct setting for --credentials-file\n'
    )
def test_non_existent_credentials(filename, expected_retval):
    # with a non-existent credentials file
    ret = main(
        [get_resource_path(filename), "--credentials-file=testing/resources/credentailsfilethatdoesntexist"]
    )
    assert ret == expected_retval
def test_detect_aws_credentials(filename, expected_retval):
    # with a valid credentials file
    ret = main((get_resource_path(filename), "--credentials-file=testing/resources/sample_aws_credentials"))
    assert ret == expected_retval