From 730a744dbbcb10ca646d28d0a42fc4dbb63e7b47 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 14 Feb 2018 09:22:46 -0800 Subject: [PATCH] Fix tests and disable scm environment variable injection (#148) --- build/dependencies.props | 52 ++++++++-------- ...Core.AzureAppServices.SiteExtension.csproj | 1 + .../scmApplicationHost.xdt | 5 ++ .../TransformTest.cs | 59 ++++++++++++------- .../config_existingemptyvalue.xml | 1 + .../config_existingline.xml | 1 + .../config_existingvalue.xml | 1 + 7 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/scmApplicationHost.xdt diff --git a/build/dependencies.props b/build/dependencies.props index 7b68be0b24..6279f3ece6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,40 +4,40 @@ 2.1.0-preview1-1010 - 2.1.0-preview2-15684 + 2.1.0-preview1-1015 2.1.1 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 0.5.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 0.5.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 1.1.3 1.1.0-preview - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 - 2.1.0-preview1-28193 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 + 2.1.0-preview1-28274 2.0.0 - 2.1.0-preview1-26122-01 + 2.1.0-preview1-26208-06 15.3.0 1.4.0 4.7.49 10.0.1 - 1.6.0-preview1-26119-06 + 1.6.0-preview1-26208-08 8.1.4 2.3.1 2.3.1 diff --git a/extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj b/extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj index b99d92aae7..0d2980dc00 100644 --- a/extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj +++ b/extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj @@ -14,6 +14,7 @@ + diff --git a/extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/scmApplicationHost.xdt b/extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/scmApplicationHost.xdt new file mode 100644 index 0000000000..a8dd367f9f --- /dev/null +++ b/extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/scmApplicationHost.xdt @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/TransformTest.cs b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/TransformTest.cs index c8972cbf58..eb9f81d28b 100644 --- a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/TransformTest.cs +++ b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/TransformTest.cs @@ -11,6 +11,8 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension { public class TransformTest { + private static readonly string XdtExtensionPath = AppDomain.CurrentDomain.BaseDirectory; + [Theory] [InlineData("config_empty.xml")] [InlineData("config_existingline.xml")] @@ -24,18 +26,25 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension Assert.NotNull(envNode); - Assert.Equal(2, envNode.ChildNodes.Count); + Assert.Equal(3, envNode.ChildNodes.Count); - var firstChild = envNode.FirstChild; - Assert.Equal("add", firstChild.Name); - Assert.Equal("DOTNET_ADDITIONAL_DEPS", firstChild.Attributes["name"].Value); - Assert.Equal(@"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\", - firstChild.Attributes["value"].Value); + var depsElement = envNode.FirstChild; + Assert.Equal("add", depsElement.Name); + Assert.Equal("DOTNET_ADDITIONAL_DEPS", depsElement.Attributes["name"].Value); + Assert.Equal($@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;" + + $@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureKeyVault.HostingStartup\;" + + @"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\", + depsElement.Attributes["value"].Value); - var secondChild = firstChild.NextSibling; - Assert.Equal("add", secondChild.Name); - Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", secondChild.Attributes["name"].Value); - Assert.Equal("Microsoft.AspNetCore.AzureAppServices.HostingStartup", secondChild.Attributes["value"].Value); + var sharedStoreElement = depsElement.NextSibling; + Assert.Equal("add", sharedStoreElement.Name); + Assert.Equal("DOTNET_SHARED_STORE", sharedStoreElement.Attributes["name"].Value); + Assert.Equal($@"{XdtExtensionPath}\store", sharedStoreElement.Attributes["value"].Value); + + var startupAssembliesElement = sharedStoreElement.NextSibling; + Assert.Equal("add", startupAssembliesElement.Name); + Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", startupAssembliesElement.Attributes["name"].Value); + Assert.Equal("Microsoft.AspNetCore.AzureAppServices.HostingStartup", startupAssembliesElement.Attributes["value"].Value); } [Fact] @@ -48,18 +57,26 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension Assert.NotNull(envNode); - Assert.Equal(2, envNode.ChildNodes.Count); + Assert.Equal(3, envNode.ChildNodes.Count); - var firstChild = envNode.FirstChild; - Assert.Equal("add", firstChild.Name); - Assert.Equal("DOTNET_ADDITIONAL_DEPS", firstChild.Attributes["name"].Value); - Assert.Equal(@"ExistingValue1;%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\", - firstChild.Attributes["value"].Value); + var depsElement = envNode.FirstChild; + Assert.Equal("add", depsElement.Name); + Assert.Equal("DOTNET_ADDITIONAL_DEPS", depsElement.Attributes["name"].Value); + Assert.Equal(@"ExistingValue1;"+ + $@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;" + + $@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureKeyVault.HostingStartup\;" + + @"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\", + depsElement.Attributes["value"].Value); - var secondChild = firstChild.NextSibling; - Assert.Equal("add", secondChild.Name); - Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", secondChild.Attributes["name"].Value); - Assert.Equal("ExistingValue2;Microsoft.AspNetCore.AzureAppServices.HostingStartup", secondChild.Attributes["value"].Value); + var sharedStoreElement = depsElement.NextSibling; + Assert.Equal("add", sharedStoreElement.Name); + Assert.Equal("DOTNET_SHARED_STORE", sharedStoreElement.Attributes["name"].Value); + Assert.Equal($@"ExistingValue3;{XdtExtensionPath}\store", sharedStoreElement.Attributes["value"].Value); + + var startupAssembliesElement = sharedStoreElement.NextSibling; + Assert.Equal("add", startupAssembliesElement.Name); + Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", startupAssembliesElement.Attributes["name"].Value); + Assert.Equal("ExistingValue2;Microsoft.AspNetCore.AzureAppServices.HostingStartup", startupAssembliesElement.Attributes["value"].Value); } private static XmlDocument LoadDocAndRunTransform(string docName) @@ -67,7 +84,7 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension // Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionDefinition.Transform // (See Microsoft.Web.Hosting, Version=7.1.0.0) replaces variables for you in Azure. var transformFile = File.ReadAllText("applicationHost.xdt"); - transformFile = transformFile.Replace("%XDT_EXTENSIONPATH%", AppDomain.CurrentDomain.BaseDirectory); + transformFile = transformFile.Replace("%XDT_EXTENSIONPATH%", XdtExtensionPath); var transform = new XmlTransformation(transformFile, isTransformAFile: false, logger: null); var doc = new XmlDocument(); doc.Load(docName); diff --git a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingemptyvalue.xml b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingemptyvalue.xml index a127fb1b3a..b25079c3ce 100644 --- a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingemptyvalue.xml +++ b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingemptyvalue.xml @@ -4,6 +4,7 @@ + diff --git a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingline.xml b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingline.xml index f9da5a268c..312e525b86 100644 --- a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingline.xml +++ b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingline.xml @@ -4,6 +4,7 @@ + diff --git a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingvalue.xml b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingvalue.xml index 748662e783..4659b9a48b 100644 --- a/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingvalue.xml +++ b/test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingvalue.xml @@ -4,6 +4,7 @@ +