Beispiel #1
0
    public void Returns_Uri__With_Correct_Value()
    {
        // Arrange
        var name   = Rnd.Str;
        var config = new KeyVaultConfig {
            Name = name
        };

        // Act
        var result = config.GetUri();

        // Assert
        Assert.Equal($"https://{name.ToLowerInvariant()}.vault.azure.net/", result.AbsoluteUri);
    }
        /// <summary>
        /// Gets all the configuration to run a complete key rotation integration test.
        /// </summary>
        public KeyRotationConfig GetKeyRotationConfig()
        {
            var azureEnv = new ServiceBusNamespace(
                tenantId: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:TenantId"),
                azureSubscriptionId: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:SubscriptionId"),
                resourceGroup: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:ResourceGroupName"),
                @namespace: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:Namespace"),
                queueName: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:QueueName"),
                topicName: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:TopicName"),
                authorizationRuleName: _config.GetValue <string>("Arcus:KeyRotation:ServiceBus:AuthorizationRuleName"));

            var servicePrincipal = new ServicePrincipal(
                clientId: _config.GetValue <string>("Arcus:KeyRotation:ServicePrincipal:ClientId"),
                clientSecret: _config.GetValue <string>("Arcus:KeyRotation:ServicePrincipal:ClientSecret"),
                clientSecretKey: _config.GetValue <string>("Arcus:KeyRotation:ServicePrincipal:ClientSecretKey"));

            var secret = new KeyVaultConfig(
                vaultUri: _config.GetValue <string>("Arcus:KeyRotation:KeyVault:VaultUri"),
                secretName: _config.GetValue <string>("Arcus:KeyRotation:KeyVault:ConnectionStringSecretName"),
                secretNewVersionCreated: new KeyVaultEventEndpoint(
                    _config.GetValue <string>("Arcus:KeyRotation:KeyVault:SecretNewVersionCreated:ServiceBusConnectionStringWithTopicEndpoint")));

            return(new KeyRotationConfig(secret, servicePrincipal, azureEnv));
        }