Skip to content

[Admin] Add Test Codes for AddTableStorageService #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

sikutisa
Copy link
Contributor


Subscription

  • ApiApp의 ServiceCollectionExtensions.cs에 있는 AddTableStorageService에 대한 테스트코드 입니다.
    public static IServiceCollection AddTableStorageService(this IServiceCollection services)
    {
    services.AddSingleton<TableServiceClient>(sp => {
    var configuration = sp.GetService<IConfiguration>()
    ?? throw new InvalidOperationException($"{nameof(IConfiguration)} service is not registerd.");
    var settings = configuration.GetSection(AzureSettings.Name).GetSection(KeyVaultSettings.Name).Get<KeyVaultSettings>()
    ?? throw new InvalidOperationException($"{nameof(KeyVaultSettings)} could not be retrieved from the configuration.");
    var clientSecret = sp.GetService<SecretClient>()
    ?? throw new InvalidOperationException($"{nameof(SecretClient)} service is not registered.");
    if (string.IsNullOrWhiteSpace(settings.SecretNames[KeyVaultSecretNames.Storage]) == true)
    {
    throw new InvalidOperationException($"{nameof(KeyVaultSettings.SecretNames)}.{KeyVaultSecretNames.Storage} is not defined.");
    }
    var storageKeyVault = clientSecret.GetSecret(settings.SecretNames[KeyVaultSecretNames.Storage]!);
    var client = new TableServiceClient(storageKeyVault.Value.Value);
    return client;
    });
    return services;
    }

Discussion

  • AddTableStorageService에서 ConnectionString에 대한 Validation 체크를 할 필요가 없나요? 아니면 @tae0y 님이 작업하신 부분에서 체크가 돼서 KeyVault에 저장되고 있는 상황인 건가요?

Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

@justinyoo justinyoo merged commit 4edf7a8 into aliencube:main Sep 13, 2024
1 check passed
@sikutisa sikutisa deleted the feature/300-add-tests branch September 13, 2024 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Admin] 스토리지 커넥션 개체 생성
2 participants