"""Shared fixtures for willian-secrets tests."""

from __future__ import annotations

import pytest

from vault.config import SecretsConfig, init_secrets, reset_secrets
from vault.encryption import AESGCMEncryption, FernetEncryption
from vault.store import InMemorySecretStore

MASTER_PASSWORD = "test-master-password-for-secrets"


@pytest.fixture(autouse=True)
def _reset_global_state():
    """Ensure each test starts with a clean global singleton."""
    reset_secrets()
    yield
    reset_secrets()


@pytest.fixture()
def fernet():
    return FernetEncryption(master_password=MASTER_PASSWORD)


@pytest.fixture()
def aesgcm():
    return AESGCMEncryption(master_password=MASTER_PASSWORD)


@pytest.fixture()
def memory_store(fernet):
    return InMemorySecretStore(fernet)


@pytest.fixture()
def secrets_config():
    return SecretsConfig(master_key=MASTER_PASSWORD)


@pytest.fixture()
def initialized_secrets(secrets_config):
    return init_secrets(secrets_config)
