Exemplo n.º 1
0
def test_add_service_raises_if_file_exists(mock_config_paths):
    ensure_config_paths()
    secret_file = mock_config_paths[1] / 'test'
    secret_file.write_text('test data')

    with pytest.raises(FileExistsError):
        add_service('test', 'secret test', mock_config_paths[1])
Exemplo n.º 2
0
def test_ensure_config_path_not_fail_if_paths_exists(mock_config_paths):
    for path in mock_config_paths:
        path.mkdir(parents=True)

    ensure_config_paths()

    assert all(path.exists() for path in mock_config_paths)
Exemplo n.º 3
0
def test_add_service_creates_new_secret_file(mock_config_paths):
    ensure_config_paths()
    secret_file = mock_config_paths[1] / 'test'

    add_service('test', 'secret_test', mock_config_paths[1])

    assert secret_file.exists()
    assert secret_file.read_text() == 'secret_test'
Exemplo n.º 4
0
def test_retrieve_service_without_existing_secret(mock_config_paths):
    ensure_config_paths()

    with pytest.raises(FileNotFoundError):
        retrieve_service('test', mock_config_paths[1])
Exemplo n.º 5
0
def test_retrieve_service_with_existing_secret(mock_config_paths):
    ensure_config_paths()
    add_service('test', 'secret_test', mock_config_paths[1])

    assert retrieve_service('test', mock_config_paths[1]) == 'secret_test'
Exemplo n.º 6
0
def test_list_services_with_a_service(mock_config_paths):
    ensure_config_paths()
    add_service('test', 'secret_test', mock_config_paths[1])

    assert list_services(mock_config_paths[1]) == ['test']
Exemplo n.º 7
0
def test_list_services_empty(mock_config_paths):
    ensure_config_paths()

    assert list_services(mock_config_paths[1]) == []
Exemplo n.º 8
0
def test_ensure_config_paths_creates_paths(mock_config_paths):
    ensure_config_paths()

    assert all(path.exists() for path in mock_config_paths)