Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #3
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);
        }