public void Test_ServicePrincipleConfig_Validate()
        {
            // Arrange
            var spConfig = new ServicePrincipleConfig()
            {
                InstanceName   = null,
                SubscriptionId = null,
                TenantId       = null,
                AppId          = null,
                AppSecret      = null,
                Sender         = null,
                Receiver       = null
            };

            // Act/Assert
            Assert.Throws <ValidateException>(() => spConfig.ThrowIfInvalid());
            Assert.Null(spConfig.TenantId);
            Assert.Null(spConfig.SubscriptionId);
            Assert.Null(spConfig.AppId);
            Assert.Null(spConfig.AppSecret);
            Assert.Null(spConfig.Sender);
            Assert.Null(spConfig.Receiver);
            Assert.Null(spConfig.InstanceName);
            spConfig.ToString().Should().NotBeNullOrEmpty();
        }
        /// <summary>Initializes a new instance of the KeyVault class using Service Principle security.</summary>
        /// <param name="config">Service Principle configuration the instance.</param>
        public KeyVault([NotNull] ServicePrincipleConfig config)
        {
            // Ensure the required config values are all set.
            config.ThrowIfInvalid();

            ServicePrincipleConfig = config;
            InstanceUri            = config.Uri;
            Name   = config.KeyVaultInstanceName;
            Config = config;
        }
示例#3
0
        /// <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(ServicePrincipleConfig config, ILogger logger = null)
        {
            // Ensure all mandatory fields are set.
            config.ThrowIfInvalid();

            Logger = logger;
            ServicePrincipleConfig = 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(ServicePrincipleConfig config, ILogger logger = null)
        {
            // Validate the config.
            config.ThrowIfInvalid();

            Logger = logger;
            ServicePrincipleConfig = 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;
        }
示例#5
0
        public void Test_ServicePrincipleConfig_Validation()
        {
            var spConfig = new ServicePrincipleConfig();

            // Check the service Principle config validation.
            Assert.Throws <ValidateException>(() => spConfig.ThrowIfInvalid());
            spConfig.InstanceName = "test";
            Assert.Throws <ValidateException>(() => spConfig.ThrowIfInvalid());
            spConfig.AppId = "test";
            Assert.Throws <ValidateException>(() => spConfig.ThrowIfInvalid());
            spConfig.AppSecret = "test";
            Assert.Throws <ValidateException>(() => spConfig.ThrowIfInvalid());
            spConfig.TenantId = "test";
            Assert.Throws <ValidateException>(() => spConfig.ThrowIfInvalid());
            spConfig.SubscriptionId = "test";
            AssertExtensions.DoesNotThrow(() => spConfig.ThrowIfInvalid());
            spConfig.ToString().Should().NotBeNullOrEmpty();
        }