public async Task GetRawSecret_WithoutSecretName_Throws(string secretName)
        {
            // Arrange
            var provider = new EnvironmentVariableSecretProvider();

            // Act / Assert
            await Assert.ThrowsAnyAsync <ArgumentException>(() => provider.GetRawSecretAsync(secretName));
        }
Esempio n. 2
0
        public async Task GetSecret_WithoutSecretResult_ReturnsNull()
        {
            // Arrange
            var provider = new EnvironmentVariableSecretProvider();

            // Act
            Secret result = await provider.GetSecretAsync($"random-not-found-secret-{Guid.NewGuid()}");

            // Assert
            Assert.Null(result);
        }
Esempio n. 3
0
        public async Task GetEntityPath_WithNamespaceConnectionStringInsteadOfEntityScopedUsingConnectionString_Fails()
        {
            // Arrange
            var entityType      = ServiceBusEntityType.Queue;
            var options         = new AzureServiceBusMessagePumpOptions();
            var secretProvider  = new EnvironmentVariableSecretProvider();
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <ISecretProvider>(secretProvider)
                                  .BuildServiceProvider();
            var namespaceConnectionString =
                $"Endpoint=sb://arcus-messaging-integration-tests.servicebus.windows.net/;SharedAccessKeyName=MyAccessKeyName;SharedAccessKey={Guid.NewGuid()}";

            var settings = new AzureServiceBusMessagePumpSettings(
                entityName: null,
                subscriptionName: null,
                serviceBusEntity: entityType,
                getConnectionStringFromConfigurationFunc: null,
                getConnectionStringFromSecretFunc: secretProvider => Task.FromResult(namespaceConnectionString),
                options: options,
                serviceProvider: serviceProvider);

            // Act
            await Assert.ThrowsAnyAsync <ArgumentException>(() => settings.GetEntityPathAsync());
        }