public void Test_MsiConfig_ConfigValidation() { // Arrange var msiConfig = new MsiConfig(); // Act/Assert - Check the msi config validation. Assert.Throws <ValidateException>(() => msiConfig.ThrowIfInvalid()); msiConfig.InstanceName = "test"; Assert.Throws <ValidateException>(() => msiConfig.ThrowIfInvalid()); msiConfig.TenantId = "test"; Assert.Throws <ValidateException>(() => msiConfig.ThrowIfInvalid()); msiConfig.SubscriptionId = "test"; AssertExtensions.DoesNotThrow(() => msiConfig.ThrowIfInvalid()); msiConfig.ToString().Should().NotBeNullOrEmpty(); }
/// <summary>Initializes a new instance of the KeyVault class using Managed Service Principle (MSI) security.</summary> /// <param name="config">Msi configuration for this instance.</param> public KeyVault([NotNull] MsiConfig config) { // Ensure the required config values are all set. config.ThrowIfInvalid(); MsiConfig = config; InstanceUri = config.Uri; Name = config.KeyVaultInstanceName; Config = config; }
/// <summary> /// Initializes a new instance of the <see cref="TableStorageBase"/> class. /// </summary> /// <param name="config">The configuration.</param> /// <param name="logger">The logger.</param> protected TableStorageBase(MsiConfig config, ILogger logger = null) { // Ensure all mandatory fields are set. config.ThrowIfInvalid(); Logger = logger; MsiConfig = config; Name = config.InstanceName; _instanceName = config.InstanceName; _subscriptionId = config.SubscriptionId; }
/// <summary> /// Initializes a new instance of the <see cref="CosmosStorageBase"/> class. /// </summary> /// <param name="config">The configuration.</param> /// <param name="logger">The logger.</param> protected CosmosStorageBase(MsiConfig config, ILogger logger = null) { // Validate the config. config.ThrowIfInvalid(); Logger = logger; MsiConfig = config; Name = config.InstanceName; DatabaseName = config.DatabaseName; _instanceName = config.InstanceName; _subscriptionId = config.SubscriptionId; _createIfNotExists = config.CreateDatabaseIfNotExists; _createTableNames = config.CreateTables; _maxThroughput = config.MaxThroughput; _autoscaleDatabaseThroughput = config.AutoscaleDatabaseThroughput; }
public void Test_MsiConfig_Validate() { // Arrange var msiConfig = new MsiConfig() { InstanceName = null, SubscriptionId = null, TenantId = null, Receiver = null, Sender = null }; // Act/Assert Assert.Throws <ValidateException>(() => msiConfig.ThrowIfInvalid()); Assert.Null(msiConfig.InstanceName); Assert.Null(msiConfig.Receiver); Assert.Null(msiConfig.Sender); Assert.Null(msiConfig.SubscriptionId); Assert.Null(msiConfig.TenantId); msiConfig.ToString().Should().NotBeNullOrEmpty(); }