Skip to content

[DEV] Implement KeyVaultService abstraction #56

@artcava

Description

@artcava

Overview

Implement a IKeyVaultService abstraction and its concrete implementation wrapping Azure.Security.KeyVault.Secrets.SecretClient. This service will be consumed by LinkedInAuthService and LinkedInTokenRefresherFunction and is designed to be mockable in unit tests.

Depends on: #54

Tasks

  • Add NuGet packages to src/XPoster.csproj:
    • Azure.Security.KeyVault.Secrets
    • Azure.Identity
  • Create src/Abstraction/IKeyVaultService.cs:
public interface IKeyVaultService
{
    Task<string> GetSecretAsync(string secretName);
    Task SetSecretAsync(string secretName, string value);
}
  • Create src/Services/KeyVaultService.cs using DefaultAzureCredential (works both locally with az login and in Azure with Managed Identity)
  • Register in Program.cs as Singleton:
builder.Services.AddSingleton<IKeyVaultService, KeyVaultService>();
  • Write unit tests with mocked IKeyVaultService in tests/XPoster.Tests/Services/KeyVaultServiceTests.cs

Acceptance Criteria

  • IKeyVaultService is fully mockable
  • Local development works via az login (no hardcoded credentials)
  • Azure deployment works via Managed Identity
  • Unit tests pass

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions