Exemplo n.º 1
0
        public void Fails_When_No_Storage_is_set()
        {
            // TODO: We shouldn't have to do this, but our default parser
            //       does not allow for null Storage/Dashboard.
            var mockParser = new Mock <IStorageAccountParser>();

            mockParser
            .Setup(p => p.ParseAccount(null, It.IsAny <string>()))
            .Returns <string>(null);

            // no storage account!
            IHost host = new HostBuilder()
                         .ConfigureDefaultTestHost <ProgramSimple>()
                         .ConfigureServices(services =>
            {
                services.AddSingleton <IStorageAccountParser>(mockParser.Object);
            })
                         .ConfigureAppConfiguration(config =>
            {
                config.AddInMemoryCollection(new Dictionary <string, string>
                {
                    { "AzureWebJobsStorge", null },
                    { "AzureWebJobsDashboard", null }
                });
            })
                         .Build();

            string message = StorageAccountParser.FormatParseAccountErrorMessage(StorageAccountParseResult.MissingOrEmptyConnectionStringError, "Storage");

            TestHelpers.AssertIndexingError(() => host.GetJobHost().Call <ProgramSimple>("Func"), "ProgramSimple.Func", message);
        }
Exemplo n.º 2
0
        public void Fails_When_No_Storage_is_set()
        {
            var    host    = TestHelpers.NewJobHost <ProgramSimple>(); // no storage account!
            string message = StorageAccountParser.FormatParseAccountErrorMessage(StorageAccountParseResult.MissingOrEmptyConnectionStringError, "Storage");

            TestHelpers.AssertIndexingError(() => host.Call("Func"),
                                            "ProgramSimple.Func", message);
        }
Exemplo n.º 3
0
        public void TryParseAccount_WithMalformed_Fails()
        {
            string connectionString = "DefaultEndpointsProtocol=https;AccountName=[NOVALUE];AccountKey=[NOVALUE]";
            CloudStorageAccount ignore;

            StorageAccountParseResult result = StorageAccountParser.TryParseAccount(connectionString, out ignore);

            Assert.Equal(StorageAccountParseResult.MalformedConnectionStringError, result);
        }
Exemplo n.º 4
0
        public void TryParseAccount_WithNull_Fails()
        {
            string connectionString = null;
            CloudStorageAccount ignore;

            StorageAccountParseResult result = StorageAccountParser.TryParseAccount(connectionString, out ignore);

            Assert.Equal(StorageAccountParseResult.MissingOrEmptyConnectionStringError, result);
        }
Exemplo n.º 5
0
        public void TryParseAccount_WithProxiedEmulator_Fails()
        {
            string connectionString = "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://myProxyUri";
            CloudStorageAccount ignore;

            StorageAccountParseResult result = StorageAccountParser.TryParseAccount(connectionString, out ignore);

            Assert.Equal(StorageAccountParseResult.EmulatorIsNotSupportedError, result);
        }
Exemplo n.º 6
0
        public void Sanitizes_Exception_If_Connection_String()
        {
            // people accidentally use their connection string; we want to make sure we sanitize it
            var    host    = TestHelpers.NewJobHost <ProgramSimple2>();
            string message = StorageAccountParser.FormatParseAccountErrorMessage(StorageAccountParseResult.MissingOrEmptyConnectionStringError, ProgramSimple2.ConnectionString);

            TestHelpers.AssertIndexingError(() => host.Call(nameof(ProgramSimple2.Func2)),
                                            "ProgramSimple2.Func2", message);

            Assert.DoesNotContain(ProgramSimple2.ConnectionString, message);
            Assert.DoesNotContain("AzureWebJobs", message); // prefix should not be added
            Assert.Contains("[Hidden Credential]", message);
        }