Skip to content

test(backend): add component tests for ProviderConfigService #393

@fpindej

Description

@fpindej

Context

Follow-up to #368. ProviderConfigService has no direct component tests. The service is tested indirectly through OAuthProvidersControllerTests (which mock IProviderConfigService) and AesGcmEncryptionServiceTests (unit tests for the encryption layer), but the actual DB interaction paths are untested.

Scope

Add ProviderConfigServiceTests to MyProject.Component.Tests/Services/ covering:

  • GetAllAsync: DB records returned with decrypted client IDs, appsettings fallback for unconfigured providers
  • GetAllAsync: corrupted ciphertext returns null client ID (resilience path)
  • GetCredentialsAsync: cache miss loads from DB, subsequent call hits cache
  • GetCredentialsAsync: disabled provider returns null
  • GetCredentialsAsync: no DB record falls back to appsettings
  • UpsertAsync: insert new provider config (encrypts and stores)
  • UpsertAsync: update existing provider config (keeps secret when null)
  • UpsertAsync: unknown provider returns validation failure
  • UpsertAsync: cache invalidation after save
  • UpsertAsync: audit log entry created

Notes

  • Uses InMemory EF provider (existing TestDbContextFactory pattern)
  • Needs a real AesGcmEncryptionService instance (or a test double) since the service encrypts/decrypts
  • Mock HybridCache with NoOpHybridCache (already exists in test fixtures)

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend (.NET)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions