From a0fa8fff16637c2df36a19fff41e2574c75d6293 Mon Sep 17 00:00:00 2001 From: Yishai Galatzer Date: Mon, 16 Feb 2015 18:31:39 -0800 Subject: [PATCH 001/271] Initial commit --- .gitattributes | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 36 +++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 4 ++++ LICENSE.txt | 12 ++++++++++++ NuGet.Config | 7 +++++++ README.md | 4 ++++ build.cmd | 28 +++++++++++++++++++++++++++ build.sh | 38 +++++++++++++++++++++++++++++++++++++ global.json | 3 +++ makefile.shade | 12 ++++++++++++ 10 files changed, 194 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.txt create mode 100644 NuGet.Config create mode 100644 README.md create mode 100644 build.cmd create mode 100644 build.sh create mode 100644 global.json create mode 100644 makefile.shade diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..bdaa5ba982 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,50 @@ +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +*.jpg binary +*.png binary +*.gif binary + +*.cs text=auto diff=csharp +*.vb text=auto +*.resx text=auto +*.c text=auto +*.cpp text=auto +*.cxx text=auto +*.h text=auto +*.hxx text=auto +*.py text=auto +*.rb text=auto +*.java text=auto +*.html text=auto +*.htm text=auto +*.css text=auto +*.scss text=auto +*.sass text=auto +*.less text=auto +*.js text=auto +*.lisp text=auto +*.clj text=auto +*.sql text=auto +*.php text=auto +*.lua text=auto +*.m text=auto +*.asm text=auto +*.erl text=auto +*.fs text=auto +*.fsx text=auto +*.hs text=auto + +*.csproj text=auto +*.vbproj text=auto +*.fsproj text=auto +*.dbproj text=auto +*.sln text=auto eol=crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..8a9bbc3a43 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +[Oo]bj/ +[Bb]in/ +TestResults/ +.nuget/ +*.sln.ide/ +_ReSharper.*/ +packages/ +artifacts/ +PublishProfiles/ +.vs/ +bower_components/ +node_modules/ +**/wwwroot/lib/ +debugSettings.json +project.lock.json +*.user +*.suo +*.cache +*.docstates +_ReSharper.* +nuget.exe +*net45.csproj +*net451.csproj +*k10.csproj +*.psess +*.vsp +*.pidb +*.userprefs +*DS_Store +*.ncrunchsolution +*.*sdf +*.ipch +.settings +*.sln.ide +node_modules +**/[Cc]ompiler/[Rr]esources/**/*.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..eac4268e4c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +Contributing +====== + +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000..d85a1524ad --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,12 @@ +Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +these files except in compliance with the License. You may obtain a copy of the +License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000000..f41e9c631d --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000000..3c46d88951 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +CORS +=== +CORS repository includes the core implementation for CORS policy, utilized by the CORS middleware and MVC. +This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000000..86ca5bbbf1 --- /dev/null +++ b/build.cmd @@ -0,0 +1,28 @@ +@echo off +cd %~dp0 + +SETLOCAL +SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe + +IF EXIST %CACHED_NUGET% goto copynuget +echo Downloading latest version of NuGet.exe... +IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet +@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'" + +:copynuget +IF EXIST .nuget\nuget.exe goto restore +md .nuget +copy %CACHED_NUGET% .nuget\nuget.exe > nul + +:restore +IF EXIST packages\KoreBuild goto run +.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion + +IF "%SKIP_KRE_INSTALL%"=="1" goto run +CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 + +:run +CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh new file mode 100644 index 0000000000..c7873ef58e --- /dev/null +++ b/build.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +if test `uname` = Darwin; then + cachedir=~/Library/Caches/KBuild +else + if [ -z $XDG_DATA_HOME ]; then + cachedir=$HOME/.local/share + else + cachedir=$XDG_DATA_HOME; + fi +fi +mkdir -p $cachedir + +url=https://www.nuget.org/nuget.exe + +if test ! -f $cachedir/nuget.exe; then + wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null +fi + +if test ! -e .nuget; then + mkdir .nuget + cp $cachedir/nuget.exe .nuget/nuget.exe +fi + +if test ! -d packages/KoreBuild; then + mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion +fi + +if ! type k > /dev/null 2>&1; then + source packages/KoreBuild/build/kvm.sh +fi + +if ! type k > /dev/null 2>&1; then + kvm upgrade +fi + +mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" diff --git a/global.json b/global.json new file mode 100644 index 0000000000..840c36f6ad --- /dev/null +++ b/global.json @@ -0,0 +1,3 @@ +{ + "sources": ["src"] +} \ No newline at end of file diff --git a/makefile.shade b/makefile.shade new file mode 100644 index 0000000000..cf2ed944c2 --- /dev/null +++ b/makefile.shade @@ -0,0 +1,12 @@ + +var VERSION='0.1' +var FULL_VERSION='0.1' +var AUTHORS='Microsoft Open Technologies, Inc.' + +use-standard-lifecycle +k-standard-goals + +#xml-docs-test .clean .build-compile description='Check generated XML documentation files for errors' target='test' + k-xml-docs-test + + From 594ccb98ccb67b2c33f0c32d0cf13186f7e8578a Mon Sep 17 00:00:00 2001 From: Harsh Gupta Date: Tue, 24 Feb 2015 13:32:31 -0800 Subject: [PATCH 002/271] Initial Commit to enable CI --- CORS.sln | 32 +++++++++++++++++++ .../Microsoft.AspNet.Cors.Core.kproj | 20 ++++++++++++ src/Microsoft.AspNet.Cors.Core/project.json | 17 ++++++++++ 3 files changed, 69 insertions(+) create mode 100644 CORS.sln create mode 100644 src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.kproj create mode 100644 src/Microsoft.AspNet.Cors.Core/project.json diff --git a/CORS.sln b/CORS.sln new file mode 100644 index 0000000000..2887117253 --- /dev/null +++ b/CORS.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.22604.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{280203D6-9DDE-4B80-BF93-4E7382CAD1A9}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + EndProjectSection +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core", "src\Microsoft.AspNet.Cors.Core\Microsoft.AspNet.Cors.Core.kproj", "{C573AEE1-8D54-4A83-8D6B-61C85E8F713E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C573AEE1-8D54-4A83-8D6B-61C85E8F713E} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} + EndGlobalSection +EndGlobal diff --git a/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.kproj b/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.kproj new file mode 100644 index 0000000000..7449ce1c4e --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.kproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + c573aee1-8d54-4a83-8d6b-61c85e8f713e + Microsoft.AspNet.Cors.Core + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json new file mode 100644 index 0000000000..55840b00a5 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -0,0 +1,17 @@ +{ + "version": "1.0.0-*", + "dependencies": { + }, + + "frameworks" : { + "aspnet50" : { + "dependencies": { + } + }, + "aspnetcore50" : { + "dependencies": { + "System.Runtime": "4.0.20-beta-*" + } + } + } +} From 9865d37b0e151b922c53897f7deb339d11275e93 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 12:47:51 -0700 Subject: [PATCH 003/271] Update aspnet50/aspnetcore50 => dnx451/dnxcore50. --- src/Microsoft.AspNet.Cors.Core/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index 55840b00a5..fbd6d04df2 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -4,11 +4,11 @@ }, "frameworks" : { - "aspnet50" : { + "dnx451" : { "dependencies": { } }, - "aspnetcore50" : { + "dnxcore50" : { "dependencies": { "System.Runtime": "4.0.20-beta-*" } From ce4ee36829668270d72424459c74dc51b2f8a202 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 12:47:51 -0700 Subject: [PATCH 004/271] Update K_BUILD_VERSION/kre/KRE/.k => DNX_BUILD_VERSION/dnx/DNX/.dnx. --- build.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cmd b/build.cmd index 86ca5bbbf1..49ba0692de 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,4 @@ -@echo off +@echo off cd %~dp0 SETLOCAL @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_KRE_INSTALL%"=="1" goto run +IF "%SKIP_DNX_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 From ceef530572e82d06e5fd2c28317f661208a1db85 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 12:47:51 -0700 Subject: [PATCH 005/271] Update kvm/KVM/Kvm => dnvm/DNVM/Dnvm. --- build.cmd | 6 +++--- build.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index 49ba0692de..77be0a6627 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index c7873ef58e..74cb3421e6 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/kvm.sh + source packages/KoreBuild/build/dnvm.sh fi if ! type k > /dev/null 2>&1; then - kvm upgrade + dnvm upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From f0af3fd8af93466e8d393c387e3dd0aeaf001c7a Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 12:47:51 -0700 Subject: [PATCH 006/271] Update build.sh to use dnvm correctly. --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 74cb3421e6..a9ce06d087 100644 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion fi -if ! type k > /dev/null 2>&1; then +if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi @@ -36,3 +36,4 @@ if ! type k > /dev/null 2>&1; then fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" + From dd870750ecacecee02835f40b3afe9c33d615637 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 9 Mar 2015 12:52:10 -0700 Subject: [PATCH 007/271] Remove BOM from project.json, *.cmd, *.sh and *.shade files. --- build.cmd | 2 +- build.sh | 2 +- src/Microsoft.AspNet.Cors.Core/project.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 77be0a6627..68a732c182 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,4 @@ -@echo off +@echo off cd %~dp0 SETLOCAL diff --git a/build.sh b/build.sh index a9ce06d087..ec3263114a 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index fbd6d04df2..f868fb80f4 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { }, From 8e399cd83d9e0271f8d072848ce2656e68220b43 Mon Sep 17 00:00:00 2001 From: Harsh Gupta Date: Tue, 24 Feb 2015 17:08:37 -0800 Subject: [PATCH 008/271] Adding Base interfaces for Cors.Core --- CORS.sln | 11 +- global.json | 2 +- .../CorsConstants.cs | 91 ++ src/Microsoft.AspNet.Cors.Core/CorsOptions.cs | 50 + src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs | 146 +++ .../CorsPolicyBuilder.cs | 194 ++++ src/Microsoft.AspNet.Cors.Core/CorsResult.cs | 96 ++ src/Microsoft.AspNet.Cors.Core/CorsService.cs | 212 ++++ .../CorsServiceCollectionExtensions.cs | 42 + .../DisableCorsAttribute.cs | 13 + .../EnableCorsAttribute.cs | 24 + .../ICorsService.cs | 32 + .../IDisableCorsMetadata.cs | 12 + .../IEnableCorsMetadata.cs | 16 + .../Properties/Resources.Designer.cs | 110 +++ src/Microsoft.AspNet.Cors.Core/Resources.resx | 135 +++ src/Microsoft.AspNet.Cors.Core/project.json | 13 +- .../CorsPolicyBuilderTests.cs | 233 +++++ .../CorsPolicyTests.cs | 73 ++ .../CorsResultTests.cs | 69 ++ .../CorsServiceTests.cs | 904 ++++++++++++++++++ .../Microsoft.AspNet.Cors.Core.Test.kproj | 20 + .../project.json | 21 + 23 files changed, 2513 insertions(+), 6 deletions(-) create mode 100644 src/Microsoft.AspNet.Cors.Core/CorsConstants.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/CorsOptions.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/CorsResult.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/CorsService.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/ICorsService.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/IDisableCorsMetadata.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/IEnableCorsMetadata.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/Resources.resx create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.kproj create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/project.json diff --git a/CORS.sln b/CORS.sln index 2887117253..2cf414de64 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22604.0 +VisualStudioVersion = 14.0.22529.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" EndProject @@ -12,6 +12,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core", "src\Microsoft.AspNet.Cors.Core\Microsoft.AspNet.Cors.Core.kproj", "{C573AEE1-8D54-4A83-8D6B-61C85E8F713E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F32074C7-087C-46CC-A913-422BFD2D6E0A}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core.Test", "test\Microsoft.AspNet.Cors.Core.Test\Microsoft.AspNet.Cors.Core.Test.kproj", "{B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -22,11 +26,16 @@ Global {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Debug|Any CPU.Build.0 = Debug|Any CPU {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Release|Any CPU.ActiveCfg = Release|Any CPU {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Release|Any CPU.Build.0 = Release|Any CPU + {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {C573AEE1-8D54-4A83-8D6B-61C85E8F713E} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} + {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} EndGlobalSection EndGlobal diff --git a/global.json b/global.json index 840c36f6ad..be397c3721 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,3 @@ { - "sources": ["src"] + "sources": ["src", "test"] } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs b/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs new file mode 100644 index 0000000000..fad7a5b533 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// CORS-related constants. + /// + public static class CorsConstants + { + /// + /// The HTTP method for the CORS preflight request. + /// + public static readonly string PreflightHttpMethod = "OPTIONS"; + + /// + /// The Origin request header. + /// + public static readonly string Origin = "Origin"; + + /// + /// The value for the Access-Control-Allow-Origin response header to allow all origins. + /// + public static readonly string AnyOrigin = "*"; + + /// + /// The Access-Control-Request-Method request header. + /// + public static readonly string AccessControlRequestMethod = "Access-Control-Request-Method"; + + /// + /// The Access-Control-Request-Headers request header. + /// + public static readonly string AccessControlRequestHeaders = "Access-Control-Request-Headers"; + + /// + /// The Access-Control-Allow-Origin response header. + /// + public static readonly string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; + + /// + /// The Access-Control-Allow-Headers response header. + /// + public static readonly string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; + + /// + /// The Access-Control-Expose-Headers response header. + /// + public static readonly string AccessControlExposeHeaders = "Access-Control-Expose-Headers"; + + /// + /// The Access-Control-Allow-Methods response header. + /// + public static readonly string AccessControlAllowMethods = "Access-Control-Allow-Methods"; + + /// + /// The Access-Control-Allow-Credentials response header. + /// + public static readonly string AccessControlAllowCredentials = "Access-Control-Allow-Credentials"; + + /// + /// The Access-Control-Max-Age response header. + /// + public static readonly string AccessControlMaxAge = "Access-Control-Max-Age"; + + internal static readonly string[] SimpleRequestHeaders = + { + "Origin", + "Accept", + "Accept-Language", + "Content-Language", + }; + + internal static readonly string[] SimpleResponseHeaders = + { + "Cache-Control", + "Content-Language", + "Content-Type", + "Expires", + "Last-Modified", + "Pragma" + }; + + internal static readonly string[] SimpleMethods = + { + "GET", + "HEAD", + "POST" + }; + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs new file mode 100644 index 0000000000..7d76181e62 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.AspNet.Cors.Core; +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// Provides programmatic configuration for Cors. + /// + public class CorsOptions + { + private IDictionary PolicyMap { get; } = new Dictionary(); + + /// + /// Adds a new policy. + /// + /// The name of the policy. + /// The policy to be added. + public void AddPolicy([NotNull] string name, [NotNull] CorsPolicy policy) + { + PolicyMap[name] = policy; + } + + /// + /// Adds a new policy. + /// + /// The name of the policy. + /// A delegate which can use a policy builder to build a policy. + public void AddPolicy([NotNull] string name, [NotNull] Action configurePolicy) + { + var policyBuilder = new CorsPolicyBuilder(); + configurePolicy(policyBuilder); + PolicyMap[name] = policyBuilder.Build(); + } + + /// + /// Gets the policy based on the + /// + /// The name of the policy to lookup. + /// The if the policy was added.null otherwise. + public CorsPolicy GetPolicy([NotNull] string name) + { + return PolicyMap.ContainsKey(name) ? PolicyMap[name] : null; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs b/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs new file mode 100644 index 0000000000..9fc7ba9d2b --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// Defines the policy for Cross-Origin requests based on the CORS specifications. + /// + public class CorsPolicy + { + private TimeSpan? _preflightMaxAge; + + /// + /// Gets a value indicating if all headers are allowed. + /// + public bool AllowAnyHeader + { + get + { + if (Headers == null || Headers.Count != 1 || Headers.Count == 1 && Headers[0] != "*") + { + return false; + } + + return true; + } + } + + /// + /// Gets a value indicating if all methods are allowed. + /// + public bool AllowAnyMethod + { + get + { + if (Methods == null || Methods.Count != 1 || Methods.Count == 1 && Methods[0] != "*") + { + return false; + } + + return true; + } + } + + /// + /// Gets a value indicating if all origins are allowed. + /// + public bool AllowAnyOrigin + { + get + { + if (Origins == null || Origins.Count != 1 || Origins.Count == 1 && Origins[0] != "*") + { + return false; + } + + return true; + } + } + + /// + /// Gets the headers that the resource might use and can be exposed. + /// + public IList ExposedHeaders { get; } = new List(); + + /// + /// Gets the headers that are supported by the resource. + /// + public IList Headers { get; } = new List(); + + /// + /// Gets the methods that are supported by the resource. + /// + public IList Methods { get; } = new List(); + + /// + /// Gets the origins that are allowed to access the resource. + /// + public IList Origins { get; } = new List(); + + /// + /// Gets or sets the for which the results of a preflight request can be cached. + /// + public TimeSpan? PreflightMaxAge + { + get + { + return _preflightMaxAge; + } + set + { + if (value < TimeSpan.Zero) + { + throw new ArgumentOutOfRangeException("value", Resources.PreflightMaxAgeOutOfRange); + } + + _preflightMaxAge = value; + } + } + + /// + /// Gets or sets a value indicating whether the resource supports user credentials in the request. + /// + public bool SupportsCredentials { get; set; } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + var builder = new StringBuilder(); + builder.Append("AllowAnyHeader: "); + builder.Append(AllowAnyHeader); + builder.Append(", AllowAnyMethod: "); + builder.Append(AllowAnyMethod); + builder.Append(", AllowAnyOrigin: "); + builder.Append(AllowAnyOrigin); + builder.Append(", PreflightMaxAge: "); + builder.Append(PreflightMaxAge.HasValue ? + PreflightMaxAge.Value.TotalSeconds.ToString() : "null"); + builder.Append(", SupportsCredentials: "); + builder.Append(SupportsCredentials); + builder.Append(", Origins: {"); + builder.Append(string.Join(",", Origins)); + builder.Append("}"); + builder.Append(", Methods: {"); + builder.Append(string.Join(",", Methods)); + builder.Append("}"); + builder.Append(", Headers: {"); + builder.Append(string.Join(",", Headers)); + builder.Append("}"); + builder.Append(", ExposedHeaders: {"); + builder.Append(string.Join(",", ExposedHeaders)); + builder.Append("}"); + return builder.ToString(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs new file mode 100644 index 0000000000..83303009bb --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using Microsoft.AspNet.Cors.Core; +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Cors +{ + /// + /// Exposes methods to build a policy. + /// + public class CorsPolicyBuilder + { + private readonly CorsPolicy _policy = new CorsPolicy(); + + /// + /// Creates a new instance of the . + /// + /// list of origins which can be added. + public CorsPolicyBuilder(params string[] origins) + { + AddOrigins(origins); + } + + /// + /// Creates a new instance of the . + /// + /// The policy which will be used to intialize the builder. + public CorsPolicyBuilder(CorsPolicy policy) + { + Combine(policy); + } + + /// + /// Adds the specified to the policy. + /// + /// The origins that are allowed. + /// The current policy builder + public CorsPolicyBuilder AddOrigins(params string[] origins) + { + foreach (var req in origins) + { + _policy.Origins.Add(req); + } + + return this; + } + + /// + /// Adds the specified to the policy. + /// + /// The headers which need to be allowed in the request. + /// The current policy builder + public CorsPolicyBuilder AddHeaders(params string[] headers) + { + foreach (var req in headers) + { + _policy.Headers.Add(req); + } + return this; + } + + /// + /// Adds the specified to the policy. + /// + /// The headers which need to be exposed to the client. + /// The current policy builder + public CorsPolicyBuilder AddExposedHeaders(params string[] exposedHeaders) + { + foreach (var req in exposedHeaders) + { + _policy.ExposedHeaders.Add(req); + } + + return this; + } + + /// + /// Adds the specified to the policy. + /// + /// The methods which need to be added to the policy. + /// The current policy builder + public CorsPolicyBuilder AddMethods(params string[] methods) + { + foreach (var req in methods) + { + _policy.Methods.Add(req); + } + + return this; + } + + /// + /// Sets the policy to allow credentials. + /// + /// The current policy builder + public CorsPolicyBuilder AllowCredentials() + { + _policy.SupportsCredentials = true; + return this; + } + + /// + /// Sets the policy to not allow credentials. + /// + /// The current policy builder + public CorsPolicyBuilder DisallowCredentials() + { + _policy.SupportsCredentials = false; + return this; + } + + /// + /// Ensures that the policy allows any origin. + /// + /// The current policy builder + public CorsPolicyBuilder AllowAnyOrigin() + { + _policy.Origins.Clear(); + _policy.Origins.Add(CorsConstants.AnyOrigin); + return this; + } + + /// + /// Ensures that the policy allows any method. + /// + /// The current policy builder + public CorsPolicyBuilder AllowAnyMethod() + { + _policy.Methods.Clear(); + _policy.Methods.Add("*"); + return this; + } + + /// + /// Ensures that the policy allows any header. + /// + /// The current policy builder + public CorsPolicyBuilder AllowAnyHeader() + { + _policy.Headers.Clear(); + _policy.Headers.Add("*"); + return this; + } + + /// + /// Sets the preflightMaxAge for the underlying policy. + /// + /// A positive indicating the time a preflight + /// request can be cached. + /// + public CorsPolicyBuilder SetPreflightMaxAge(TimeSpan preflightMaxAge) + { + _policy.PreflightMaxAge = preflightMaxAge; + return this; + } + + /// + /// Builds a new using the entries added. + /// + /// The constructed . + public CorsPolicy Build() + { + return _policy; + } + + /// + /// Combines the given to the existing properties in the builder. + /// + /// The policy which needs to be combined. + /// The current policy builder + private CorsPolicyBuilder Combine([NotNull] CorsPolicy policy) + { + AddOrigins(policy.Origins.ToArray()); + AddHeaders(policy.Headers.ToArray()); + AddExposedHeaders(policy.ExposedHeaders.ToArray()); + AddMethods(policy.Methods.ToArray()); + SetPreflightMaxAge(policy.PreflightMaxAge.Value); + + if (policy.SupportsCredentials) + { + AllowCredentials(); + } + else + { + DisallowCredentials(); + } + + return this; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsResult.cs b/src/Microsoft.AspNet.Cors.Core/CorsResult.cs new file mode 100644 index 0000000000..024f2b6615 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/CorsResult.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// Results returned by . + /// + public class CorsResult + { + private TimeSpan? _preflightMaxAge; + + /// + /// Gets or sets the allowed origin. + /// + public string AllowedOrigin { get; set; } + + /// + /// Gets or sets a value indicating whether the resource supports user credentials. + /// + public bool SupportsCredentials { get; set; } + + /// + /// Gets the allowed methods. + /// + public IList AllowedMethods { get; } = new List(); + + /// + /// Gets the allowed headers. + /// + public IList AllowedHeaders { get; } = new List(); + + /// + /// Gets the allowed headers that can be exposed on the response. + /// + public IList AllowedExposedHeaders { get; } = new List(); + + /// + /// Gets or sets a value indicating if a 'Vary' header with the value 'Origin' is required. + /// + public bool VaryByOrigin { get; set; } + + /// + /// Gets or sets the for which the results of a preflight request can be cached. + /// + public TimeSpan? PreflightMaxAge + { + get + { + return _preflightMaxAge; + } + set + { + if (value < TimeSpan.Zero) + { + throw new ArgumentOutOfRangeException("value", Resources.PreflightMaxAgeOutOfRange); + } + _preflightMaxAge = value; + } + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + var builder = new StringBuilder(); + builder.Append("AllowCredentials: "); + builder.Append(SupportsCredentials); + builder.Append(", PreflightMaxAge: "); + builder.Append(PreflightMaxAge.HasValue ? + PreflightMaxAge.Value.TotalSeconds.ToString() : "null"); + builder.Append(", AllowOrigin: "); + builder.Append(AllowedOrigin); + builder.Append(", AllowExposedHeaders: {"); + builder.Append(string.Join(",", AllowedExposedHeaders)); + builder.Append("}"); + builder.Append(", AllowHeaders: {"); + builder.Append(string.Join(",", AllowedHeaders)); + builder.Append("}"); + builder.Append(", AllowMethods: {"); + builder.Append(string.Join(",", AllowedMethods)); + builder.Append("}"); + return builder.ToString(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs new file mode 100644 index 0000000000..9cab11612c --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNet.Http; +using Microsoft.Framework.Internal; +using Microsoft.Framework.OptionsModel; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// Default implementation of . + /// + public class CorsService : ICorsService + { + private readonly CorsOptions _options; + + /// + /// Creates a new instance of the . + /// + /// The option model representing . + public CorsService([NotNull] IOptions options) + { + _options = options.Options; + } + + /// + /// Looks up a policy using the and then evaluates the policy using the passed in + /// . + /// + /// + /// + /// A which contains the result of policy evaluation and can be + /// used by the caller to set apporpriate response headers. + public CorsResult EvaluatePolicy([NotNull] HttpContext context, string policyName) + { + var policy = _options.GetPolicy(policyName); + return EvaluatePolicy(context, policy); + } + + /// + public CorsResult EvaluatePolicy([NotNull] HttpContext context, [NotNull] CorsPolicy policy) + { + var corsResult = new CorsResult(); + var accessControlRequestMethod = context.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); + if (string.Equals(context.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.Ordinal) && + accessControlRequestMethod != null) + { + EvaluatePreflightRequest(context, policy, corsResult); + } + else + { + EvaluateRequest(context, policy, corsResult); + } + + return corsResult; + } + + public virtual void EvaluateRequest(HttpContext context, CorsPolicy policy, CorsResult result) + { + var origin = context.Request.Headers.Get(CorsConstants.Origin); + if (origin == null || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + { + return; + } + + AddOriginToResult(origin, policy, result); + result.SupportsCredentials = policy.SupportsCredentials; + AddHeaderValues(result.AllowedExposedHeaders, policy.ExposedHeaders); + } + + public virtual void EvaluatePreflightRequest(HttpContext context, CorsPolicy policy, CorsResult result) + { + var origin = context.Request.Headers.Get(CorsConstants.Origin); + if (origin == null || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + { + return; + } + + var accessControlRequestMethod = context.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); + if (accessControlRequestMethod == null) + { + return; + } + + var requestHeaders = + context.Request.Headers.GetCommaSeparatedValues(CorsConstants.AccessControlRequestHeaders); + + if (!policy.AllowAnyMethod && !policy.Methods.Contains(accessControlRequestMethod)) + { + return; + } + + if (!policy.AllowAnyHeader && + requestHeaders != null && + !requestHeaders.All(header => policy.Headers.Contains(header, StringComparer.Ordinal))) + { + return; + } + + AddOriginToResult(origin, policy, result); + result.SupportsCredentials = policy.SupportsCredentials; + result.PreflightMaxAge = policy.PreflightMaxAge; + result.AllowedMethods.Add(accessControlRequestMethod); + AddHeaderValues(result.AllowedHeaders, requestHeaders); + } + + /// + public virtual void ApplyResult(CorsResult result, HttpResponse response) + { + var headers = response.Headers; + + if (result.AllowedOrigin != null) + { + headers.Add(CorsConstants.AccessControlAllowOrigin, new[] { result.AllowedOrigin }); + } + + if (result.VaryByOrigin) + { + headers.Set("Vary", "Origin"); + } + + if (result.SupportsCredentials) + { + headers.Add(CorsConstants.AccessControlAllowCredentials, new[] { "true" }); + } + + if (result.AllowedMethods.Count > 0) + { + // Filter out simple methods + var nonSimpleAllowMethods = result.AllowedMethods + .Where(m => + !CorsConstants.SimpleMethods.Contains(m, StringComparer.OrdinalIgnoreCase)) + .ToArray(); + + if (nonSimpleAllowMethods.Length > 0) + { + headers.Add(CorsConstants.AccessControlAllowMethods, nonSimpleAllowMethods); + } + } + + if (result.AllowedHeaders.Count > 0) + { + // Filter out simple request headers + var nonSimpleAllowRequestHeaders = result.AllowedHeaders + .Where(header => + !CorsConstants.SimpleRequestHeaders.Contains(header, StringComparer.OrdinalIgnoreCase)) + .ToArray(); + + if (nonSimpleAllowRequestHeaders.Length > 0) + { + headers.Add(CorsConstants.AccessControlAllowHeaders, nonSimpleAllowRequestHeaders); + } + } + + if (result.AllowedExposedHeaders.Count > 0) + { + // Filter out simple response headers + var nonSimpleAllowResponseHeaders = result.AllowedExposedHeaders + .Where(header => + !CorsConstants.SimpleResponseHeaders.Contains(header, StringComparer.OrdinalIgnoreCase)) + .ToArray(); + if (nonSimpleAllowResponseHeaders.Length > 0) + { + headers.Add(CorsConstants.AccessControlExposeHeaders, nonSimpleAllowResponseHeaders.ToArray()); + } + } + + if (result.PreflightMaxAge.HasValue) + { + headers.Set( + CorsConstants.AccessControlMaxAge, + result.PreflightMaxAge.Value.TotalSeconds.ToString()); + } + } + + private void AddOriginToResult(string origin, CorsPolicy policy, CorsResult result) + { + if (policy.AllowAnyOrigin) + { + if (policy.SupportsCredentials) + { + result.AllowedOrigin = origin; + result.VaryByOrigin = true; + } + else + { + result.AllowedOrigin = CorsConstants.AnyOrigin; + } + } + else if (policy.Origins.Contains(origin)) + { + result.AllowedOrigin = origin; + } + } + + private static void AddHeaderValues(IList target, IEnumerable headerValues) + { + if (headerValues == null) + { + return; + } + + foreach (var current in headerValues) + { + target.Add(current); + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs new file mode 100644 index 0000000000..adb38d189a --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNet.Cors; +using Microsoft.AspNet.Cors.Core; +using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.Internal; + +namespace Microsoft.Framework.DependencyInjection +{ + /// + /// The extensions for enabling CORS support. + /// + public static class CorsServiceCollectionExtensions + { + /// + /// Can be used to configure services in the . + /// + /// The service collection which needs to be configured. + /// A delegate which is run to configure the services. + /// + public static IServiceCollection ConfigureCors( + [NotNull] this IServiceCollection serviceCollection, + [NotNull] Action configure) + { + return serviceCollection.Configure(configure); + } + + /// + /// Add services needed to support CORS to the given . + /// + /// The service collection to which CORS services are added. + /// The updated . + public static IServiceCollection AddCors(this IServiceCollection serviceCollection) + { + serviceCollection.AddOptions(); + serviceCollection.AddTransient(); + return serviceCollection; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs new file mode 100644 index 0000000000..4ebcb449b1 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] + public class DisableCorsAttribute : Attribute, IDisableCorsMetadata + { + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs new file mode 100644 index 0000000000..d53016e09f --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] + public class EnableCorsAttribute : Attribute, IEnableCorsMetadata + { + /// + /// Creates a new instance of the . + /// + /// The name of the policy to be applied. + public EnableCorsAttribute(string policyName) + { + PolicyName = policyName; + } + + /// + public string PolicyName { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsService.cs b/src/Microsoft.AspNet.Cors.Core/ICorsService.cs new file mode 100644 index 0000000000..59216ee576 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/ICorsService.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Http; +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// A type which can evaluate a policy for a particular . + /// + public interface ICorsService + { + /// + /// Evaluates the given using the passed in . + /// + /// The associated with the call. + /// The which needs to be evaluated. + /// A which contains the result of policy evaluation and can be + /// used by the caller to set apporpriate response headers. + CorsResult EvaluatePolicy([NotNull] HttpContext context, [NotNull] CorsPolicy policy); + + + /// + /// Adds CORS-specific response headers to the given . + /// + /// The used to read the allowed values. + /// The associated with the current call. + void ApplyResult([NotNull] CorsResult result, [NotNull] HttpResponse response); + + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/IDisableCorsMetadata.cs b/src/Microsoft.AspNet.Cors.Core/IDisableCorsMetadata.cs new file mode 100644 index 0000000000..6afe8fc272 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/IDisableCorsMetadata.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// An interface which can be used to identify a type which provides metdata to disable cors for a resource. + /// + public interface IDisableCorsMetadata + { + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/IEnableCorsMetadata.cs b/src/Microsoft.AspNet.Cors.Core/IEnableCorsMetadata.cs new file mode 100644 index 0000000000..2270ff7bf5 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/IEnableCorsMetadata.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// An interface which can be used to identify a type which provides metadata needed for enabling CORS support. + /// + public interface IEnableCorsMetadata + { + /// + /// The name of the policy which needs to be applied. + /// + string PolicyName { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..f50fb004a2 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs @@ -0,0 +1,110 @@ +// +namespace Microsoft.AspNet.Cors.Core +{ + using System.Globalization; + using System.Reflection; + using System.Resources; + + internal static class Resources + { + private static readonly ResourceManager _resourceManager + = new ResourceManager("Microsoft.AspNet.Cors.Core.Resources", typeof(Resources).GetTypeInfo().Assembly); + + /// + /// The collection of headers '{0}' is not allowed. + /// + internal static string HeadersNotAllowed + { + get { return GetString("HeadersNotAllowed"); } + } + + /// + /// The collection of headers '{0}' is not allowed. + /// + internal static string FormatHeadersNotAllowed(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("HeadersNotAllowed"), p0); + } + + /// + /// The method '{0}' is not allowed. + /// + internal static string MethodNotAllowed + { + get { return GetString("MethodNotAllowed"); } + } + + /// + /// The method '{0}' is not allowed. + /// + internal static string FormatMethodNotAllowed(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("MethodNotAllowed"), p0); + } + + /// + /// The request does not contain the Origin header. + /// + internal static string NoOriginHeader + { + get { return GetString("NoOriginHeader"); } + } + + /// + /// The request does not contain the Origin header. + /// + internal static string FormatNoOriginHeader() + { + return GetString("NoOriginHeader"); + } + + /// + /// The origin '{0}' is not allowed. + /// + internal static string OriginNotAllowed + { + get { return GetString("OriginNotAllowed"); } + } + + /// + /// The origin '{0}' is not allowed. + /// + internal static string FormatOriginNotAllowed(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("OriginNotAllowed"), p0); + } + + /// + /// PreflightMaxAge must be greater than or equal to 0. + /// + internal static string PreflightMaxAgeOutOfRange + { + get { return GetString("PreflightMaxAgeOutOfRange"); } + } + + /// + /// PreflightMaxAge must be greater than or equal to 0. + /// + internal static string FormatPreflightMaxAgeOutOfRange() + { + return GetString("PreflightMaxAgeOutOfRange"); + } + + private static string GetString(string name, params string[] formatterNames) + { + var value = _resourceManager.GetString(name); + + System.Diagnostics.Debug.Assert(value != null); + + if (formatterNames != null) + { + for (var i = 0; i < formatterNames.Length; i++) + { + value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); + } + } + + return value; + } + } +} diff --git a/src/Microsoft.AspNet.Cors.Core/Resources.resx b/src/Microsoft.AspNet.Cors.Core/Resources.resx new file mode 100644 index 0000000000..ef0e5b5f1f --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/Resources.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The collection of headers '{0}' is not allowed. + + + The method '{0}' is not allowed. + + + The request does not contain the Origin header. + + + The origin '{0}' is not allowed. + + + PreflightMaxAge must be greater than or equal to 0. + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index f868fb80f4..db6b0673eb 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -1,7 +1,12 @@ { - "version": "1.0.0-*", - "dependencies": { - }, + "version": "1.0.0-*", + "dependencies": { + "Microsoft.Framework.ConfigurationModel.Interfaces": "1.0.0-*", + "Microsoft.Framework.DependencyInjection.Interfaces": "1.0.0-*", + "Microsoft.Framework.OptionsModel": "1.0.0-*", + "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" } + }, "frameworks" : { "dnx451" : { @@ -14,4 +19,4 @@ } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs new file mode 100644 index 0000000000..3a7a7227ec --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs @@ -0,0 +1,233 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Microsoft.AspNet.Cors.Core.Test +{ + public class CorsPolicyBuilderTests + { + [Fact] + public void Constructor_WithPolicy_AddsTheGivenPolicy() + { + // Arrange + var policy = new CorsPolicy(); + policy.Origins.Add("http://existing.com"); + policy.Headers.Add("Existing"); + policy.Methods.Add("GET"); + policy.ExposedHeaders.Add("ExistingExposed"); + policy.SupportsCredentials = true; + policy.PreflightMaxAge = TimeSpan.FromSeconds(12); + + // Act + var builder = new CorsPolicyBuilder(policy); + + // Assert + var corsPolicy = builder.Build(); + + Assert.False(corsPolicy.AllowAnyHeader); + Assert.False(corsPolicy.AllowAnyMethod); + Assert.False(corsPolicy.AllowAnyOrigin); + Assert.True(corsPolicy.SupportsCredentials); + Assert.Equal(policy.Headers, corsPolicy.Headers); + Assert.Equal(policy.Methods, corsPolicy.Methods); + Assert.Equal(policy.Origins, corsPolicy.Origins); + Assert.Equal(policy.ExposedHeaders, corsPolicy.ExposedHeaders); + Assert.Equal(TimeSpan.FromSeconds(12), corsPolicy.PreflightMaxAge); + } + + [Fact] + public void Constructor_WithNoOrigin() + { + // Arrange & Act + var builder = new CorsPolicyBuilder(); + + // Assert + var corsPolicy = builder.Build(); + Assert.False(corsPolicy.AllowAnyHeader); + Assert.False(corsPolicy.AllowAnyMethod); + Assert.False(corsPolicy.AllowAnyOrigin); + Assert.False(corsPolicy.SupportsCredentials); + Assert.Empty(corsPolicy.ExposedHeaders); + Assert.Empty(corsPolicy.Headers); + Assert.Empty(corsPolicy.Methods); + Assert.Empty(corsPolicy.Origins); + Assert.Null(corsPolicy.PreflightMaxAge); + } + + [Theory] + [InlineData("")] + [InlineData("http://example.com,http://example2.com")] + public void Constructor_WithParamsOrigin_InitializesOrigin(string origin) + { + // Arrange + var origins = origin.Split(','); + + // Act + var builder = new CorsPolicyBuilder(origins); + + // Assert + var corsPolicy = builder.Build(); + Assert.False(corsPolicy.AllowAnyHeader); + Assert.False(corsPolicy.AllowAnyMethod); + Assert.False(corsPolicy.AllowAnyOrigin); + Assert.False(corsPolicy.SupportsCredentials); + Assert.Empty(corsPolicy.ExposedHeaders); + Assert.Empty(corsPolicy.Headers); + Assert.Empty(corsPolicy.Methods); + Assert.Equal(origins.ToList(), corsPolicy.Origins); + Assert.Null(corsPolicy.PreflightMaxAge); + } + + [Fact] + public void AddOrigins_AddsOrigins() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AddOrigins("http://example.com", "http://example2.com"); + + // Assert + var corsPolicy = builder.Build(); + Assert.False(corsPolicy.AllowAnyOrigin); + Assert.Equal(new List() { "http://example.com", "http://example2.com" }, corsPolicy.Origins); + } + + [Fact] + public void AllowAnyOrigin_AllowsAny() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AllowAnyOrigin(); + + // Assert + var corsPolicy = builder.Build(); + Assert.True(corsPolicy.AllowAnyOrigin); + Assert.Equal(new List() { "*" }, corsPolicy.Origins); + } + + + [Fact] + public void AddMethods_AddsMethods() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AddMethods("PUT", "GET"); + + // Assert + var corsPolicy = builder.Build(); + Assert.False(corsPolicy.AllowAnyOrigin); + Assert.Equal(new List() { "PUT", "GET" }, corsPolicy.Methods); + } + + [Fact] + public void AllowAnyMethod_AllowsAny() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AllowAnyMethod(); + + // Assert + var corsPolicy = builder.Build(); + Assert.True(corsPolicy.AllowAnyMethod); + Assert.Equal(new List() { "*" }, corsPolicy.Methods); + } + + [Fact] + public void AddHeaders_AddsHeaders() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AddHeaders("example1", "example2"); + + // Assert + var corsPolicy = builder.Build(); + Assert.False(corsPolicy.AllowAnyHeader); + Assert.Equal(new List() { "example1", "example2" }, corsPolicy.Headers); + } + + [Fact] + public void AllowAnyHeaders_AllowsAny() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AllowAnyHeader(); + + // Assert + var corsPolicy = builder.Build(); + Assert.True(corsPolicy.AllowAnyHeader); + Assert.Equal(new List() { "*" }, corsPolicy.Headers); + } + + [Fact] + public void AddExposedHeaders_AddsExposedHeaders() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AddExposedHeaders("exposed1", "exposed2"); + + // Assert + var corsPolicy = builder.Build(); + Assert.Equal(new List() { "exposed1", "exposed2" }, corsPolicy.ExposedHeaders); + } + + [Fact] + public void SetPreFlightMaxAge_SetsThePreFlightAge() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.SetPreflightMaxAge(TimeSpan.FromSeconds(12)); + + // Assert + var corsPolicy = builder.Build(); + Assert.Equal(TimeSpan.FromSeconds(12), corsPolicy.PreflightMaxAge); + } + + [Fact] + public void AllowCredential_SetsSupportsCredentials_ToTrue() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.AllowCredentials(); + + // Assert + var corsPolicy = builder.Build(); + Assert.True(corsPolicy.SupportsCredentials); + } + + + [Fact] + public void DisallowCredential_SetsSupportsCredentials_ToFalse() + { + // Arrange + var builder = new CorsPolicyBuilder(); + + // Act + builder.DisallowCredentials(); + + // Assert + var corsPolicy = builder.Build(); + Assert.False(corsPolicy.SupportsCredentials); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs new file mode 100644 index 0000000000..af257ed411 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Xunit; + +namespace Microsoft.AspNet.Cors.Core.Test +{ + public class CorsPolicyTest + { + [Fact] + public void Default_Constructor() + { + // Arrange & Act + var corsPolicy = new CorsPolicy(); + + // Assert + Assert.False(corsPolicy.AllowAnyHeader); + Assert.False(corsPolicy.AllowAnyMethod); + Assert.False(corsPolicy.AllowAnyOrigin); + Assert.False(corsPolicy.SupportsCredentials); + Assert.Empty(corsPolicy.ExposedHeaders); + Assert.Empty(corsPolicy.Headers); + Assert.Empty(corsPolicy.Methods); + Assert.Empty(corsPolicy.Origins); + Assert.Null(corsPolicy.PreflightMaxAge); + } + + [Fact] + public void SettingNegativePreflightMaxAge_Throws() + { + // Arrange + var policy = new CorsPolicy(); + + // Act + var exception = Assert.Throws(() => + { + policy.PreflightMaxAge = TimeSpan.FromSeconds(-12); + }); + + // Assert + Assert.Equal( + "PreflightMaxAge must be greater than or equal to 0.\r\nParameter name: value", + exception.Message); + } + + [Fact] + public void ToString_ReturnsThePropertyValues() + { + // Arrange + var corsPolicy = new CorsPolicy + { + PreflightMaxAge = TimeSpan.FromSeconds(12), + SupportsCredentials = true + }; + corsPolicy.Headers.Add("foo"); + corsPolicy.Headers.Add("bar"); + corsPolicy.Origins.Add("http://example.com"); + corsPolicy.Origins.Add("http://example.org"); + corsPolicy.Methods.Add("GET"); + + // Act + var policyString = corsPolicy.ToString(); + + // Assert + Assert.Equal( + @"AllowAnyHeader: False, AllowAnyMethod: False, AllowAnyOrigin: False, PreflightMaxAge: 12,"+ + " SupportsCredentials: True, Origins: {http://example.com,http://example.org}, Methods: {GET},"+ + " Headers: {foo,bar}, ExposedHeaders: {}", + policyString); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs new file mode 100644 index 0000000000..ab094a86a3 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Xunit; + +namespace Microsoft.AspNet.Cors.Core.Test +{ + public class CorsResultTest + { + [Fact] + public void Default_Constructor() + { + // Arrange & Act + var result = new CorsResult(); + + // Assert + Assert.Empty(result.AllowedHeaders); + Assert.Empty(result.AllowedExposedHeaders); + Assert.Empty(result.AllowedMethods); + Assert.False(result.SupportsCredentials); + Assert.Null(result.AllowedOrigin); + Assert.Null(result.PreflightMaxAge); + } + + [Fact] + public void SettingNegativePreflightMaxAge_Throws() + { + // Arrange + var result = new CorsResult(); + + // Act + var exception = Assert.Throws(() => + { + result.PreflightMaxAge = TimeSpan.FromSeconds(-1); + }); + + // Assert + Assert.Equal( + "PreflightMaxAge must be greater than or equal to 0.\r\nParameter name: value", + exception.Message); + } + + [Fact] + public void ToString_ReturnsThePropertyValues() + { + // Arrange + var corsResult = new CorsResult + { + SupportsCredentials = true, + PreflightMaxAge = TimeSpan.FromSeconds(30), + AllowedOrigin = "*" + }; + corsResult.AllowedExposedHeaders.Add("foo"); + corsResult.AllowedHeaders.Add("bar"); + corsResult.AllowedHeaders.Add("baz"); + corsResult.AllowedMethods.Add("GET"); + + // Act + var result = corsResult.ToString(); + + // Assert + Assert.Equal( + @"AllowCredentials: True, PreflightMaxAge: 30, AllowOrigin: *," + + " AllowExposedHeaders: {foo}, AllowHeaders: {bar,baz}, AllowMethods: {GET}", + result); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs new file mode 100644 index 0000000000..24c20b1b2e --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -0,0 +1,904 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Core; +using Microsoft.Framework.OptionsModel; +using Moq; +using Xunit; + +namespace Microsoft.AspNet.Cors.Core.Test +{ + public class CorsServiceTests + { + [Fact] + public void EvaluatePolicy_NoOrigin_ReturnsInvalidResult() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext("GET", origin: null); + + // Act + var result = corsService.EvaluatePolicy(requestContext, new CorsPolicy()); + + // Assert + Assert.Null(result.AllowedOrigin); + Assert.False(result.VaryByOrigin); + } + + [Fact] + public void EvaluatePolicy_NoMatchingOrigin_ReturnsInvalidResult() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy(); + policy.Origins.Add("bar"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Null(result.AllowedOrigin); + Assert.False(result.VaryByOrigin); + } + + [Fact] + public void EvaluatePolicy_EmptyOriginsPolicy_ReturnsInvalidResult() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy(); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Null(result.AllowedOrigin); + Assert.False(result.VaryByOrigin); + } + + [Fact] + public void EvaluatePolicy_AllowAnyOrigin_DoesNotSupportCredentials_EmitsWildcardForOrigin() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + + var policy = new CorsPolicy + { + SupportsCredentials = false + }; + + policy.Origins.Add(CorsConstants.AnyOrigin); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal("*", result.AllowedOrigin); + } + + [Fact] + public void EvaluatePolicy_AllowAnyOrigin_SupportsCredentials_AddsSpecificOrigin() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy + { + SupportsCredentials = true + }; + policy.Origins.Add(CorsConstants.AnyOrigin); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal("http://example.com", result.AllowedOrigin); + Assert.True(result.VaryByOrigin); + } + + [Fact] + public void EvaluatePolicy_DoesNotSupportCredentials_AllowCredentialsReturnsFalse() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy + { + SupportsCredentials = false + }; + policy.Origins.Add(CorsConstants.AnyOrigin); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.False(result.SupportsCredentials); + } + + [Fact] + public void EvaluatePolicy_SupportsCredentials_AllowCredentialsReturnsTrue() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy + { + SupportsCredentials = true + }; + policy.Origins.Add(CorsConstants.AnyOrigin); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.True(result.SupportsCredentials); + } + + [Fact] + public void EvaluatePolicy_NoExposedHeaders_NoAllowExposedHeaders() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Empty(result.AllowedExposedHeaders); + } + + [Fact] + public void EvaluatePolicy_OneExposedHeaders_HeadersAllowed() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.ExposedHeaders.Add("foo"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal(1, result.AllowedExposedHeaders.Count); + Assert.Contains("foo", result.AllowedExposedHeaders); + } + + [Fact] + public void EvaluatePolicy_ManyExposedHeaders_HeadersAllowed() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.ExposedHeaders.Add("foo"); + policy.ExposedHeaders.Add("bar"); + policy.ExposedHeaders.Add("baz"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal(3, result.AllowedExposedHeaders.Count); + Assert.Contains("foo", result.AllowedExposedHeaders); + Assert.Contains("bar", result.AllowedExposedHeaders); + Assert.Contains("baz", result.AllowedExposedHeaders); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_MethodNotAllowed_ReturnsInvalidResult() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("GET"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Empty(result.AllowedMethods); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_MethodAllowed_ReturnsAllowMethods() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("PUT"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.NotNull(result); + Assert.Contains("PUT", result.AllowedMethods); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_OriginAllowed_ReturnsOrigin() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Origins.Add("http://example.com"); + policy.Methods.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal("http://example.com", result.AllowedOrigin); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_SupportsCredentials_AllowCredentialsReturnsTrue() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy + { + SupportsCredentials = true + }; + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.True(result.SupportsCredentials); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_NoPreflightMaxAge_NoPreflightMaxAgeSet() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy + { + PreflightMaxAge = null + }; + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Null(result.PreflightMaxAge); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_PreflightMaxAge_PreflightMaxAgeSet() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy + { + PreflightMaxAge = TimeSpan.FromSeconds(10) + }; + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal(TimeSpan.FromSeconds(10), result.PreflightMaxAge); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_AnyMethod_ReturnsRequestMethod() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "GET"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal(1, result.AllowedMethods.Count); + Assert.Contains("GET", result.AllowedMethods); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_ListedMethod_ReturnsSubsetOfListedMethods() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("PUT"); + policy.Methods.Add("DELETE"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal(1, result.AllowedMethods.Count); + Assert.Contains("PUT", result.AllowedMethods); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_NoHeadersRequested_AllowedAllHeaders_ReturnsEmptyHeaders() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + policy.Headers.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Empty(result.AllowedHeaders); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_HeadersRequested_AllowAllHeaders_ReturnsRequestedHeaders() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext( + method: "OPTIONS", + origin: "http://example.com", + accessControlRequestMethod: "PUT", + accessControlRequestHeaders: new[] { "foo", "bar" }); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + policy.Headers.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal(2, result.AllowedHeaders.Count); + Assert.Contains("foo", result.AllowedHeaders); + Assert.Contains("bar", result.AllowedHeaders); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_HeadersRequested_AllowSomeHeaders_ReturnsSubsetOfListedHeaders() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext( + method: "OPTIONS", + origin: "http://example.com", + accessControlRequestMethod: "PUT", + accessControlRequestHeaders: new[] { "Content-Type" }); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + policy.Headers.Add("foo"); + policy.Headers.Add("bar"); + policy.Headers.Add("Content-Type"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal(1, result.AllowedHeaders.Count); + Assert.Contains("Content-Type", result.AllowedHeaders); + } + + [Fact] + public void EvaluatePolicy_PreflightRequest_HeadersRequested_NotAllHeaderMatches_ReturnsInvalidResult() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + var requestContext = GetHttpContext( + method: "OPTIONS", + origin: "http://example.com", + accessControlRequestMethod: "PUT", + accessControlRequestHeaders: new[] { "match", "noMatch" }); + var policy = new CorsPolicy(); + policy.Origins.Add(CorsConstants.AnyOrigin); + policy.Methods.Add("*"); + policy.Headers.Add("match"); + policy.Headers.Add("foo"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Empty(result.AllowedHeaders); + Assert.Empty(result.AllowedMethods); + Assert.Empty(result.AllowedExposedHeaders); + Assert.Null(result.AllowedOrigin); + } + + [Fact] + public void EaluatePolicy_DoesCaseSensitiveComparison() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + + var policy = new CorsPolicy(); + policy.Methods.Add("POST"); + var httpContext = GetHttpContext(origin: null, accessControlRequestMethod: "post"); + + // Act + var result = corsService.EvaluatePolicy(httpContext, policy); + + // Assert + Assert.Empty(result.AllowedHeaders); + Assert.Empty(result.AllowedMethods); + Assert.Empty(result.AllowedExposedHeaders); + Assert.Null(result.AllowedOrigin); + } + + [Fact] + public void TryValidateOrigin_DoesCaseSensitiveComparison() + { + // Arrange + var corsService = new CorsService(Mock.Of>()); + + var policy = new CorsPolicy(); + policy.Origins.Add("http://Example.com"); + var httpContext = GetHttpContext(origin: "http://example.com"); + + // Act + var result = corsService.EvaluatePolicy(httpContext, policy); + + // Assert + Assert.Empty(result.AllowedHeaders); + Assert.Empty(result.AllowedMethods); + Assert.Empty(result.AllowedExposedHeaders); + Assert.Null(result.AllowedOrigin); + } + + + [Fact] + public void ApplyResult_ReturnsNoHeaders_ByDefault() + { + // Arrange + var result = new CorsResult(); + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Empty(httpContext.Response.Headers); + } + + [Fact] + public void ApplyResult_AllowOrigin_AllowOriginHeaderAdded() + { + // Arrange + var result = new CorsResult + { + AllowedOrigin = "http://example.com" + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Equal("http://example.com", httpContext.Response.Headers["Access-Control-Allow-Origin"]); + } + + [Fact] + public void ApplyResult_NoAllowOrigin_AllowOriginHeaderNotAdded() + { + // Arrange + var result = new CorsResult + { + AllowedOrigin = null + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Allow-Origin", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_AllowCredentials_AllowCredentialsHeaderAdded() + { + // Arrange + var result = new CorsResult + { + SupportsCredentials = true + }; + + var service = new CorsService(Mock.Of>()); + + // Act + var httpContext = new DefaultHttpContext(); + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Equal("true", httpContext.Response.Headers["Access-Control-Allow-Credentials"]); + } + + [Fact] + public void ApplyResult_AddVaryHeader_VaryHeaderAdded() + { + // Arrange + var result = new CorsResult + { + VaryByOrigin = true + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Equal("Origin", httpContext.Response.Headers["Vary"]); + } + + [Fact] + public void ApplyResult_NoAllowCredentials_AllowCredentialsHeaderNotAdded() + { + // Arrange + var result = new CorsResult + { + SupportsCredentials = false + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Allow-Credentials", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_NoAllowMethods_AllowMethodsHeaderNotAdded() + { + // Arrange + var result = new CorsResult + { + // AllowMethods is empty by default + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Allow-Methods", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_OneAllowMethods_AllowMethodsHeaderAdded() + { + // Arrange + var result = new CorsResult(); + result.AllowedMethods.Add("PUT"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Equal("PUT", httpContext.Response.Headers["Access-Control-Allow-Methods"]); + } + + [Fact] + public void ApplyResult_SomeSimpleAllowMethods_AllowMethodsHeaderAddedForNonSimpleMethods() + { + // Arrange + var result = new CorsResult(); + result.AllowedMethods.Add("PUT"); + result.AllowedMethods.Add("get"); + result.AllowedMethods.Add("DELETE"); + result.AllowedMethods.Add("POST"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Contains("Access-Control-Allow-Methods", httpContext.Response.Headers.Keys); + var methods = httpContext.Response.Headers["Access-Control-Allow-Methods"].Split(','); + Assert.Equal(2, methods.Length); + Assert.Contains("PUT", methods); + Assert.Contains("DELETE", methods); + } + + [Fact] + public void ApplyResult_SimpleAllowMethods_AllowMethodsHeaderNotAdded() + { + // Arrange + var result = new CorsResult(); + result.AllowedMethods.Add("GET"); + result.AllowedMethods.Add("HEAD"); + result.AllowedMethods.Add("POST"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Allow-Methods", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_NoAllowHeaders_AllowHeadersHeaderNotAdded() + { + // Arrange + var result = new CorsResult + { + // AllowHeaders is empty by default + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Allow-Headers", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_OneAllowHeaders_AllowHeadersHeaderAdded() + { + // Arrange + var result = new CorsResult(); + result.AllowedHeaders.Add("foo"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Equal("foo", httpContext.Response.Headers["Access-Control-Allow-Headers"]); + } + + [Fact] + public void ApplyResult_ManyAllowHeaders_AllowHeadersHeaderAdded() + { + // Arrange + var result = new CorsResult(); + result.AllowedHeaders.Add("foo"); + result.AllowedHeaders.Add("bar"); + result.AllowedHeaders.Add("baz"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Contains("Access-Control-Allow-Headers", httpContext.Response.Headers.Keys); + string[] headerValues = httpContext.Response.Headers["Access-Control-Allow-Headers"].Split(','); + Assert.Equal(3, headerValues.Length); + Assert.Contains("foo", headerValues); + Assert.Contains("bar", headerValues); + Assert.Contains("baz", headerValues); + } + + [Fact] + public void ApplyResult_SomeSimpleAllowHeaders_AllowHeadersHeaderAddedForNonSimpleHeaders() + { + // Arrange + var result = new CorsResult(); + result.AllowedHeaders.Add("Content-Language"); + result.AllowedHeaders.Add("foo"); + result.AllowedHeaders.Add("bar"); + result.AllowedHeaders.Add("Accept"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Contains("Access-Control-Allow-Headers", httpContext.Response.Headers.Keys); + string[] headerValues = httpContext.Response.Headers["Access-Control-Allow-Headers"].Split(','); + Assert.Equal(2, headerValues.Length); + Assert.Contains("foo", headerValues); + Assert.Contains("bar", headerValues); + } + + [Fact] + public void ApplyResult_SimpleAllowHeaders_AllowHeadersHeaderNotAdded() + { + // Arrange + var result = new CorsResult(); + result.AllowedHeaders.Add("Accept"); + result.AllowedHeaders.Add("Accept-Language"); + result.AllowedHeaders.Add("Content-Language"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Allow-Headers", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_NoAllowExposedHeaders_ExposedHeadersHeaderNotAdded() + { + // Arrange + var result = new CorsResult + { + // AllowExposedHeaders is empty by default + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Expose-Headers", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_OneAllowExposedHeaders_ExposedHeadersHeaderAdded() + { + // Arrange + var result = new CorsResult(); + result.AllowedExposedHeaders.Add("foo"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Equal("foo", httpContext.Response.Headers["Access-Control-Expose-Headers"]); + } + + [Fact] + public void ApplyResult_ManyAllowExposedHeaders_ExposedHeadersHeaderAdded() + { + // Arrange + var result = new CorsResult(); + result.AllowedExposedHeaders.Add("foo"); + result.AllowedExposedHeaders.Add("bar"); + result.AllowedExposedHeaders.Add("baz"); + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Contains("Access-Control-Expose-Headers", httpContext.Response.Headers.Keys); + string[] exposedHeaderValues = httpContext.Response.Headers["Access-Control-Expose-Headers"].Split(','); + Assert.Equal(3, exposedHeaderValues.Length); + Assert.Contains("foo", exposedHeaderValues); + Assert.Contains("bar", exposedHeaderValues); + Assert.Contains("baz", exposedHeaderValues); + } + + [Fact] + public void ApplyResult_NoPreflightMaxAge_MaxAgeHeaderNotAdded() + { + // Arrange + var result = new CorsResult + { + PreflightMaxAge = null + }; + + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.DoesNotContain("Access-Control-Max-Age", httpContext.Response.Headers.Keys); + } + + [Fact] + public void ApplyResult_PreflightMaxAge_MaxAgeHeaderAdded() + { + // Arrange + var result = new CorsResult + { + PreflightMaxAge = TimeSpan.FromSeconds(30) + }; + var httpContext = new DefaultHttpContext(); + var service = new CorsService(Mock.Of>()); + + // Act + service.ApplyResult(result, httpContext.Response); + + // Assert + Assert.Equal("30", httpContext.Response.Headers["Access-Control-Max-Age"]); + } + + + + private static HttpContext GetHttpContext( + string method = null, + string origin = null, + string accessControlRequestMethod = null, + string[] accessControlRequestHeaders = null) + { + var context = new DefaultHttpContext(); + + if (method != null) + { + context.Request.Method = method; + } + + if (origin != null) + { + context.Request.Headers.Add(CorsConstants.Origin, new[] { origin }); + } + + if (accessControlRequestMethod != null) + { + context.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { accessControlRequestMethod }); + } + + if (accessControlRequestHeaders != null) + { + context.Request.Headers.Add(CorsConstants.AccessControlRequestHeaders, accessControlRequestHeaders); + } + + return context; + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.kproj b/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.kproj new file mode 100644 index 0000000000..11bdbb5b21 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.kproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + b4f83a06-eb8e-4186-84c4-c6daf7eb03d4 + Microsoft.AspNet.Cors.Core.Test + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/project.json b/test/Microsoft.AspNet.Cors.Core.Test/project.json new file mode 100644 index 0000000000..3391960147 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Microsoft.AspNet.Cors.Core": "1.0.0-*", + "Microsoft.AspNet.Http.Core": "1.0.0-*", + "Moq": "4.2.1312.1622", + "xunit.runner.kre": "1.0.0-*" + }, + + "commands": { + "test": "xunit.runner.kre" + }, + + "frameworks" : { + "dnx451" : { + "dependencies": { + } + } + } +} From 7cf1f3fe63128bc8b84d871e34b195a1c5012b47 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 11 Mar 2015 14:04:30 -0700 Subject: [PATCH 009/271] Update .kproj => .xproj. --- CORS.sln | 4 ++-- ...spNet.Cors.Core.kproj => Microsoft.AspNet.Cors.Core.xproj} | 0 ....Core.Test.kproj => Microsoft.AspNet.Cors.Core.Test.xproj} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/Microsoft.AspNet.Cors.Core/{Microsoft.AspNet.Cors.Core.kproj => Microsoft.AspNet.Cors.Core.xproj} (100%) rename test/Microsoft.AspNet.Cors.Core.Test/{Microsoft.AspNet.Cors.Core.Test.kproj => Microsoft.AspNet.Cors.Core.Test.xproj} (100%) diff --git a/CORS.sln b/CORS.sln index 2cf414de64..62bed302c5 100644 --- a/CORS.sln +++ b/CORS.sln @@ -10,11 +10,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution global.json = global.json EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core", "src\Microsoft.AspNet.Cors.Core\Microsoft.AspNet.Cors.Core.kproj", "{C573AEE1-8D54-4A83-8D6B-61C85E8F713E}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core", "src\Microsoft.AspNet.Cors.Core\Microsoft.AspNet.Cors.Core.xproj", "{C573AEE1-8D54-4A83-8D6B-61C85E8F713E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F32074C7-087C-46CC-A913-422BFD2D6E0A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core.Test", "test\Microsoft.AspNet.Cors.Core.Test\Microsoft.AspNet.Cors.Core.Test.kproj", "{B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core.Test", "test\Microsoft.AspNet.Cors.Core.Test\Microsoft.AspNet.Cors.Core.Test.xproj", "{B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.kproj b/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj similarity index 100% rename from src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.kproj rename to src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj diff --git a/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.kproj b/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.kproj rename to test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj From da6a4f2ab7cf75b99391a1f93dcbb161d45109d8 Mon Sep 17 00:00:00 2001 From: Harsh Gupta Date: Wed, 25 Feb 2015 13:57:15 -0800 Subject: [PATCH 010/271] Adding Cors Middleware. --- CORS.sln | 32 ++- samples/UseOptions/Project_Readme.html | 204 +++++++++++++++++ samples/UseOptions/Startup.cs | 23 ++ samples/UseOptions/UseOptions.xproj | 19 ++ samples/UseOptions/project.json | 30 +++ samples/UsePolicyBuilder/Project_Readme.html | 204 +++++++++++++++++ samples/UsePolicyBuilder/Startup.cs | 21 ++ .../UsePolicyBuilder/UsePolicyBuilder.xproj | 19 ++ samples/UsePolicyBuilder/project.json | 30 +++ src/Microsoft.AspNet.Cors.Core/CorsOptions.cs | 19 ++ .../CorsPolicyBuilder.cs | 18 +- .../CorsServiceCollectionExtensions.cs | 1 + .../DefaultCorsPolicyProvider.cs | 31 +++ .../ICorsPolicyProvider.cs | 23 ++ .../Properties/Resources.Designer.cs | 64 ------ src/Microsoft.AspNet.Cors.Core/Resources.resx | 14 +- src/Microsoft.AspNet.Cors/CorsMiddleware.cs | 91 ++++++++ .../CorsMiddlewareExtensions.cs | 43 ++++ .../Microsoft.AspNet.Cors.xproj | 20 ++ src/Microsoft.AspNet.Cors/project.json | 21 ++ .../CorsPolicyBuilderTests.cs | 16 +- .../DefaultCorsPolicyProviderTests.cs | 58 +++++ .../project.json | 4 +- .../CorsMiddlewareTests.cs | 214 ++++++++++++++++++ .../Microsoft.AspNet.Cors.Test.xproj | 20 ++ test/Microsoft.AspNet.Cors.Test/project.json | 17 ++ 26 files changed, 1159 insertions(+), 97 deletions(-) create mode 100644 samples/UseOptions/Project_Readme.html create mode 100644 samples/UseOptions/Startup.cs create mode 100644 samples/UseOptions/UseOptions.xproj create mode 100644 samples/UseOptions/project.json create mode 100644 samples/UsePolicyBuilder/Project_Readme.html create mode 100644 samples/UsePolicyBuilder/Startup.cs create mode 100644 samples/UsePolicyBuilder/UsePolicyBuilder.xproj create mode 100644 samples/UsePolicyBuilder/project.json create mode 100644 src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs create mode 100644 src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs create mode 100644 src/Microsoft.AspNet.Cors/CorsMiddleware.cs create mode 100644 src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs create mode 100644 src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj create mode 100644 src/Microsoft.AspNet.Cors/project.json create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs create mode 100644 test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs create mode 100644 test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj create mode 100644 test/Microsoft.AspNet.Cors.Test/project.json diff --git a/CORS.sln b/CORS.sln index 62bed302c5..f3d81e9fcd 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22529.0 +VisualStudioVersion = 14.0.22711.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" EndProject @@ -16,6 +16,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F32074C7-0 EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core.Test", "test\Microsoft.AspNet.Cors.Core.Test\Microsoft.AspNet.Cors.Core.Test.xproj", "{B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors", "src\Microsoft.AspNet.Cors\Microsoft.AspNet.Cors.xproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Test", "test\Microsoft.AspNet.Cors.Test\Microsoft.AspNet.Cors.Test.xproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{EEF80A8E-F334-4C66-9537-8D24D002149D}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UseOptions", "samples\UseOptions\UseOptions.xproj", "{8DC90D0F-9660-42AD-BE08-4A7643A8F46E}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UsePolicyBuilder", "samples\UsePolicyBuilder\UsePolicyBuilder.xproj", "{6916DB8A-0246-45F8-9C64-9B05556C1A5D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,6 +40,22 @@ Global {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Release|Any CPU.Build.0 = Release|Any CPU + {41349FCD-D1C4-47A6-82D0-D16D00A8D59D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41349FCD-D1C4-47A6-82D0-D16D00A8D59D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {41349FCD-D1C4-47A6-82D0-D16D00A8D59D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {41349FCD-D1C4-47A6-82D0-D16D00A8D59D}.Release|Any CPU.Build.0 = Release|Any CPU + {F05BE96F-F869-4408-A480-96935B4835EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F05BE96F-F869-4408-A480-96935B4835EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F05BE96F-F869-4408-A480-96935B4835EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F05BE96F-F869-4408-A480-96935B4835EE}.Release|Any CPU.Build.0 = Release|Any CPU + {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Release|Any CPU.Build.0 = Release|Any CPU + {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -37,5 +63,9 @@ Global GlobalSection(NestedProjects) = preSolution {C573AEE1-8D54-4A83-8D6B-61C85E8F713E} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} + {41349FCD-D1C4-47A6-82D0-D16D00A8D59D} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} + {F05BE96F-F869-4408-A480-96935B4835EE} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} + {8DC90D0F-9660-42AD-BE08-4A7643A8F46E} = {EEF80A8E-F334-4C66-9537-8D24D002149D} + {6916DB8A-0246-45F8-9C64-9B05556C1A5D} = {EEF80A8E-F334-4C66-9537-8D24D002149D} EndGlobalSection EndGlobal diff --git a/samples/UseOptions/Project_Readme.html b/samples/UseOptions/Project_Readme.html new file mode 100644 index 0000000000..b693be4eba --- /dev/null +++ b/samples/UseOptions/Project_Readme.html @@ -0,0 +1,204 @@ + + + + + Welcome to ASP.NET 5 + + + + + + + + + + \ No newline at end of file diff --git a/samples/UseOptions/Startup.cs b/samples/UseOptions/Startup.cs new file mode 100644 index 0000000000..5c29d7f67d --- /dev/null +++ b/samples/UseOptions/Startup.cs @@ -0,0 +1,23 @@ +using System; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Http; +using Microsoft.Framework.DependencyInjection; + +namespace UseOptions +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddCors(); + services.ConfigureCors( + options => + options.AddPolicy("allowSingleOrigin", builder => builder.WithOrigins("http://example.com"))); + } + + public void Configure(IApplicationBuilder app) + { + app.UseCors("allowSingleOrigin"); + } + } +} diff --git a/samples/UseOptions/UseOptions.xproj b/samples/UseOptions/UseOptions.xproj new file mode 100644 index 0000000000..0ad1f53b04 --- /dev/null +++ b/samples/UseOptions/UseOptions.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 8dc90d0f-9660-42ad-be08-4a7643a8f46e + UseOptions + ..\artifacts\obj\$(MSBuildProjectName) + ..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + 5442 + + + \ No newline at end of file diff --git a/samples/UseOptions/project.json b/samples/UseOptions/project.json new file mode 100644 index 0000000000..6bcdc93d96 --- /dev/null +++ b/samples/UseOptions/project.json @@ -0,0 +1,30 @@ +{ + "webroot": "wwwroot", + "version": "1.0.0-*", + "dependencies": { + "Microsoft.AspNet.Cors": "1.0.0-*", + "Microsoft.AspNet.Diagnostics": "1.0.0-*", + "Microsoft.AspNet.Server.IIS": "1.0.0-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.Framework.Logging.Console": "1.0.0-*" + }, + "commands": { + "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" + }, + "frameworks": { + "dnx451": {}, + "dnxcore50": {} + }, + "bundleExclude": [ + "node_modules", + "bower_components", + "**.kproj", + "**.user", + "**.vspscc" + ], + "exclude": [ + "wwwroot", + "node_modules", + "bower_components" + ] +} \ No newline at end of file diff --git a/samples/UsePolicyBuilder/Project_Readme.html b/samples/UsePolicyBuilder/Project_Readme.html new file mode 100644 index 0000000000..b693be4eba --- /dev/null +++ b/samples/UsePolicyBuilder/Project_Readme.html @@ -0,0 +1,204 @@ + + + + + Welcome to ASP.NET 5 + + + + + + + + + + \ No newline at end of file diff --git a/samples/UsePolicyBuilder/Startup.cs b/samples/UsePolicyBuilder/Startup.cs new file mode 100644 index 0000000000..de8233cfbb --- /dev/null +++ b/samples/UsePolicyBuilder/Startup.cs @@ -0,0 +1,21 @@ +using System; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Cors.Core; +using Microsoft.AspNet.Http; +using Microsoft.Framework.DependencyInjection; + +namespace UsePolicy +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddCors(); + } + + public void Configure(IApplicationBuilder app) + { + app.UseCors(policy => policy.WithOrigins("http://example.com")); + } + } +} diff --git a/samples/UsePolicyBuilder/UsePolicyBuilder.xproj b/samples/UsePolicyBuilder/UsePolicyBuilder.xproj new file mode 100644 index 0000000000..cf8bbbdeb7 --- /dev/null +++ b/samples/UsePolicyBuilder/UsePolicyBuilder.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 6916db8a-0246-45f8-9c64-9b05556c1a5d + UseOptions + ..\artifacts\obj\$(MSBuildProjectName) + ..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + 12497 + + + \ No newline at end of file diff --git a/samples/UsePolicyBuilder/project.json b/samples/UsePolicyBuilder/project.json new file mode 100644 index 0000000000..6bcdc93d96 --- /dev/null +++ b/samples/UsePolicyBuilder/project.json @@ -0,0 +1,30 @@ +{ + "webroot": "wwwroot", + "version": "1.0.0-*", + "dependencies": { + "Microsoft.AspNet.Cors": "1.0.0-*", + "Microsoft.AspNet.Diagnostics": "1.0.0-*", + "Microsoft.AspNet.Server.IIS": "1.0.0-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.Framework.Logging.Console": "1.0.0-*" + }, + "commands": { + "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" + }, + "frameworks": { + "dnx451": {}, + "dnxcore50": {} + }, + "bundleExclude": [ + "node_modules", + "bower_components", + "**.kproj", + "**.user", + "**.vspscc" + ], + "exclude": [ + "wwwroot", + "node_modules", + "bower_components" + ] +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs index 7d76181e62..0a94c70bfb 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs @@ -13,8 +13,27 @@ namespace Microsoft.AspNet.Cors.Core /// public class CorsOptions { + private string _defaultPolicyName = "__DefaultCorsPolicy"; private IDictionary PolicyMap { get; } = new Dictionary(); + public string DefaultPolicyName + { + get + { + return _defaultPolicyName; + } + + set + { + if (value == null) + { + throw new ArgumentNullException("value"); + } + + _defaultPolicyName = value; + } + } + /// /// Adds a new policy. /// diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs index 83303009bb..b9dd7d9f68 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Cors /// list of origins which can be added. public CorsPolicyBuilder(params string[] origins) { - AddOrigins(origins); + WithOrigins(origins); } /// @@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Cors /// /// The origins that are allowed. /// The current policy builder - public CorsPolicyBuilder AddOrigins(params string[] origins) + public CorsPolicyBuilder WithOrigins(params string[] origins) { foreach (var req in origins) { @@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Cors /// /// The headers which need to be allowed in the request. /// The current policy builder - public CorsPolicyBuilder AddHeaders(params string[] headers) + public CorsPolicyBuilder WithHeaders(params string[] headers) { foreach (var req in headers) { @@ -67,7 +67,7 @@ namespace Microsoft.AspNet.Cors /// /// The headers which need to be exposed to the client. /// The current policy builder - public CorsPolicyBuilder AddExposedHeaders(params string[] exposedHeaders) + public CorsPolicyBuilder WithExposedHeaders(params string[] exposedHeaders) { foreach (var req in exposedHeaders) { @@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Cors /// /// The methods which need to be added to the policy. /// The current policy builder - public CorsPolicyBuilder AddMethods(params string[] methods) + public CorsPolicyBuilder WithMethods(params string[] methods) { foreach (var req in methods) { @@ -173,10 +173,10 @@ namespace Microsoft.AspNet.Cors /// The current policy builder private CorsPolicyBuilder Combine([NotNull] CorsPolicy policy) { - AddOrigins(policy.Origins.ToArray()); - AddHeaders(policy.Headers.ToArray()); - AddExposedHeaders(policy.ExposedHeaders.ToArray()); - AddMethods(policy.Methods.ToArray()); + WithOrigins(policy.Origins.ToArray()); + WithHeaders(policy.Headers.ToArray()); + WithExposedHeaders(policy.ExposedHeaders.ToArray()); + WithMethods(policy.Methods.ToArray()); SetPreflightMaxAge(policy.PreflightMaxAge.Value); if (policy.SupportsCredentials) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index adb38d189a..544b426837 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -36,6 +36,7 @@ namespace Microsoft.Framework.DependencyInjection { serviceCollection.AddOptions(); serviceCollection.AddTransient(); + serviceCollection.AddTransient(); return serviceCollection; } } diff --git a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs new file mode 100644 index 0000000000..307744e461 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Microsoft.AspNet.Http; +using Microsoft.Framework.Internal; +using Microsoft.Framework.OptionsModel; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + public class DefaultCorsPolicyProvider : ICorsPolicyProvider + { + private readonly CorsOptions _options; + + /// + /// Creates a new instance of . + /// + /// The options configured for the application. + public DefaultCorsPolicyProvider(IOptions options) + { + _options = options.Options; + } + + /// + public Task GetPolicyAsync(HttpContext context, string policyName) + { + return Task.FromResult(_options.GetPolicy(policyName ?? _options.DefaultPolicyName)); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs new file mode 100644 index 0000000000..b837230ff7 --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Microsoft.AspNet.Http; +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Cors.Core +{ + /// + /// A type which can provide a for a particular . + /// + public interface ICorsPolicyProvider + { + /// + /// Gets a from the given + /// + /// The associated with this call. + /// An optional policy name to look for. + /// A + Task GetPolicyAsync([NotNull] HttpContext context, string policyName); + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs index f50fb004a2..8b6e085a94 100644 --- a/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs +++ b/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs @@ -10,70 +10,6 @@ namespace Microsoft.AspNet.Cors.Core private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.AspNet.Cors.Core.Resources", typeof(Resources).GetTypeInfo().Assembly); - /// - /// The collection of headers '{0}' is not allowed. - /// - internal static string HeadersNotAllowed - { - get { return GetString("HeadersNotAllowed"); } - } - - /// - /// The collection of headers '{0}' is not allowed. - /// - internal static string FormatHeadersNotAllowed(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("HeadersNotAllowed"), p0); - } - - /// - /// The method '{0}' is not allowed. - /// - internal static string MethodNotAllowed - { - get { return GetString("MethodNotAllowed"); } - } - - /// - /// The method '{0}' is not allowed. - /// - internal static string FormatMethodNotAllowed(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("MethodNotAllowed"), p0); - } - - /// - /// The request does not contain the Origin header. - /// - internal static string NoOriginHeader - { - get { return GetString("NoOriginHeader"); } - } - - /// - /// The request does not contain the Origin header. - /// - internal static string FormatNoOriginHeader() - { - return GetString("NoOriginHeader"); - } - - /// - /// The origin '{0}' is not allowed. - /// - internal static string OriginNotAllowed - { - get { return GetString("OriginNotAllowed"); } - } - - /// - /// The origin '{0}' is not allowed. - /// - internal static string FormatOriginNotAllowed(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("OriginNotAllowed"), p0); - } - /// /// PreflightMaxAge must be greater than or equal to 0. /// diff --git a/src/Microsoft.AspNet.Cors.Core/Resources.resx b/src/Microsoft.AspNet.Cors.Core/Resources.resx index ef0e5b5f1f..6b9ebaad31 100644 --- a/src/Microsoft.AspNet.Cors.Core/Resources.resx +++ b/src/Microsoft.AspNet.Cors.Core/Resources.resx @@ -117,19 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - The collection of headers '{0}' is not allowed. - - - The method '{0}' is not allowed. - - - The request does not contain the Origin header. - - - The origin '{0}' is not allowed. - - + PreflightMaxAge must be greater than or equal to 0. \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs new file mode 100644 index 0000000000..21c079ed99 --- /dev/null +++ b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Cors.Core; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.WebUtilities; +using Microsoft.Framework.Internal; +using Microsoft.Framework.OptionsModel; + +namespace Microsoft.AspNet.Cors +{ + /// + /// An ASP.NET middleware for handling CORS. + /// + public class CorsMiddleware + { + private readonly RequestDelegate _next; + private readonly ICorsService _corsService; + private readonly ICorsPolicyProvider _corsPolicyProvider; + private readonly CorsPolicy _policy; + private readonly string _corsPolicyName; + + /// + /// Instantiates a new . + /// + /// The next middleware in the pipeline. + /// An instance of . + /// A policy provider which can get an . + /// An optional name of the policy to be fetched. + public CorsMiddleware( + [NotNull] RequestDelegate next, + [NotNull] ICorsService corsService, + [NotNull] ICorsPolicyProvider policyProvider, + string policyName) + { + _next = next; + _corsService = corsService; + _corsPolicyProvider = policyProvider; + _corsPolicyName = policyName; + } + + /// + /// Instantiates a new . + /// + /// The next middleware in the pipeline. + /// An instance of . + /// An instance of the which can be applied. + public CorsMiddleware( + [NotNull] RequestDelegate next, + [NotNull] ICorsService corsService, + [NotNull] CorsPolicy policy) + { + _next = next; + _corsService = corsService; + _policy = policy; + } + + /// + public async Task Invoke(HttpContext context) + { + if (context.Request.Headers.ContainsKey(CorsConstants.Origin)) + { + var corsPolicy = _policy ?? await _corsPolicyProvider?.GetPolicyAsync(context, _corsPolicyName); + if (corsPolicy != null) + { + var corsResult = _corsService.EvaluatePolicy(context, corsPolicy); + _corsService.ApplyResult(corsResult, context.Response); + + var accessControlRequestMethod = + context.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); + if (string.Equals( + context.Request.Method, + CorsConstants.PreflightHttpMethod, + StringComparison.Ordinal) && + accessControlRequestMethod != null) + { + // Since there is a policy which was identified, + // always respond to preflight requests. + context.Response.StatusCode = StatusCodes.Status204NoContent; + return; + } + } + } + + await _next(context); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs new file mode 100644 index 0000000000..88e529dea8 --- /dev/null +++ b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.AspNet.Cors; +using Microsoft.AspNet.Cors.Core; +using Microsoft.Framework.Internal; + +namespace Microsoft.AspNet.Builder +{ + /// + /// The extensions for adding CORS middleware support. + /// + public static class CorsMiddlewareExtensions + { + /// + /// Adds a CORS middleware to your web application pipeline to allow cross domain requests. + /// + /// The IApplicationBuilder passed to your Configure method + /// The policy name of a configured policy. + /// The original app parameter + public static IApplicationBuilder UseCors([NotNull]this IApplicationBuilder app, string policyName) + { + return app.UseMiddleware(policyName); + } + + /// + /// Adds a CORS middleware to your web application pipeline to allow cross domain requests. + /// + /// The IApplicationBuilder passed to your Configure method. + /// A delegate which can use a policy builder to build a policy. + /// The original app parameter + public static IApplicationBuilder UseCors( + [NotNull] this IApplicationBuilder app, + [NotNull] Action configurePolicy) + { + var policyBuilder = new CorsPolicyBuilder(); + configurePolicy(policyBuilder); + return app.UseMiddleware(policyBuilder.Build()); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj b/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj new file mode 100644 index 0000000000..34f1a256e0 --- /dev/null +++ b/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 41349fcd-d1c4-47a6-82d0-d16d00a8d59d + Microsoft.AspNet.Cors + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json new file mode 100644 index 0000000000..bf9e28ec79 --- /dev/null +++ b/src/Microsoft.AspNet.Cors/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + "dependencies": { + "Microsoft.AspNet.Cors.Core": "1.0.0-*", + "Microsoft.AspNet.RequestContainer": "1.0.0-*", + "Microsoft.AspNet.WebUtilities": "1.0.0-*", + "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" } + }, + + "frameworks" : { + "dnx451" : { + "dependencies": { + } + }, + "dnxcore50" : { + "dependencies": { + "System.Runtime": "4.0.20-beta-*" + } + } + } +} diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs index 3a7a7227ec..2b6d424137 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs @@ -83,13 +83,13 @@ namespace Microsoft.AspNet.Cors.Core.Test } [Fact] - public void AddOrigins_AddsOrigins() + public void WithOrigins_AddsOrigins() { // Arrange var builder = new CorsPolicyBuilder(); // Act - builder.AddOrigins("http://example.com", "http://example2.com"); + builder.WithOrigins("http://example.com", "http://example2.com"); // Assert var corsPolicy = builder.Build(); @@ -114,13 +114,13 @@ namespace Microsoft.AspNet.Cors.Core.Test [Fact] - public void AddMethods_AddsMethods() + public void WithMethods_AddsMethods() { // Arrange var builder = new CorsPolicyBuilder(); // Act - builder.AddMethods("PUT", "GET"); + builder.WithMethods("PUT", "GET"); // Assert var corsPolicy = builder.Build(); @@ -144,13 +144,13 @@ namespace Microsoft.AspNet.Cors.Core.Test } [Fact] - public void AddHeaders_AddsHeaders() + public void WithHeaders_AddsHeaders() { // Arrange var builder = new CorsPolicyBuilder(); // Act - builder.AddHeaders("example1", "example2"); + builder.WithHeaders("example1", "example2"); // Assert var corsPolicy = builder.Build(); @@ -174,13 +174,13 @@ namespace Microsoft.AspNet.Cors.Core.Test } [Fact] - public void AddExposedHeaders_AddsExposedHeaders() + public void WithExposedHeaders_AddsExposedHeaders() { // Arrange var builder = new CorsPolicyBuilder(); // Act - builder.AddExposedHeaders("exposed1", "exposed2"); + builder.WithExposedHeaders("exposed1", "exposed2"); // Assert var corsPolicy = builder.Build(); diff --git a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs new file mode 100644 index 0000000000..a04297bdb5 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Microsoft.AspNet.Http.Core; +using Microsoft.Framework.OptionsModel; +using Moq; +using Xunit; + +namespace Microsoft.AspNet.Cors.Core.Test +{ + public class DefaultPolicyProviderTests + { + [Fact] + public async Task UsesTheDefaultPolicyName() + { + // Arrange + var options = new CorsOptions(); + var policy = new CorsPolicy(); + options.AddPolicy(options.DefaultPolicyName, policy); + + var mockOptions = new Mock>(); + mockOptions + .SetupGet(o => o.Options) + .Returns(options); + var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); + + // Act + var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName: null); + + // Assert + Assert.Same(policy, actualPolicy); + } + + [Theory] + [InlineData("")] + [InlineData("policyName")] + public async Task GetsNamedPolicy(string policyName) + { + // Arrange + var options = new CorsOptions(); + var policy = new CorsPolicy(); + options.AddPolicy(policyName, policy); + + var mockOptions = new Mock>(); + mockOptions + .SetupGet(o => o.Options) + .Returns(options); + var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); + + // Act + var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName); + + // Assert + Assert.Same(policy, actualPolicy); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/project.json b/test/Microsoft.AspNet.Cors.Core.Test/project.json index 3391960147..4c01305c27 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Core.Test/project.json @@ -5,11 +5,11 @@ "Microsoft.AspNet.Cors.Core": "1.0.0-*", "Microsoft.AspNet.Http.Core": "1.0.0-*", "Moq": "4.2.1312.1622", - "xunit.runner.kre": "1.0.0-*" + "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "commands": { - "test": "xunit.runner.kre" + "test": "xunit.runner.aspnet" }, "frameworks" : { diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs new file mode 100644 index 0000000000..fc7da7b900 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq; +using System.Net; +using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Cors.Core; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Core; +using Microsoft.AspNet.TestHost; +using Microsoft.Framework.DependencyInjection; +using Moq; +using Xunit; + +namespace Microsoft.AspNet.Cors.Test +{ + public class CorsMiddlewareTests + { + [Fact] + public async Task CorsRequest_MatchPolicy_SetsResponseHeaders() + { + // Arrange + using (var server = TestServer.Create(app => + { + app.UseServices(services => services.AddCors()); + app.UseCors(builder => + builder.WithOrigins("http://localhost:5001") + .WithMethods("PUT") + .WithHeaders("Header1") + .WithExposedHeaders("AllowedHeader")); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + })) + { + // Act + // Actual request. + var response = await server.CreateRequest("/") + .AddHeader(CorsConstants.Origin, "http://localhost:5001") + .SendAsync("PUT"); + + // Assert + response.EnsureSuccessStatusCode(); + Assert.Equal(2, response.Headers.Count()); + Assert.Equal("Cross origin response", await response.Content.ReadAsStringAsync()); + Assert.Equal("http://localhost:5001", response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault()); + Assert.Equal("AllowedHeader", response.Headers.GetValues(CorsConstants.AccessControlExposeHeaders).FirstOrDefault()); + } + } + + [Fact] + public async Task PreFlight_MatchesPolicy_SetsResponseHeaders() + { + // Arrange + var policy = new CorsPolicy(); + policy.Origins.Add("http://localhost:5001"); + policy.Methods.Add("PUT"); + policy.Headers.Add("Header1"); + policy.ExposedHeaders.Add("AllowedHeader"); + + using (var server = TestServer.Create(app => + { + app.UseServices(services => + { + services.AddCors(); + services.ConfigureCors(options => + { + options.AddPolicy("customPolicy", policy); + }); + }); + app.UseCors("customPolicy"); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + })) + { + // Act + // Preflight request. + var response = await server.CreateRequest("/") + .AddHeader(CorsConstants.Origin, "http://localhost:5001") + .AddHeader(CorsConstants.AccessControlRequestMethod, "PUT") + .SendAsync(CorsConstants.PreflightHttpMethod); + + // Assert + response.EnsureSuccessStatusCode(); + Assert.Equal(2, response.Headers.Count()); + Assert.Equal("http://localhost:5001", response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault()); + Assert.Equal("PUT", response.Headers.GetValues(CorsConstants.AccessControlAllowMethods).FirstOrDefault()); + } + } + + [Fact] + public async Task PreFlightRequest_DoesNotMatchPolicy_DoesNotSetHeaders() + { + // Arrange + using (var server = TestServer.Create(app => + { + app.UseServices(services => services.AddCors()); + app.UseCors(builder => + builder.WithOrigins("http://localhost:5001") + .WithMethods("PUT") + .WithHeaders("Header1") + .WithExposedHeaders("AllowedHeader")); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + })) + { + // Act + // Preflight request. + var response = await server.CreateRequest("/") + .AddHeader(CorsConstants.Origin, "http://localhost:5002") + .AddHeader(CorsConstants.AccessControlRequestMethod, "PUT") + .SendAsync(CorsConstants.PreflightHttpMethod); + + // Assert + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + Assert.Empty(response.Headers); + } + } + + [Fact] + public async Task CorsRequest_DoesNotMatchPolicy_DoesNotSetHeaders() + { + // Arrange + using (var server = TestServer.Create(app => + { + app.UseServices(services => services.AddCors()); + app.UseCors(builder => + builder.WithOrigins("http://localhost:5001") + .WithMethods("PUT") + .WithHeaders("Header1") + .WithExposedHeaders("AllowedHeader")); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + })) + { + // Act + // Actual request. + var response = await server.CreateRequest("/") + .AddHeader(CorsConstants.Origin, "http://localhost:5002") + .SendAsync("PUT"); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Empty(response.Headers); + } + } + + [Fact] + public async Task Uses_PolicyProvider_AsFallback() + { + // Arrange + var corsService = Mock.Of(); + var mockProvider = new Mock(); + mockProvider.Setup(o => o.GetPolicyAsync(It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(null)) + .Verifiable(); + + var middleware = new CorsMiddleware( + Mock.Of(), + corsService, + mockProvider.Object, + policyName: null); + + var httpContext = new DefaultHttpContext(); + httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); + + // Act + await middleware.Invoke(httpContext); + + // Assert + mockProvider.Verify( + o => o.GetPolicyAsync(It.IsAny(), It.IsAny()), + Times.Once); + } + + [Fact] + public async Task DoesNotSetHeaders_ForNoPolicy() + { + // Arrange + var corsService = Mock.Of(); + var mockProvider = new Mock(); + mockProvider.Setup(o => o.GetPolicyAsync(It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(null)) + .Verifiable(); + + var middleware = new CorsMiddleware( + Mock.Of(), + corsService, + mockProvider.Object, + policyName: null); + + var httpContext = new DefaultHttpContext(); + httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); + + // Act + await middleware.Invoke(httpContext); + + // Assert + Assert.Equal(200, httpContext.Response.StatusCode); + Assert.Empty(httpContext.Response.Headers); + mockProvider.Verify( + o => o.GetPolicyAsync(It.IsAny(), It.IsAny()), + Times.Once); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj b/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj new file mode 100644 index 0000000000..e1e0c40b4c --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + f05be96f-f869-4408-a480-96935b4835ee + Microsoft.AspNet.Cors.Test + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Test/project.json b/test/Microsoft.AspNet.Cors.Test/project.json new file mode 100644 index 0000000000..a75b306308 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Test/project.json @@ -0,0 +1,17 @@ +{ + "version": "1.0.0-*", + "dependencies": { + "Microsoft.AspNet.Cors": "1.0.0-*", + "Microsoft.AspNet.TestHost": "1.0.0-*", + "Moq": "4.2.1312.1622", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { + "dependencies": {} + } + } +} \ No newline at end of file From 57f22197a944c9bf782e7b328b7f158065f61698 Mon Sep 17 00:00:00 2001 From: Harsh Gupta Date: Wed, 18 Mar 2015 10:08:45 -0700 Subject: [PATCH 011/271] Enable and Disable Interface renames --- src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs | 2 +- src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs | 2 +- .../{IDisableCorsMetadata.cs => IDisableCorsAttribute.cs} | 2 +- .../{IEnableCorsMetadata.cs => IEnableCorsAttribute.cs} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename src/Microsoft.AspNet.Cors.Core/{IDisableCorsMetadata.cs => IDisableCorsAttribute.cs} (89%) rename src/Microsoft.AspNet.Cors.Core/{IEnableCorsMetadata.cs => IEnableCorsAttribute.cs} (100%) diff --git a/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs index 4ebcb449b1..162915e266 100644 --- a/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNet.Cors.Core { /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - public class DisableCorsAttribute : Attribute, IDisableCorsMetadata + public class DisableCorsAttribute : Attribute, IDisableCorsAttribute { } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs index d53016e09f..3e7bf2aa0d 100644 --- a/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNet.Cors.Core { /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] - public class EnableCorsAttribute : Attribute, IEnableCorsMetadata + public class EnableCorsAttribute : Attribute, IEnableCorsAttribute { /// /// Creates a new instance of the . diff --git a/src/Microsoft.AspNet.Cors.Core/IDisableCorsMetadata.cs b/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs similarity index 89% rename from src/Microsoft.AspNet.Cors.Core/IDisableCorsMetadata.cs rename to src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs index 6afe8fc272..a9e5566baf 100644 --- a/src/Microsoft.AspNet.Cors.Core/IDisableCorsMetadata.cs +++ b/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs @@ -6,7 +6,7 @@ namespace Microsoft.AspNet.Cors.Core /// /// An interface which can be used to identify a type which provides metdata to disable cors for a resource. /// - public interface IDisableCorsMetadata + public interface IDisableCorsAttribute { } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/IEnableCorsMetadata.cs b/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNet.Cors.Core/IEnableCorsMetadata.cs rename to src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs From 55af12b62051b40253b9725328e7fafbc362e7c5 Mon Sep 17 00:00:00 2001 From: Harsh Gupta Date: Wed, 18 Mar 2015 10:12:25 -0700 Subject: [PATCH 012/271] Fixing break --- src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs index 2270ff7bf5..7dd0d4a8a4 100644 --- a/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs @@ -6,7 +6,7 @@ namespace Microsoft.AspNet.Cors.Core /// /// An interface which can be used to identify a type which provides metadata needed for enabling CORS support. /// - public interface IEnableCorsMetadata + public interface IEnableCorsAttribute { /// /// The name of the policy which needs to be applied. From 7fe9aceb1923259f8404b44b736c7ae4607c54ec Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 19 Mar 2015 11:20:23 -0700 Subject: [PATCH 013/271] React to hosting --- src/Microsoft.AspNet.Cors/project.json | 2 +- .../CorsMiddlewareTests.cs | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index bf9e28ec79..c5cf4cf35a 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.Cors.Core": "1.0.0-*", - "Microsoft.AspNet.RequestContainer": "1.0.0-*", + "Microsoft.AspNet.Hosting": "1.0.0-*", "Microsoft.AspNet.WebUtilities": "1.0.0-*", "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" } }, diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index fc7da7b900..10e0cdbd86 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -23,7 +23,6 @@ namespace Microsoft.AspNet.Cors.Test // Arrange using (var server = TestServer.Create(app => { - app.UseServices(services => services.AddCors()); app.UseCors(builder => builder.WithOrigins("http://localhost:5001") .WithMethods("PUT") @@ -33,7 +32,8 @@ namespace Microsoft.AspNet.Cors.Test { await context.Response.WriteAsync("Cross origin response"); }); - })) + }, + services => services.AddCors())) { // Act // Actual request. @@ -62,19 +62,19 @@ namespace Microsoft.AspNet.Cors.Test using (var server = TestServer.Create(app => { - app.UseServices(services => - { - services.AddCors(); - services.ConfigureCors(options => - { - options.AddPolicy("customPolicy", policy); - }); - }); app.UseCors("customPolicy"); app.Run(async context => { await context.Response.WriteAsync("Cross origin response"); }); + }, + services => + { + services.AddCors(); + services.ConfigureCors(options => + { + options.AddPolicy("customPolicy", policy); + }); })) { // Act @@ -98,7 +98,6 @@ namespace Microsoft.AspNet.Cors.Test // Arrange using (var server = TestServer.Create(app => { - app.UseServices(services => services.AddCors()); app.UseCors(builder => builder.WithOrigins("http://localhost:5001") .WithMethods("PUT") @@ -108,7 +107,8 @@ namespace Microsoft.AspNet.Cors.Test { await context.Response.WriteAsync("Cross origin response"); }); - })) + }, + services => services.AddCors())) { // Act // Preflight request. @@ -129,7 +129,6 @@ namespace Microsoft.AspNet.Cors.Test // Arrange using (var server = TestServer.Create(app => { - app.UseServices(services => services.AddCors()); app.UseCors(builder => builder.WithOrigins("http://localhost:5001") .WithMethods("PUT") @@ -139,7 +138,8 @@ namespace Microsoft.AspNet.Cors.Test { await context.Response.WriteAsync("Cross origin response"); }); - })) + }, + services => services.AddCors())) { // Act // Actual request. From 543b08c254182a5635e90634a1349bb768847a9e Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 19 Mar 2015 19:45:14 -0700 Subject: [PATCH 014/271] Fixed CORS dependencies --- src/Microsoft.AspNet.Cors/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index c5cf4cf35a..b2e26d0308 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.Cors.Core": "1.0.0-*", - "Microsoft.AspNet.Hosting": "1.0.0-*", + "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.AspNet.WebUtilities": "1.0.0-*", "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" } }, From da56d693c4365396650570585821da864716fde5 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 24 Mar 2015 21:27:52 -0700 Subject: [PATCH 015/271] Remove k command and use dnx instead --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index ec3263114a..d81164353c 100644 --- a/build.sh +++ b/build.sh @@ -31,7 +31,7 @@ if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi -if ! type k > /dev/null 2>&1; then +if ! type dnx > /dev/null 2>&1; then dnvm upgrade fi From 586070f37734f55e1e079437727e864da4921f1f Mon Sep 17 00:00:00 2001 From: hishamco Date: Wed, 25 Mar 2015 12:14:18 +0300 Subject: [PATCH 016/271] Update 'dnvmx -x86' switch --- build.cmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 68a732c182..41025afb26 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 :run -CALL packages\KoreBuild\build\dnvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* From 2fc5508decbe321c00f025dbe34ae428a0a90cfa Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Thu, 26 Mar 2015 12:28:58 -0700 Subject: [PATCH 017/271] Updated Nuget.config to release feed --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..2d3b0cb857 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From 099d910579b20ca716b1b84899e9834f69748a96 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Sun, 29 Mar 2015 10:47:00 -0700 Subject: [PATCH 018/271] Rename "dnu bundle" to "dnu publish" --- samples/UseOptions/project.json | 2 +- samples/UsePolicyBuilder/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/UseOptions/project.json b/samples/UseOptions/project.json index 6bcdc93d96..cef1621e00 100644 --- a/samples/UseOptions/project.json +++ b/samples/UseOptions/project.json @@ -15,7 +15,7 @@ "dnx451": {}, "dnxcore50": {} }, - "bundleExclude": [ + "publishExclude": [ "node_modules", "bower_components", "**.kproj", diff --git a/samples/UsePolicyBuilder/project.json b/samples/UsePolicyBuilder/project.json index 6bcdc93d96..cef1621e00 100644 --- a/samples/UsePolicyBuilder/project.json +++ b/samples/UsePolicyBuilder/project.json @@ -15,7 +15,7 @@ "dnx451": {}, "dnxcore50": {} }, - "bundleExclude": [ + "publishExclude": [ "node_modules", "bower_components", "**.kproj", From c23dda2e29d62d6d349a65f27ac0d1b32cba49d0 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 1 Apr 2015 15:38:46 -0700 Subject: [PATCH 019/271] Add travis and appveyor CI support. --- .travis.yml | 3 +++ appveyor.yml | 5 +++++ build.sh | 0 3 files changed, 8 insertions(+) create mode 100644 .travis.yml create mode 100644 appveyor.yml mode change 100644 => 100755 build.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..0f4cb93e59 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: csharp +script: + - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..88cb9ef145 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,5 @@ +build_script: + - build.cmd verify +clone_depth: 1 +test: off +deploy: off \ No newline at end of file diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 From 3189b36877370f7ebaa31637b69bd224134ce33e Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 1 Apr 2015 17:04:12 -0700 Subject: [PATCH 020/271] Turn off sudo for .travis.yml. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0f4cb93e59..5939a529e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: csharp +sudo: false script: - ./build.sh verify \ No newline at end of file From 2562becc0bd4eb7f9fa59a2a77289fdee0d1240b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 1 Apr 2015 18:08:34 -0700 Subject: [PATCH 021/271] Adding status badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3c46d88951..5ed1513680 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ CORS === +AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/yi0m8evjtg107o12/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/CORS/branch/dev) + +Travis: [![Travis](https://travis-ci.org/aspnet/CORS.svg?branch=dev)](https://travis-ci.org/aspnet/CORS) + CORS repository includes the core implementation for CORS policy, utilized by the CORS middleware and MVC. This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. From 532fca365cdb8b46db25ebeada04ea28716a5e00 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 2 Apr 2015 09:19:52 -0700 Subject: [PATCH 022/271] Update global.json, sources=>projects --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index be397c3721..ec2e704f70 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,3 @@ { - "sources": ["src", "test"] -} \ No newline at end of file + "projects": ["src", "test"] +} From cd1ca24d471dc45adc309f6c3a19af3751251a5f Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 2 Apr 2015 13:49:23 -0700 Subject: [PATCH 023/271] Update .xproj files for Microsoft.Web.AspNet.* -> Microsoft.DNX.* rename --- samples/UseOptions/UseOptions.xproj | 9 ++++----- samples/UsePolicyBuilder/UsePolicyBuilder.xproj | 9 ++++----- .../Microsoft.AspNet.Cors.Core.xproj | 7 ++----- src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj | 7 ++----- .../Microsoft.AspNet.Cors.Core.Test.xproj | 7 ++----- .../Microsoft.AspNet.Cors.Test.xproj | 7 ++----- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/samples/UseOptions/UseOptions.xproj b/samples/UseOptions/UseOptions.xproj index 0ad1f53b04..93e6c00701 100644 --- a/samples/UseOptions/UseOptions.xproj +++ b/samples/UseOptions/UseOptions.xproj @@ -4,16 +4,15 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 8dc90d0f-9660-42ad-be08-4a7643a8f46e - UseOptions - ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ 2.0 5442 - + \ No newline at end of file diff --git a/samples/UsePolicyBuilder/UsePolicyBuilder.xproj b/samples/UsePolicyBuilder/UsePolicyBuilder.xproj index cf8bbbdeb7..f75668321b 100644 --- a/samples/UsePolicyBuilder/UsePolicyBuilder.xproj +++ b/samples/UsePolicyBuilder/UsePolicyBuilder.xproj @@ -4,16 +4,15 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 6916db8a-0246-45f8-9c64-9b05556c1a5d - UseOptions - ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ 2.0 12497 - + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj b/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj index 7449ce1c4e..197beaeb9e 100644 --- a/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj +++ b/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj @@ -4,17 +4,14 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - + c573aee1-8d54-4a83-8d6b-61c85e8f713e - Microsoft.AspNet.Cors.Core ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - 2.0 - + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj b/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj index 34f1a256e0..19173e3a64 100644 --- a/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj +++ b/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj @@ -4,17 +4,14 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - + 41349fcd-d1c4-47a6-82d0-d16d00a8d59d - Microsoft.AspNet.Cors ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - 2.0 - + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj b/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj index 11bdbb5b21..760025e155 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj +++ b/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj @@ -4,17 +4,14 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - + b4f83a06-eb8e-4186-84c4-c6daf7eb03d4 - Microsoft.AspNet.Cors.Core.Test ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - 2.0 - + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj b/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj index e1e0c40b4c..cb9268f4ad 100644 --- a/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj +++ b/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj @@ -4,17 +4,14 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - + f05be96f-f869-4408-a480-96935b4835ee - Microsoft.AspNet.Cors.Test ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ - 2.0 - + \ No newline at end of file From c96407bea9f64e827d53347450e8fff240b9cbe9 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Fri, 3 Apr 2015 17:07:40 -0700 Subject: [PATCH 024/271] Fix AppVeyor git line ending config --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 88cb9ef145..3fab83e134 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,5 @@ +init: + - git config --global core.autocrlf true build_script: - build.cmd verify clone_depth: 1 From 94bc3760b75b78ffd7b14da331c0710ce7f8ff53 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 7 Apr 2015 14:40:20 -0700 Subject: [PATCH 025/271] Add serviceable attribute to projects. aspnet/DNX#1600 --- src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs | 6 ++++++ src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f5c6f4a83a --- /dev/null +++ b/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Reflection; + +[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..f5c6f4a83a --- /dev/null +++ b/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Reflection; + +[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file From db002867d7b63f10be41edf5cf10a4aaadbe90ca Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 7 Apr 2015 16:14:09 -0700 Subject: [PATCH 026/271] Update .travis.yml and appveyor.yml to build quietly. --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5939a529e5..947bf868ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: csharp sudo: false script: - - ./build.sh verify \ No newline at end of file + - ./build.sh --quiet verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 3fab83e134..636a7618d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ init: - git config --global core.autocrlf true build_script: - - build.cmd verify + - build.cmd --quiet verify clone_depth: 1 test: off deploy: off \ No newline at end of file From 133d8b5e962ea68c292f55f8f7311b533c478671 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 16 Apr 2015 14:51:56 -0700 Subject: [PATCH 027/271] Handle Http.Core rename. --- test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs | 1 - .../DefaultCorsPolicyProviderTests.cs | 2 +- test/Microsoft.AspNet.Cors.Core.Test/project.json | 2 +- test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index 24c20b1b2e..1ff78a3866 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Core; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs index a04297bdb5..3ca194ee6e 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNet.Http.Core; +using Microsoft.AspNet.Http; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/project.json b/test/Microsoft.AspNet.Cors.Core.Test/project.json index 4c01305c27..29cf71cd7f 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Core.Test/project.json @@ -3,7 +3,7 @@ "dependencies": { "Microsoft.AspNet.Cors.Core": "1.0.0-*", - "Microsoft.AspNet.Http.Core": "1.0.0-*", + "Microsoft.AspNet.Http": "1.0.0-*", "Moq": "4.2.1312.1622", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index 10e0cdbd86..27d8694c94 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Core; using Microsoft.AspNet.TestHost; using Microsoft.Framework.DependencyInjection; using Moq; From 4efe031e6efefbd14ff3899935bc530f3e42039b Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 30 Apr 2015 10:14:10 -0700 Subject: [PATCH 028/271] React to interface package renames --- src/Microsoft.AspNet.Cors.Core/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index db6b0673eb..bc1af529a6 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -1,8 +1,8 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.Framework.ConfigurationModel.Interfaces": "1.0.0-*", - "Microsoft.Framework.DependencyInjection.Interfaces": "1.0.0-*", + "Microsoft.Framework.ConfigurationModel.Abstractions: "1.0.0-*", + "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", "Microsoft.Framework.OptionsModel": "1.0.0-*", "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" } From d42838aaebd60f2d26eacb224431d7674d597780 Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 30 Apr 2015 10:19:21 -0700 Subject: [PATCH 029/271] Missing " --- src/Microsoft.AspNet.Cors.Core/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index bc1af529a6..4b35de1489 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -1,7 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.Framework.ConfigurationModel.Abstractions: "1.0.0-*", + "Microsoft.Framework.ConfigurationModel.Abstractions": "1.0.0-*", "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", "Microsoft.Framework.OptionsModel": "1.0.0-*", "Microsoft.AspNet.Http": "1.0.0-*", From 1cadc54c3b3fca71fcabd90965d2dd76ad1ebaf0 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 30 Apr 2015 12:43:49 -0700 Subject: [PATCH 030/271] Use TryAdd to add services rather than Add --- .../CorsServiceCollectionExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index 544b426837..11c1b5261a 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -35,8 +35,8 @@ namespace Microsoft.Framework.DependencyInjection public static IServiceCollection AddCors(this IServiceCollection serviceCollection) { serviceCollection.AddOptions(); - serviceCollection.AddTransient(); - serviceCollection.AddTransient(); + serviceCollection.TryAdd(ServiceDescriptor.Transient()); + serviceCollection.TryAdd(ServiceDescriptor.Transient()); return serviceCollection; } } From ece9a50883160bf5c30f9fb35a3ec79c2c51aa1d Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 1 May 2015 13:45:35 -0700 Subject: [PATCH 031/271] Update LICENSE.txt and license header on files. --- LICENSE.txt | 2 +- src/Microsoft.AspNet.Cors.Core/CorsConstants.cs | 2 +- src/Microsoft.AspNet.Cors.Core/CorsOptions.cs | 2 +- src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs | 2 +- src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs | 2 +- src/Microsoft.AspNet.Cors.Core/CorsResult.cs | 2 +- src/Microsoft.AspNet.Cors.Core/CorsService.cs | 2 +- .../CorsServiceCollectionExtensions.cs | 2 +- src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs | 2 +- src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs | 2 +- src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs | 2 +- src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs | 2 +- src/Microsoft.AspNet.Cors.Core/ICorsService.cs | 2 +- src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs | 2 +- src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs | 2 +- src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs | 2 +- src/Microsoft.AspNet.Cors/CorsMiddleware.cs | 2 +- src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs | 2 +- src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs | 2 +- test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs | 2 +- test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs | 2 +- test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs | 2 +- test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs | 2 +- .../DefaultCorsPolicyProviderTests.cs | 2 +- test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index d85a1524ad..0bdc1962b6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +Copyright (c) .NET Foundation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the diff --git a/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs b/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs index fad7a5b533..e38da324b3 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNet.Cors.Core diff --git a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs index 0a94c70bfb..02c48c5f68 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs b/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs index 9fc7ba9d2b..125b3c030d 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs index b9dd7d9f68..9a5c409f77 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/CorsResult.cs b/src/Microsoft.AspNet.Cors.Core/CorsResult.cs index 024f2b6615..deecf19ada 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsResult.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsResult.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs index 9cab11612c..0e42dcb8b6 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index 11c1b5261a..0577b46a84 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs index 307744e461..08113e31a4 100644 --- a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; diff --git a/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs index 162915e266..dfc07b3f22 100644 --- a/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs index 3e7bf2aa0d..03294db22e 100644 --- a/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs index b837230ff7..bc92954e9f 100644 --- a/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsService.cs b/src/Microsoft.AspNet.Cors.Core/ICorsService.cs index 59216ee576..5259e13493 100644 --- a/src/Microsoft.AspNet.Cors.Core/ICorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/ICorsService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Http; diff --git a/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs index a9e5566baf..ae06fcb216 100644 --- a/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNet.Cors.Core diff --git a/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs b/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs index 7dd0d4a8a4..0531b5b847 100644 --- a/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Microsoft.AspNet.Cors.Core diff --git a/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs index f5c6f4a83a..025a94598c 100644 --- a/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs index 21c079ed99..f817384f36 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs index 88e529dea8..a66484a475 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs index f5c6f4a83a..025a94598c 100644 --- a/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs index 2b6d424137..e0b5e6217d 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs index af257ed411..877dee85b3 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs index ab094a86a3..b465edf57b 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index 1ff78a3866..e20ff19687 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs index 3ca194ee6e..75bb679af8 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index 27d8694c94..bd3b926e5b 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; From 730124063f92e1d41b6f236683bb5035cbcd7c51 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Wed, 6 May 2015 19:15:58 +0300 Subject: [PATCH 032/271] Using [NotNull] --- src/Microsoft.AspNet.Cors.Core/CorsOptions.cs | 6 +----- src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs | 2 +- src/Microsoft.AspNet.Cors.Core/CorsResult.cs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs index 02c48c5f68..b460d65c20 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs @@ -23,13 +23,9 @@ namespace Microsoft.AspNet.Cors.Core return _defaultPolicyName; } + [param: NotNull] set { - if (value == null) - { - throw new ArgumentNullException("value"); - } - _defaultPolicyName = value; } } diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs b/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs index 125b3c030d..b14d52b844 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs @@ -96,7 +96,7 @@ namespace Microsoft.AspNet.Cors.Core { if (value < TimeSpan.Zero) { - throw new ArgumentOutOfRangeException("value", Resources.PreflightMaxAgeOutOfRange); + throw new ArgumentOutOfRangeException(nameof(value), Resources.PreflightMaxAgeOutOfRange); } _preflightMaxAge = value; diff --git a/src/Microsoft.AspNet.Cors.Core/CorsResult.cs b/src/Microsoft.AspNet.Cors.Core/CorsResult.cs index deecf19ada..8b0f39a9cb 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsResult.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsResult.cs @@ -59,7 +59,7 @@ namespace Microsoft.AspNet.Cors.Core { if (value < TimeSpan.Zero) { - throw new ArgumentOutOfRangeException("value", Resources.PreflightMaxAgeOutOfRange); + throw new ArgumentOutOfRangeException(nameof(value), Resources.PreflightMaxAgeOutOfRange); } _preflightMaxAge = value; } From e00f842a45b410766732c223ce876b54348ee110 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 7 May 2015 09:35:31 -0700 Subject: [PATCH 033/271] React to common package name change --- src/Microsoft.AspNet.Cors.Core/project.json | 2 +- src/Microsoft.AspNet.Cors/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index 4b35de1489..046774e265 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -5,7 +5,7 @@ "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", "Microsoft.Framework.OptionsModel": "1.0.0-*", "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" } + "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" } }, "frameworks" : { diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index b2e26d0308..3e36184c3c 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -4,7 +4,7 @@ "Microsoft.AspNet.Cors.Core": "1.0.0-*", "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.AspNet.WebUtilities": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" } + "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" } }, "frameworks" : { From 43d50db495e69e36841e04da3ad735fd07a3fc0c Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 7 May 2015 14:03:31 -0700 Subject: [PATCH 034/271] React to Http namespace changes. --- test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs | 1 + .../DefaultCorsPolicyProviderTests.cs | 2 +- test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index e20ff19687..a66eb2aaba 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -3,6 +3,7 @@ using System; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Internal; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs index 75bb679af8..d3ea65056d 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Internal; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index bd3b926e5b..59e693b996 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.TestHost; using Microsoft.Framework.DependencyInjection; using Moq; From c1e0b2819cc4f487d80d3121597be0575c8837df Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 12 May 2015 11:47:18 -0700 Subject: [PATCH 035/271] Update Home master -> Home dev --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eac4268e4c..64ff041d5c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ Contributing ====== -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. From a38815de58346ee587a37edaf17280d303191679 Mon Sep 17 00:00:00 2001 From: Kirthi Krishnamraju Date: Wed, 20 May 2015 18:37:10 -0700 Subject: [PATCH 036/271] React to aspnet/Configuration #195,#198 --- .../CorsServiceCollectionExtensions.cs | 2 +- src/Microsoft.AspNet.Cors.Core/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index 0577b46a84..7148ad7417 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -4,7 +4,7 @@ using System; using Microsoft.AspNet.Cors; using Microsoft.AspNet.Cors.Core; -using Microsoft.Framework.ConfigurationModel; +using Microsoft.Framework.Configuration; using Microsoft.Framework.Internal; namespace Microsoft.Framework.DependencyInjection diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index 046774e265..4d3b91d4ec 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -1,7 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.Framework.ConfigurationModel.Abstractions": "1.0.0-*", + "Microsoft.Framework.Configuration.Abstractions": "1.0.0-*", "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", "Microsoft.Framework.OptionsModel": "1.0.0-*", "Microsoft.AspNet.Http": "1.0.0-*", From f8065ab693202a4cc19733685bfca884dcfd1e63 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 27 May 2015 16:34:07 -0700 Subject: [PATCH 037/271] Updating to release NuGet.config --- NuGet.Config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..0e74a4912d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,8 @@  - - + + + From 88fa7fb51a97c6e8e89ad464516d1004c8514b21 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 23 Jun 2015 10:52:23 -0700 Subject: [PATCH 038/271] Change hardcoded `bash` shebang to `env` - aspnet/Home#695 - support various `bash` installation locations - in particular, enable building on FreeBSD --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index d81164353c..3ef874f9bd 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild From b1ade8f2cf2e0fec1e878eb251f8e626f2306861 Mon Sep 17 00:00:00 2001 From: Harsh Gupta Date: Tue, 23 Jun 2015 15:57:09 -0700 Subject: [PATCH 039/271] Add single csv values so that there is a single response header added per value. --- src/Microsoft.AspNet.Cors.Core/CorsService.cs | 17 ++++-- .../CorsServiceTests.cs | 58 ++++++++++--------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs index 0e42dcb8b6..3bfac415ff 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -93,8 +93,8 @@ namespace Microsoft.AspNet.Cors.Core return; } - if (!policy.AllowAnyHeader && - requestHeaders != null && + if (!policy.AllowAnyHeader && + requestHeaders != null && !requestHeaders.All(header => policy.Headers.Contains(header, StringComparer.Ordinal))) { return; @@ -137,7 +137,9 @@ namespace Microsoft.AspNet.Cors.Core if (nonSimpleAllowMethods.Length > 0) { - headers.Add(CorsConstants.AccessControlAllowMethods, nonSimpleAllowMethods); + headers.SetCommaSeparatedValues( + CorsConstants.AccessControlAllowMethods, + nonSimpleAllowMethods); } } @@ -151,7 +153,9 @@ namespace Microsoft.AspNet.Cors.Core if (nonSimpleAllowRequestHeaders.Length > 0) { - headers.Add(CorsConstants.AccessControlAllowHeaders, nonSimpleAllowRequestHeaders); + headers.SetCommaSeparatedValues( + CorsConstants.AccessControlAllowHeaders, + nonSimpleAllowRequestHeaders); } } @@ -162,9 +166,12 @@ namespace Microsoft.AspNet.Cors.Core .Where(header => !CorsConstants.SimpleResponseHeaders.Contains(header, StringComparer.OrdinalIgnoreCase)) .ToArray(); + if (nonSimpleAllowResponseHeaders.Length > 0) { - headers.Add(CorsConstants.AccessControlExposeHeaders, nonSimpleAllowResponseHeaders.ToArray()); + headers.SetCommaSeparatedValues( + CorsConstants.AccessControlExposeHeaders, + nonSimpleAllowResponseHeaders); } } diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index a66eb2aaba..3ffb6af9ac 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Act var result = corsService.EvaluatePolicy(requestContext, new CorsPolicy()); - + // Assert Assert.Null(result.AllowedOrigin); Assert.False(result.VaryByOrigin); @@ -303,7 +303,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Act var result = corsService.EvaluatePolicy(requestContext, policy); - + // Assert Assert.Equal(TimeSpan.FromSeconds(10), result.PreflightMaxAge); } @@ -380,7 +380,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Act var result = corsService.EvaluatePolicy(requestContext, policy); - + // Assert Assert.Equal(2, result.AllowedHeaders.Count); Assert.Contains("foo", result.AllowedHeaders); @@ -430,7 +430,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Act var result = corsService.EvaluatePolicy(requestContext, policy); - + // Assert Assert.Empty(result.AllowedHeaders); Assert.Empty(result.AllowedMethods); @@ -447,7 +447,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var policy = new CorsPolicy(); policy.Methods.Add("POST"); var httpContext = GetHttpContext(origin: null, accessControlRequestMethod: "post"); - + // Act var result = corsService.EvaluatePolicy(httpContext, policy); @@ -487,7 +487,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -506,7 +506,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -525,7 +525,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -543,7 +543,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var service = new CorsService(Mock.Of>()); - // Act + // Act var httpContext = new DefaultHttpContext(); service.ApplyResult(result, httpContext.Response); @@ -563,7 +563,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -582,7 +582,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -601,7 +601,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -618,7 +618,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -638,11 +638,13 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert Assert.Contains("Access-Control-Allow-Methods", httpContext.Response.Headers.Keys); + var value = Assert.Single(httpContext.Response.Headers.Values); + Assert.Equal(new[] { "PUT,DELETE" }, value); var methods = httpContext.Response.Headers["Access-Control-Allow-Methods"].Split(','); Assert.Equal(2, methods.Length); Assert.Contains("PUT", methods); @@ -661,7 +663,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -680,7 +682,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -697,7 +699,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -716,11 +718,13 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert Assert.Contains("Access-Control-Allow-Headers", httpContext.Response.Headers.Keys); + var value = Assert.Single(httpContext.Response.Headers.Values); + Assert.Equal(new[] { "foo,bar,baz" }, value); string[] headerValues = httpContext.Response.Headers["Access-Control-Allow-Headers"].Split(','); Assert.Equal(3, headerValues.Length); Assert.Contains("foo", headerValues); @@ -741,7 +745,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -764,7 +768,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -783,7 +787,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -800,7 +804,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -819,11 +823,13 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert Assert.Contains("Access-Control-Expose-Headers", httpContext.Response.Headers.Keys); + var value = Assert.Single(httpContext.Response.Headers.Values); + Assert.Equal(new[] { "foo,bar,baz" }, value); string[] exposedHeaderValues = httpContext.Response.Headers["Access-Control-Expose-Headers"].Split(','); Assert.Equal(3, exposedHeaderValues.Length); Assert.Contains("foo", exposedHeaderValues); @@ -843,7 +849,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert @@ -861,14 +867,14 @@ namespace Microsoft.AspNet.Cors.Core.Test var httpContext = new DefaultHttpContext(); var service = new CorsService(Mock.Of>()); - // Act + // Act service.ApplyResult(result, httpContext.Response); // Assert Assert.Equal("30", httpContext.Response.Headers["Access-Control-Max-Age"]); } - + private static HttpContext GetHttpContext( string method = null, From c53dba25c8f9433e55228679f5528efb20e21777 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 1 Jul 2015 19:30:37 -0700 Subject: [PATCH 040/271] Add repository information to project files --- src/Microsoft.AspNet.Cors.Core/project.json | 4 ++++ src/Microsoft.AspNet.Cors/project.json | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index 4d3b91d4ec..c9551fc701 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -1,5 +1,9 @@ { "version": "1.0.0-*", + "repository": { + "type": "git", + "url": "https://github.com/aspnet/cors" + }, "dependencies": { "Microsoft.Framework.Configuration.Abstractions": "1.0.0-*", "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index 3e36184c3c..60fac13b7d 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -1,5 +1,9 @@ { "version": "1.0.0-*", + "repository": { + "type": "git", + "url": "https://github.com/aspnet/cors" + }, "dependencies": { "Microsoft.AspNet.Cors.Core": "1.0.0-*", "Microsoft.AspNet.Http.Extensions": "1.0.0-*", From cde53ffbd592911f79c452033954480f73267b72 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Jul 2015 09:02:46 -0700 Subject: [PATCH 041/271] Updating to release NuGet.config --- NuGet.Config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..0e74a4912d 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,8 @@  - - + + + From 72a7fb06c2c98266ddacca4d48ffd8428e727f25 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Tue, 4 Aug 2015 10:15:22 -0700 Subject: [PATCH 042/271] Update CoreCLR versions --- src/Microsoft.AspNet.Cors.Core/project.json | 4 ++-- src/Microsoft.AspNet.Cors/project.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index c9551fc701..dbbc14ee5d 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -19,8 +19,8 @@ }, "dnxcore50" : { "dependencies": { - "System.Runtime": "4.0.20-beta-*" + "System.Runtime": "4.0.21-beta-*" } } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index 60fac13b7d..035a2dfb88 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "repository": { "type": "git", @@ -18,7 +18,7 @@ }, "dnxcore50" : { "dependencies": { - "System.Runtime": "4.0.20-beta-*" + "System.Runtime": "4.0.21-beta-*" } } } From 567b6808012212cdb05dc4f596c0a126af057eca Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 11 Aug 2015 14:04:30 -0700 Subject: [PATCH 043/271] Reacting to DI changes --- .../CorsServiceCollectionExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index 7148ad7417..d22dd2c855 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -5,6 +5,7 @@ using System; using Microsoft.AspNet.Cors; using Microsoft.AspNet.Cors.Core; using Microsoft.Framework.Configuration; +using Microsoft.Framework.DependencyInjection.Extensions; using Microsoft.Framework.Internal; namespace Microsoft.Framework.DependencyInjection From fc6c3d52625e1e1e2ce582d5bf192050d8bf745a Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Tue, 11 Aug 2015 16:56:42 -0700 Subject: [PATCH 044/271] Enable pinning build script --- build.cmd | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 41025afb26..ccf195aee8 100644 --- a/build.cmd +++ b/build.cmd @@ -3,6 +3,8 @@ cd %~dp0 SETLOCAL SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe +SET BUILDCMD_KOREBUILD_VERSION="" +SET BUILDCMD_DNX_VERSION="" IF EXIST %CACHED_NUGET% goto copynuget echo Downloading latest version of NuGet.exe... @@ -16,13 +18,21 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore IF EXIST packages\KoreBuild goto run -.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +IF %BUILDCMD_KOREBUILD_VERSION%=="" ( + .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +) ELSE ( + .nuget\NuGet.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre +) .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +IF %BUILDCMD_DNX_VERSION%=="" ( + CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +) ELSE ( + CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -a default +) CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 :run CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* \ No newline at end of file From c9ca9fee4733231c8cdc3e2333b626d0f728c1ee Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 17 Aug 2015 14:49:02 -0700 Subject: [PATCH 045/271] Updating to release NuGet.config. --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..1ce6b9e257 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From 2956633cf3aa415e67816f37ba1c96b707919959 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 18 Aug 2015 14:00:24 -0700 Subject: [PATCH 046/271] Updating to aspnetliterelease. --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 1ce6b9e257..afaa7747c1 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + From a1bf2ecbc02291d88c85d100751bfa4ecc48ca89 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 18 Aug 2015 14:00:24 -0700 Subject: [PATCH 047/271] Updating to aspnetlitedev. --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631d..78fbe8380c 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From e3dcd8218f7675ee01b7dbd0a20680b77fed3afd Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 19 Aug 2015 14:54:41 -0700 Subject: [PATCH 048/271] Update NuGet feed from v2 => v3. --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 78fbe8380c..1697aeadd4 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -2,6 +2,6 @@ - + From 0c36470f8bbe3e6640c7024bc2c931f147f3978e Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 20 Aug 2015 15:38:14 -0700 Subject: [PATCH 049/271] Update 'build.cmd' to pull Sake from v2 NuGet feed. --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index ccf195aee8..b54d91cf74 100644 --- a/build.cmd +++ b/build.cmd @@ -23,7 +23,7 @@ IF %BUILDCMD_KOREBUILD_VERSION%=="" ( ) ELSE ( .nuget\NuGet.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre ) -.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion +.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages IF "%SKIP_DNX_INSTALL%"=="1" goto run IF %BUILDCMD_DNX_VERSION%=="" ( From ad029520d9d4e43c91f051730b062c8d972a13d3 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 20 Aug 2015 20:47:01 -0700 Subject: [PATCH 050/271] Update 'build.sh' to pull Sake from v2 NuGet feed. --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 3ef874f9bd..68c3e8cb52 100755 --- a/build.sh +++ b/build.sh @@ -24,7 +24,7 @@ fi if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion + mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages fi if ! type dnvm > /dev/null 2>&1; then From e84a707160ad88821fa130ccc1eef7c30e0ae13c Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 28 Aug 2015 14:36:58 -0700 Subject: [PATCH 051/271] React to the string[] -> StringValues changes. --- src/Microsoft.AspNet.Cors.Core/CorsService.cs | 31 ++++++++++--------- src/Microsoft.AspNet.Cors.Core/project.json | 6 ++-- src/Microsoft.AspNet.Cors/CorsMiddleware.cs | 7 ++--- src/Microsoft.AspNet.Cors/project.json | 2 -- .../CorsServiceTests.cs | 9 +++--- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs index 3bfac415ff..3be0a1663b 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -3,10 +3,12 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; using Microsoft.Framework.OptionsModel; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Cors.Core { @@ -33,7 +35,7 @@ namespace Microsoft.AspNet.Cors.Core /// /// /// A which contains the result of policy evaluation and can be - /// used by the caller to set apporpriate response headers. + /// used by the caller to set appropriate response headers. public CorsResult EvaluatePolicy([NotNull] HttpContext context, string policyName) { var policy = _options.GetPolicy(policyName); @@ -44,9 +46,9 @@ namespace Microsoft.AspNet.Cors.Core public CorsResult EvaluatePolicy([NotNull] HttpContext context, [NotNull] CorsPolicy policy) { var corsResult = new CorsResult(); - var accessControlRequestMethod = context.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); + var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (string.Equals(context.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.Ordinal) && - accessControlRequestMethod != null) + !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { EvaluatePreflightRequest(context, policy, corsResult); } @@ -60,8 +62,8 @@ namespace Microsoft.AspNet.Cors.Core public virtual void EvaluateRequest(HttpContext context, CorsPolicy policy, CorsResult result) { - var origin = context.Request.Headers.Get(CorsConstants.Origin); - if (origin == null || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + var origin = context.Request.Headers[CorsConstants.Origin]; + if (StringValues.IsNullOrEmpty(origin) || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) { return; } @@ -73,14 +75,14 @@ namespace Microsoft.AspNet.Cors.Core public virtual void EvaluatePreflightRequest(HttpContext context, CorsPolicy policy, CorsResult result) { - var origin = context.Request.Headers.Get(CorsConstants.Origin); - if (origin == null || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + var origin = context.Request.Headers[CorsConstants.Origin]; + if (StringValues.IsNullOrEmpty(origin) || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) { return; } - var accessControlRequestMethod = context.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); - if (accessControlRequestMethod == null) + var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; + if (StringValues.IsNullOrEmpty(accessControlRequestMethod)) { return; } @@ -114,17 +116,17 @@ namespace Microsoft.AspNet.Cors.Core if (result.AllowedOrigin != null) { - headers.Add(CorsConstants.AccessControlAllowOrigin, new[] { result.AllowedOrigin }); + headers[CorsConstants.AccessControlAllowOrigin] = result.AllowedOrigin; } if (result.VaryByOrigin) { - headers.Set("Vary", "Origin"); + headers["Vary"] = "Origin"; } if (result.SupportsCredentials) { - headers.Add(CorsConstants.AccessControlAllowCredentials, new[] { "true" }); + headers[CorsConstants.AccessControlAllowCredentials] = "true"; } if (result.AllowedMethods.Count > 0) @@ -177,9 +179,8 @@ namespace Microsoft.AspNet.Cors.Core if (result.PreflightMaxAge.HasValue) { - headers.Set( - CorsConstants.AccessControlMaxAge, - result.PreflightMaxAge.Value.TotalSeconds.ToString()); + headers[CorsConstants.AccessControlMaxAge] + = result.PreflightMaxAge.Value.TotalSeconds.ToString(CultureInfo.InvariantCulture); } } diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index dbbc14ee5d..48b267a114 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -5,11 +5,11 @@ "url": "https://github.com/aspnet/cors" }, "dependencies": { + "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.Framework.Configuration.Abstractions": "1.0.0-*", "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", - "Microsoft.Framework.OptionsModel": "1.0.0-*", - "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" } + "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }, + "Microsoft.Framework.OptionsModel": "1.0.0-*" }, "frameworks" : { diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs index f817384f36..a0ef8c2ff1 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; -using Microsoft.AspNet.WebUtilities; using Microsoft.Framework.Internal; -using Microsoft.Framework.OptionsModel; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Cors { @@ -70,12 +69,12 @@ namespace Microsoft.AspNet.Cors _corsService.ApplyResult(corsResult, context.Response); var accessControlRequestMethod = - context.Request.Headers.Get(CorsConstants.AccessControlRequestMethod); + context.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (string.Equals( context.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.Ordinal) && - accessControlRequestMethod != null) + !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { // Since there is a policy which was identified, // always respond to preflight requests. diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index 035a2dfb88..9d0567f960 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -6,8 +6,6 @@ }, "dependencies": { "Microsoft.AspNet.Cors.Core": "1.0.0-*", - "Microsoft.AspNet.Http.Extensions": "1.0.0-*", - "Microsoft.AspNet.WebUtilities": "1.0.0-*", "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" } }, diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index 3ffb6af9ac..cd2400db0b 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Linq; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.Framework.OptionsModel; @@ -645,7 +646,7 @@ namespace Microsoft.AspNet.Cors.Core.Test Assert.Contains("Access-Control-Allow-Methods", httpContext.Response.Headers.Keys); var value = Assert.Single(httpContext.Response.Headers.Values); Assert.Equal(new[] { "PUT,DELETE" }, value); - var methods = httpContext.Response.Headers["Access-Control-Allow-Methods"].Split(','); + string[] methods = httpContext.Response.Headers.GetCommaSeparatedValues("Access-Control-Allow-Methods"); Assert.Equal(2, methods.Length); Assert.Contains("PUT", methods); Assert.Contains("DELETE", methods); @@ -725,7 +726,7 @@ namespace Microsoft.AspNet.Cors.Core.Test Assert.Contains("Access-Control-Allow-Headers", httpContext.Response.Headers.Keys); var value = Assert.Single(httpContext.Response.Headers.Values); Assert.Equal(new[] { "foo,bar,baz" }, value); - string[] headerValues = httpContext.Response.Headers["Access-Control-Allow-Headers"].Split(','); + string[] headerValues = httpContext.Response.Headers.GetCommaSeparatedValues("Access-Control-Allow-Headers"); Assert.Equal(3, headerValues.Length); Assert.Contains("foo", headerValues); Assert.Contains("bar", headerValues); @@ -750,7 +751,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Assert Assert.Contains("Access-Control-Allow-Headers", httpContext.Response.Headers.Keys); - string[] headerValues = httpContext.Response.Headers["Access-Control-Allow-Headers"].Split(','); + string[] headerValues = httpContext.Response.Headers.GetCommaSeparatedValues("Access-Control-Allow-Headers"); Assert.Equal(2, headerValues.Length); Assert.Contains("foo", headerValues); Assert.Contains("bar", headerValues); @@ -830,7 +831,7 @@ namespace Microsoft.AspNet.Cors.Core.Test Assert.Contains("Access-Control-Expose-Headers", httpContext.Response.Headers.Keys); var value = Assert.Single(httpContext.Response.Headers.Values); Assert.Equal(new[] { "foo,bar,baz" }, value); - string[] exposedHeaderValues = httpContext.Response.Headers["Access-Control-Expose-Headers"].Split(','); + string[] exposedHeaderValues = httpContext.Response.Headers.GetCommaSeparatedValues("Access-Control-Expose-Headers"); Assert.Equal(3, exposedHeaderValues.Length); Assert.Contains("foo", exposedHeaderValues); Assert.Contains("bar", exposedHeaderValues); From 7a464fd80e706ceb6eef71e35e96323385c014a6 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 10 Aug 2015 16:59:17 -0700 Subject: [PATCH 052/271] React to options --- src/Microsoft.AspNet.Cors.Core/CorsService.cs | 2 +- src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs | 2 +- .../DefaultCorsPolicyProviderTests.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs index 3be0a1663b..bcc09e6cb0 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Cors.Core /// The option model representing . public CorsService([NotNull] IOptions options) { - _options = options.Options; + _options = options.Value; } /// diff --git a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs index 08113e31a4..e5ee17294f 100644 --- a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Cors.Core /// The options configured for the application. public DefaultCorsPolicyProvider(IOptions options) { - _options = options.Options; + _options = options.Value; } /// diff --git a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs index d3ea65056d..b8e3e2deb3 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var mockOptions = new Mock>(); mockOptions - .SetupGet(o => o.Options) + .SetupGet(o => o.Value) .Returns(options); var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); @@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Cors.Core.Test var mockOptions = new Mock>(); mockOptions - .SetupGet(o => o.Options) + .SetupGet(o => o.Value) .Returns(options); var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); From 2c14ac34cac14a92c947786da78aea15f96340ab Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 2 Sep 2015 21:33:47 -0700 Subject: [PATCH 053/271] Fix CORS tests --- test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs | 2 +- test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs index 877dee85b3..f9e290818e 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs @@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Assert Assert.Equal( - "PreflightMaxAge must be greater than or equal to 0.\r\nParameter name: value", + $"PreflightMaxAge must be greater than or equal to 0.{Environment.NewLine}Parameter name: value", exception.Message); } diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs index b465edf57b..fca9916c05 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Assert Assert.Equal( - "PreflightMaxAge must be greater than or equal to 0.\r\nParameter name: value", + $"PreflightMaxAge must be greater than or equal to 0.{Environment.NewLine}Parameter name: value", exception.Message); } From 38728a6bcd11bfe2c5f9c1b17fde1892bf499553 Mon Sep 17 00:00:00 2001 From: Norgerman Date: Tue, 25 Aug 2015 13:53:34 +0800 Subject: [PATCH 054/271] PreflightRequest check requset headers ignore case and ignore simple request headers Signed-off-by: Norgerman --- src/Microsoft.AspNet.Cors.Core/CorsService.cs | 3 ++- test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs index bcc09e6cb0..f9a2d6ea8e 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -97,7 +97,8 @@ namespace Microsoft.AspNet.Cors.Core if (!policy.AllowAnyHeader && requestHeaders != null && - !requestHeaders.All(header => policy.Headers.Contains(header, StringComparer.Ordinal))) + !requestHeaders.All(header => CorsConstants.SimpleRequestHeaders.Contains(header, StringComparer.OrdinalIgnoreCase) || + policy.Headers.Contains(header, StringComparer.OrdinalIgnoreCase))) { return; } diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index cd2400db0b..e32e322b4b 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -397,7 +397,7 @@ namespace Microsoft.AspNet.Cors.Core.Test method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT", - accessControlRequestHeaders: new[] { "Content-Type" }); + accessControlRequestHeaders: new[] { "content-type", "accept" }); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); policy.Methods.Add("*"); @@ -409,8 +409,8 @@ namespace Microsoft.AspNet.Cors.Core.Test var result = corsService.EvaluatePolicy(requestContext, policy); // Assert - Assert.Equal(1, result.AllowedHeaders.Count); - Assert.Contains("Content-Type", result.AllowedHeaders); + Assert.Equal(2, result.AllowedHeaders.Count); + Assert.Contains("Content-Type", result.AllowedHeaders, StringComparer.OrdinalIgnoreCase); } [Fact] From c2b9fc541eeb6c9045fb872379a9bb82511ea51c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 10 Sep 2015 16:39:09 -0700 Subject: [PATCH 055/271] Adding NeutralResourcesLanguageAttribute --- src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs | 4 +++- src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs index 025a94598c..3f4a3b62e0 100644 --- a/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs @@ -2,5 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; +using System.Resources; -[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file +[assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-US")] diff --git a/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs index 025a94598c..3f4a3b62e0 100644 --- a/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs @@ -2,5 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; +using System.Resources; -[assembly: AssemblyMetadata("Serviceable", "True")] \ No newline at end of file +[assembly: AssemblyMetadata("Serviceable", "True")] +[assembly: NeutralResourcesLanguage("en-US")] From dca5829b299c526eb4f6b7c4c077f417f5734745 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sat, 12 Sep 2015 12:39:25 -0700 Subject: [PATCH 056/271] Replacing NotNullAttribute with thrown exceptions --- src/Microsoft.AspNet.Cors.Core/CorsOptions.cs | 40 ++++++++++++++--- .../CorsPolicyBuilder.cs | 8 +++- src/Microsoft.AspNet.Cors.Core/CorsService.cs | 37 +++++++++++++-- .../CorsServiceCollectionExtensions.cs | 17 ++++--- .../DefaultCorsPolicyProvider.cs | 7 ++- .../ICorsPolicyProvider.cs | 3 +- .../ICorsService.cs | 5 +-- src/Microsoft.AspNet.Cors.Core/project.json | 12 +---- src/Microsoft.AspNet.Cors/CorsMiddleware.cs | 45 +++++++++++++++---- .../CorsMiddlewareExtensions.cs | 24 +++++++--- src/Microsoft.AspNet.Cors/project.json | 14 ++---- 11 files changed, 153 insertions(+), 59 deletions(-) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs index b460d65c20..27fe79aee8 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs @@ -3,8 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.AspNet.Cors.Core; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Cors.Core { @@ -22,10 +20,13 @@ namespace Microsoft.AspNet.Cors.Core { return _defaultPolicyName; } - - [param: NotNull] set { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + _defaultPolicyName = value; } } @@ -35,8 +36,18 @@ namespace Microsoft.AspNet.Cors.Core /// /// The name of the policy. /// The policy to be added. - public void AddPolicy([NotNull] string name, [NotNull] CorsPolicy policy) + public void AddPolicy(string name, CorsPolicy policy) { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } + PolicyMap[name] = policy; } @@ -45,8 +56,18 @@ namespace Microsoft.AspNet.Cors.Core /// /// The name of the policy. /// A delegate which can use a policy builder to build a policy. - public void AddPolicy([NotNull] string name, [NotNull] Action configurePolicy) + public void AddPolicy(string name, Action configurePolicy) { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (configurePolicy == null) + { + throw new ArgumentNullException(nameof(configurePolicy)); + } + var policyBuilder = new CorsPolicyBuilder(); configurePolicy(policyBuilder); PolicyMap[name] = policyBuilder.Build(); @@ -57,8 +78,13 @@ namespace Microsoft.AspNet.Cors.Core /// /// The name of the policy to lookup. /// The if the policy was added.null otherwise. - public CorsPolicy GetPolicy([NotNull] string name) + public CorsPolicy GetPolicy(string name) { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + return PolicyMap.ContainsKey(name) ? PolicyMap[name] : null; } } diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs index 9a5c409f77..99c1a0b795 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using Microsoft.AspNet.Cors.Core; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Cors { @@ -171,8 +170,13 @@ namespace Microsoft.AspNet.Cors /// /// The policy which needs to be combined. /// The current policy builder - private CorsPolicyBuilder Combine([NotNull] CorsPolicy policy) + private CorsPolicyBuilder Combine(CorsPolicy policy) { + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } + WithOrigins(policy.Origins.ToArray()); WithHeaders(policy.Headers.ToArray()); WithExposedHeaders(policy.ExposedHeaders.ToArray()); diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs index f9a2d6ea8e..de4a1cd8fc 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using Microsoft.AspNet.Http; -using Microsoft.Framework.Internal; using Microsoft.Framework.OptionsModel; using Microsoft.Framework.Primitives; @@ -23,8 +22,13 @@ namespace Microsoft.AspNet.Cors.Core /// Creates a new instance of the . /// /// The option model representing . - public CorsService([NotNull] IOptions options) + public CorsService(IOptions options) { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + _options = options.Value; } @@ -36,15 +40,30 @@ namespace Microsoft.AspNet.Cors.Core /// /// A which contains the result of policy evaluation and can be /// used by the caller to set appropriate response headers. - public CorsResult EvaluatePolicy([NotNull] HttpContext context, string policyName) + public CorsResult EvaluatePolicy(HttpContext context, string policyName) { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + var policy = _options.GetPolicy(policyName); return EvaluatePolicy(context, policy); } /// - public CorsResult EvaluatePolicy([NotNull] HttpContext context, [NotNull] CorsPolicy policy) + public CorsResult EvaluatePolicy(HttpContext context, CorsPolicy policy) { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } + var corsResult = new CorsResult(); var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (string.Equals(context.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.Ordinal) && @@ -113,6 +132,16 @@ namespace Microsoft.AspNet.Cors.Core /// public virtual void ApplyResult(CorsResult result, HttpResponse response) { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + if (response == null) + { + throw new ArgumentNullException(nameof(response)); + } + var headers = response.Headers; if (result.AllowedOrigin != null) diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index d22dd2c855..e46363ad97 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -2,11 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Cors; using Microsoft.AspNet.Cors.Core; -using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection.Extensions; -using Microsoft.Framework.Internal; namespace Microsoft.Framework.DependencyInjection { @@ -22,9 +19,19 @@ namespace Microsoft.Framework.DependencyInjection /// A delegate which is run to configure the services. /// public static IServiceCollection ConfigureCors( - [NotNull] this IServiceCollection serviceCollection, - [NotNull] Action configure) + this IServiceCollection serviceCollection, + Action configure) { + if (serviceCollection == null) + { + throw new ArgumentNullException(nameof(serviceCollection)); + } + + if (configure == null) + { + throw new ArgumentNullException(nameof(configure)); + } + return serviceCollection.Configure(configure); } diff --git a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs index e5ee17294f..188b8930fe 100644 --- a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs @@ -1,9 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Threading.Tasks; using Microsoft.AspNet.Http; -using Microsoft.Framework.Internal; using Microsoft.Framework.OptionsModel; namespace Microsoft.AspNet.Cors.Core @@ -25,6 +25,11 @@ namespace Microsoft.AspNet.Cors.Core /// public Task GetPolicyAsync(HttpContext context, string policyName) { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + return Task.FromResult(_options.GetPolicy(policyName ?? _options.DefaultPolicyName)); } } diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs index bc92954e9f..fa13aab7e4 100644 --- a/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Cors.Core { @@ -18,6 +17,6 @@ namespace Microsoft.AspNet.Cors.Core /// The associated with this call. /// An optional policy name to look for. /// A - Task GetPolicyAsync([NotNull] HttpContext context, string policyName); + Task GetPolicyAsync(HttpContext context, string policyName); } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsService.cs b/src/Microsoft.AspNet.Cors.Core/ICorsService.cs index 5259e13493..3c94859856 100644 --- a/src/Microsoft.AspNet.Cors.Core/ICorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/ICorsService.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Http; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Cors.Core { @@ -18,7 +17,7 @@ namespace Microsoft.AspNet.Cors.Core /// The which needs to be evaluated. /// A which contains the result of policy evaluation and can be /// used by the caller to set apporpriate response headers. - CorsResult EvaluatePolicy([NotNull] HttpContext context, [NotNull] CorsPolicy policy); + CorsResult EvaluatePolicy(HttpContext context, CorsPolicy policy); /// @@ -26,7 +25,7 @@ namespace Microsoft.AspNet.Cors.Core /// /// The used to read the allowed values. /// The associated with the current call. - void ApplyResult([NotNull] CorsResult result, [NotNull] HttpResponse response); + void ApplyResult(CorsResult result, HttpResponse response); } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index 48b267a114..6962c1be73 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -8,19 +8,11 @@ "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.Framework.Configuration.Abstractions": "1.0.0-*", "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.OptionsModel": "1.0.0-*" }, "frameworks" : { - "dnx451" : { - "dependencies": { - } - }, - "dnxcore50" : { - "dependencies": { - "System.Runtime": "4.0.21-beta-*" - } - } + "dnx451" : { }, + "dnxcore50" : { } } } diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs index a0ef8c2ff1..cccac69fec 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; -using Microsoft.Framework.Internal; using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Cors @@ -30,11 +29,26 @@ namespace Microsoft.AspNet.Cors /// A policy provider which can get an . /// An optional name of the policy to be fetched. public CorsMiddleware( - [NotNull] RequestDelegate next, - [NotNull] ICorsService corsService, - [NotNull] ICorsPolicyProvider policyProvider, + RequestDelegate next, + ICorsService corsService, + ICorsPolicyProvider policyProvider, string policyName) { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + + if (corsService == null) + { + throw new ArgumentNullException(nameof(corsService)); + } + + if (policyProvider == null) + { + throw new ArgumentNullException(nameof(policyProvider)); + } + _next = next; _corsService = corsService; _corsPolicyProvider = policyProvider; @@ -48,10 +62,25 @@ namespace Microsoft.AspNet.Cors /// An instance of . /// An instance of the which can be applied. public CorsMiddleware( - [NotNull] RequestDelegate next, - [NotNull] ICorsService corsService, - [NotNull] CorsPolicy policy) + RequestDelegate next, + ICorsService corsService, + CorsPolicy policy) { + if (next == null) + { + throw new ArgumentNullException(nameof(next)); + } + + if (corsService == null) + { + throw new ArgumentNullException(nameof(corsService)); + } + + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } + _next = next; _corsService = corsService; _policy = policy; @@ -68,7 +97,7 @@ namespace Microsoft.AspNet.Cors var corsResult = _corsService.EvaluatePolicy(context, corsPolicy); _corsService.ApplyResult(corsResult, context.Response); - var accessControlRequestMethod = + var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (string.Equals( context.Request.Method, diff --git a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs index a66484a475..b92a22180e 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs @@ -2,10 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Threading.Tasks; using Microsoft.AspNet.Cors; -using Microsoft.AspNet.Cors.Core; -using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Builder { @@ -20,8 +17,13 @@ namespace Microsoft.AspNet.Builder /// The IApplicationBuilder passed to your Configure method /// The policy name of a configured policy. /// The original app parameter - public static IApplicationBuilder UseCors([NotNull]this IApplicationBuilder app, string policyName) + public static IApplicationBuilder UseCors(this IApplicationBuilder app, string policyName) { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + return app.UseMiddleware(policyName); } @@ -32,9 +34,19 @@ namespace Microsoft.AspNet.Builder /// A delegate which can use a policy builder to build a policy. /// The original app parameter public static IApplicationBuilder UseCors( - [NotNull] this IApplicationBuilder app, - [NotNull] Action configurePolicy) + this IApplicationBuilder app, + Action configurePolicy) { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + if (configurePolicy == null) + { + throw new ArgumentNullException(nameof(configurePolicy)); + } + var policyBuilder = new CorsPolicyBuilder(); configurePolicy(policyBuilder); return app.UseMiddleware(policyBuilder.Build()); diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index 9d0567f960..0a77b75df6 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -5,19 +5,11 @@ "url": "https://github.com/aspnet/cors" }, "dependencies": { - "Microsoft.AspNet.Cors.Core": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" } + "Microsoft.AspNet.Cors.Core": "1.0.0-*" }, "frameworks" : { - "dnx451" : { - "dependencies": { - } - }, - "dnxcore50" : { - "dependencies": { - "System.Runtime": "4.0.21-beta-*" - } - } + "dnx451" : { }, + "dnxcore50" : { } } } From 96c7850e4c17d34b8ea35307e551bbf76c21bd49 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Fri, 11 Sep 2015 10:35:14 -0700 Subject: [PATCH 057/271] [Fixes #33]AddCors should adopt new pattern --- samples/UseOptions/Startup.cs | 4 +- .../CorsServiceCollectionExtensions.cs | 45 +++++++++++-------- .../CorsMiddlewareTests.cs | 11 +++-- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/samples/UseOptions/Startup.cs b/samples/UseOptions/Startup.cs index 5c29d7f67d..732cfbca1e 100644 --- a/samples/UseOptions/Startup.cs +++ b/samples/UseOptions/Startup.cs @@ -9,9 +9,7 @@ namespace UseOptions { public void ConfigureServices(IServiceCollection services) { - services.AddCors(); - services.ConfigureCors( - options => + services.AddCors(options => options.AddPolicy("allowSingleOrigin", builder => builder.WithOrigins("http://example.com"))); } diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index e46363ad97..e4e3eccf6b 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -2,8 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Cors; using Microsoft.AspNet.Cors.Core; +using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection.Extensions; +using Microsoft.Framework.Internal; namespace Microsoft.Framework.DependencyInjection { @@ -13,12 +16,30 @@ namespace Microsoft.Framework.DependencyInjection public static class CorsServiceCollectionExtensions { /// - /// Can be used to configure services in the . + /// Add services needed to support CORS to the given . /// - /// The service collection which needs to be configured. + /// The service collection to which CORS services are added. + /// The updated . + public static IServiceCollection AddCors(this IServiceCollection serviceCollection) + { + if (serviceCollection == null) + { + throw new ArgumentNullException(nameof(serviceCollection)); + } + + serviceCollection.AddOptions(); + serviceCollection.TryAdd(ServiceDescriptor.Transient()); + serviceCollection.TryAdd(ServiceDescriptor.Transient()); + return serviceCollection; + } + + /// + /// Add services needed to support CORS to the given . + /// + /// The service collection to which CORS services are added. /// A delegate which is run to configure the services. - /// - public static IServiceCollection ConfigureCors( + /// The updated . + public static IServiceCollection AddCors( this IServiceCollection serviceCollection, Action configure) { @@ -32,20 +53,8 @@ namespace Microsoft.Framework.DependencyInjection throw new ArgumentNullException(nameof(configure)); } - return serviceCollection.Configure(configure); - } - - /// - /// Add services needed to support CORS to the given . - /// - /// The service collection to which CORS services are added. - /// The updated . - public static IServiceCollection AddCors(this IServiceCollection serviceCollection) - { - serviceCollection.AddOptions(); - serviceCollection.TryAdd(ServiceDescriptor.Transient()); - serviceCollection.TryAdd(ServiceDescriptor.Transient()); - return serviceCollection; + serviceCollection.Configure(configure); + return serviceCollection.AddCors(); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index 59e693b996..a8906b1f49 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Cors.Test // Arrange using (var server = TestServer.Create(app => { - app.UseCors(builder => + app.UseCors(builder => builder.WithOrigins("http://localhost:5001") .WithMethods("PUT") .WithHeaders("Header1") @@ -70,8 +70,7 @@ namespace Microsoft.AspNet.Cors.Test }, services => { - services.AddCors(); - services.ConfigureCors(options => + services.AddCors(options => { options.AddPolicy("customPolicy", policy); }); @@ -129,7 +128,7 @@ namespace Microsoft.AspNet.Cors.Test // Arrange using (var server = TestServer.Create(app => { - app.UseCors(builder => + app.UseCors(builder => builder.WithOrigins("http://localhost:5001") .WithMethods("PUT") .WithHeaders("Header1") @@ -156,7 +155,7 @@ namespace Microsoft.AspNet.Cors.Test [Fact] public async Task Uses_PolicyProvider_AsFallback() { - // Arrange + // Arrange var corsService = Mock.Of(); var mockProvider = new Mock(); mockProvider.Setup(o => o.GetPolicyAsync(It.IsAny(), It.IsAny())) @@ -184,7 +183,7 @@ namespace Microsoft.AspNet.Cors.Test [Fact] public async Task DoesNotSetHeaders_ForNoPolicy() { - // Arrange + // Arrange var corsService = Mock.Of(); var mockProvider = new Mock(); mockProvider.Setup(o => o.GetPolicyAsync(It.IsAny(), It.IsAny())) From d076b019d04fbaa8adc5ffd9b6c72fb0672c61a7 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 17 Sep 2015 18:33:20 -0700 Subject: [PATCH 058/271] Update nuget.exe and corresponding feeds to v3. --- NuGet.Config => NuGet.config | 2 +- build.cmd | 11 ++++++----- build.sh | 12 +++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) rename NuGet.Config => NuGet.config (89%) diff --git a/NuGet.Config b/NuGet.config similarity index 89% rename from NuGet.Config rename to NuGet.config index 1697aeadd4..d6745f70b5 100644 --- a/NuGet.Config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + diff --git a/build.cmd b/build.cmd index b54d91cf74..177997c42e 100644 --- a/build.cmd +++ b/build.cmd @@ -2,14 +2,15 @@ cd %~dp0 SETLOCAL -SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe +SET NUGET_VERSION=latest +SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe SET BUILDCMD_KOREBUILD_VERSION="" SET BUILDCMD_DNX_VERSION="" IF EXIST %CACHED_NUGET% goto copynuget echo Downloading latest version of NuGet.exe... IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet -@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'" +@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" :copynuget IF EXIST .nuget\nuget.exe goto restore @@ -19,11 +20,11 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore IF EXIST packages\KoreBuild goto run IF %BUILDCMD_KOREBUILD_VERSION%=="" ( - .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre ) ELSE ( - .nuget\NuGet.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre ) -.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages +.nuget\nuget.exe install Sake -ExcludeVersion -Out packages IF "%SKIP_DNX_INSTALL%"=="1" goto run IF %BUILDCMD_DNX_VERSION%=="" ( diff --git a/build.sh b/build.sh index 68c3e8cb52..0c66139817 100755 --- a/build.sh +++ b/build.sh @@ -10,21 +10,23 @@ else fi fi mkdir -p $cachedir +nugetVersion=latest +cachePath=$cachedir/nuget.$nugetVersion.exe -url=https://www.nuget.org/nuget.exe +url=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe -if test ! -f $cachedir/nuget.exe; then - wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null +if test ! -f $cachePath; then + wget -O $cachePath $url 2>/dev/null || curl -o $cachePath --location $url /dev/null fi if test ! -e .nuget; then mkdir .nuget - cp $cachedir/nuget.exe .nuget/nuget.exe + cp $cachePath .nuget/nuget.exe fi if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages + mono .nuget/nuget.exe install Sake -ExcludeVersion -Out packages fi if ! type dnvm > /dev/null 2>&1; then From bf66dcea692d114526b2dab6ab528d7f0d06d4f8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 22 Sep 2015 08:45:27 -0700 Subject: [PATCH 059/271] Update CORS package version to 6.0.0 Fixes #24 --- samples/UseOptions/project.json | 2 +- samples/UsePolicyBuilder/project.json | 2 +- src/Microsoft.AspNet.Cors.Core/project.json | 5 ++++- src/Microsoft.AspNet.Cors/project.json | 7 +++++-- test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs | 1 - test/Microsoft.AspNet.Cors.Core.Test/project.json | 7 ++----- test/Microsoft.AspNet.Cors.Test/project.json | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/samples/UseOptions/project.json b/samples/UseOptions/project.json index cef1621e00..7d68c72128 100644 --- a/samples/UseOptions/project.json +++ b/samples/UseOptions/project.json @@ -2,7 +2,7 @@ "webroot": "wwwroot", "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Cors": "1.0.0-*", + "Microsoft.AspNet.Cors": "6.0.0-*", "Microsoft.AspNet.Diagnostics": "1.0.0-*", "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", diff --git a/samples/UsePolicyBuilder/project.json b/samples/UsePolicyBuilder/project.json index cef1621e00..7d68c72128 100644 --- a/samples/UsePolicyBuilder/project.json +++ b/samples/UsePolicyBuilder/project.json @@ -2,7 +2,7 @@ "webroot": "wwwroot", "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Cors": "1.0.0-*", + "Microsoft.AspNet.Cors": "6.0.0-*", "Microsoft.AspNet.Diagnostics": "1.0.0-*", "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index 6962c1be73..239620ae72 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -1,9 +1,12 @@ { - "version": "1.0.0-*", + "version": "6.0.0-*", "repository": { "type": "git", "url": "https://github.com/aspnet/cors" }, + "compilationOptions": { + "warningsAsErrors": true + }, "dependencies": { "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.Framework.Configuration.Abstractions": "1.0.0-*", diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index 0a77b75df6..c0e28d8f10 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -1,11 +1,14 @@ { - "version": "1.0.0-*", + "version": "6.0.0-*", "repository": { "type": "git", "url": "https://github.com/aspnet/cors" }, + "compilationOptions": { + "warningsAsErrors": true + }, "dependencies": { - "Microsoft.AspNet.Cors.Core": "1.0.0-*" + "Microsoft.AspNet.Cors.Core": "6.0.0-*" }, "frameworks" : { diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index e32e322b4b..ab3f790ac6 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.Framework.OptionsModel; diff --git a/test/Microsoft.AspNet.Cors.Core.Test/project.json b/test/Microsoft.AspNet.Cors.Core.Test/project.json index 29cf71cd7f..7eb54ebb50 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Core.Test/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Cors.Core": "1.0.0-*", + "Microsoft.AspNet.Cors.Core": "6.0.0-*", "Microsoft.AspNet.Http": "1.0.0-*", "Moq": "4.2.1312.1622", "xunit.runner.aspnet": "2.0.0-aspnet-*" @@ -13,9 +13,6 @@ }, "frameworks" : { - "dnx451" : { - "dependencies": { - } - } + "dnx451" : { } } } diff --git a/test/Microsoft.AspNet.Cors.Test/project.json b/test/Microsoft.AspNet.Cors.Test/project.json index a75b306308..270d1860d3 100644 --- a/test/Microsoft.AspNet.Cors.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Test/project.json @@ -1,7 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Cors": "1.0.0-*", + "Microsoft.AspNet.Cors": "6.0.0-*", "Microsoft.AspNet.TestHost": "1.0.0-*", "Moq": "4.2.1312.1622", "xunit.runner.aspnet": "2.0.0-aspnet-*" From bfcb7619dd53bd66658e5f85cf0b7c94092d8cb7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 22 Sep 2015 08:59:23 -0700 Subject: [PATCH 060/271] Run Cors.Core.Tests in dnxcore50 --- .../CorsServiceTests.cs | 90 +++++++++---------- .../DefaultCorsPolicyProviderTests.cs | 22 +++-- .../TestCorsOptions.cs | 12 +++ .../project.json | 5 +- 4 files changed, 68 insertions(+), 61 deletions(-) create mode 100644 test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs index ab3f790ac6..98c0af90b6 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs @@ -4,8 +4,6 @@ using System; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; -using Microsoft.Framework.OptionsModel; -using Moq; using Xunit; namespace Microsoft.AspNet.Cors.Core.Test @@ -16,7 +14,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_NoOrigin_ReturnsInvalidResult() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext("GET", origin: null); // Act @@ -31,7 +29,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_NoMatchingOrigin_ReturnsInvalidResult() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy(); policy.Origins.Add("bar"); @@ -48,7 +46,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_EmptyOriginsPolicy_ReturnsInvalidResult() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy(); @@ -64,7 +62,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_AllowAnyOrigin_DoesNotSupportCredentials_EmitsWildcardForOrigin() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy @@ -85,7 +83,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_AllowAnyOrigin_SupportsCredentials_AddsSpecificOrigin() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy { @@ -105,7 +103,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_DoesNotSupportCredentials_AllowCredentialsReturnsFalse() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy { @@ -124,7 +122,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_SupportsCredentials_AllowCredentialsReturnsTrue() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy { @@ -143,7 +141,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_NoExposedHeaders_NoAllowExposedHeaders() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -159,7 +157,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_OneExposedHeaders_HeadersAllowed() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -177,7 +175,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_ManyExposedHeaders_HeadersAllowed() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -199,7 +197,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_MethodNotAllowed_ReturnsInvalidResult() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -216,7 +214,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_MethodAllowed_ReturnsAllowMethods() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -234,7 +232,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_OriginAllowed_ReturnsOrigin() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -252,7 +250,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_SupportsCredentials_AllowCredentialsReturnsTrue() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy { @@ -272,7 +270,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_NoPreflightMaxAge_NoPreflightMaxAgeSet() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy { @@ -292,7 +290,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_PreflightMaxAge_PreflightMaxAgeSet() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy { @@ -312,7 +310,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_AnyMethod_ReturnsRequestMethod() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "GET"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -330,7 +328,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_ListedMethod_ReturnsSubsetOfListedMethods() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -349,7 +347,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_NoHeadersRequested_AllowedAllHeaders_ReturnsEmptyHeaders() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); @@ -367,7 +365,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_HeadersRequested_AllowAllHeaders_ReturnsRequestedHeaders() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext( method: "OPTIONS", origin: "http://example.com", @@ -391,7 +389,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_HeadersRequested_AllowSomeHeaders_ReturnsSubsetOfListedHeaders() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext( method: "OPTIONS", origin: "http://example.com", @@ -416,7 +414,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EvaluatePolicy_PreflightRequest_HeadersRequested_NotAllHeaderMatches_ReturnsInvalidResult() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var requestContext = GetHttpContext( method: "OPTIONS", origin: "http://example.com", @@ -442,7 +440,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void EaluatePolicy_DoesCaseSensitiveComparison() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var policy = new CorsPolicy(); policy.Methods.Add("POST"); @@ -462,7 +460,7 @@ namespace Microsoft.AspNet.Cors.Core.Test public void TryValidateOrigin_DoesCaseSensitiveComparison() { // Arrange - var corsService = new CorsService(Mock.Of>()); + var corsService = new CorsService(new TestCorsOptions()); var policy = new CorsPolicy(); policy.Origins.Add("http://Example.com"); @@ -485,7 +483,7 @@ namespace Microsoft.AspNet.Cors.Core.Test // Arrange var result = new CorsResult(); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -504,7 +502,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -523,7 +521,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -541,7 +539,7 @@ namespace Microsoft.AspNet.Cors.Core.Test SupportsCredentials = true }; - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act var httpContext = new DefaultHttpContext(); @@ -561,7 +559,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -580,7 +578,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -599,7 +597,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -616,7 +614,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedMethods.Add("PUT"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -636,7 +634,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedMethods.Add("POST"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -661,7 +659,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedMethods.Add("POST"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -680,7 +678,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -697,7 +695,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedHeaders.Add("foo"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -716,7 +714,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedHeaders.Add("baz"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -743,7 +741,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedHeaders.Add("Accept"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -766,7 +764,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedHeaders.Add("Content-Language"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -785,7 +783,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -802,7 +800,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedExposedHeaders.Add("foo"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -821,7 +819,7 @@ namespace Microsoft.AspNet.Cors.Core.Test result.AllowedExposedHeaders.Add("baz"); var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -847,7 +845,7 @@ namespace Microsoft.AspNet.Cors.Core.Test }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); @@ -865,7 +863,7 @@ namespace Microsoft.AspNet.Cors.Core.Test PreflightMaxAge = TimeSpan.FromSeconds(30) }; var httpContext = new DefaultHttpContext(); - var service = new CorsService(Mock.Of>()); + var service = new CorsService(new TestCorsOptions()); // Act service.ApplyResult(result, httpContext.Response); diff --git a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs index b8e3e2deb3..0ff2f0b0ef 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http.Internal; -using Microsoft.Framework.OptionsModel; -using Moq; using Xunit; namespace Microsoft.AspNet.Cors.Core.Test @@ -19,11 +17,11 @@ namespace Microsoft.AspNet.Cors.Core.Test var policy = new CorsPolicy(); options.AddPolicy(options.DefaultPolicyName, policy); - var mockOptions = new Mock>(); - mockOptions - .SetupGet(o => o.Value) - .Returns(options); - var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); + var corsOptions = new TestCorsOptions + { + Value = options + }; + var policyProvider = new DefaultCorsPolicyProvider(corsOptions); // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName: null); @@ -42,11 +40,11 @@ namespace Microsoft.AspNet.Cors.Core.Test var policy = new CorsPolicy(); options.AddPolicy(policyName, policy); - var mockOptions = new Mock>(); - mockOptions - .SetupGet(o => o.Value) - .Returns(options); - var policyProvider = new DefaultCorsPolicyProvider(mockOptions.Object); + var corsOptions = new TestCorsOptions + { + Value = options + }; + var policyProvider = new DefaultCorsPolicyProvider(corsOptions); // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName); diff --git a/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs b/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs new file mode 100644 index 0000000000..5bce510449 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.OptionsModel; + +namespace Microsoft.AspNet.Cors.Core.Test +{ + public class TestCorsOptions : IOptions + { + public CorsOptions Value { get; set; } + } +} diff --git a/test/Microsoft.AspNet.Cors.Core.Test/project.json b/test/Microsoft.AspNet.Cors.Core.Test/project.json index 7eb54ebb50..8d78c46151 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Core.Test/project.json @@ -4,15 +4,14 @@ "dependencies": { "Microsoft.AspNet.Cors.Core": "6.0.0-*", "Microsoft.AspNet.Http": "1.0.0-*", - "Moq": "4.2.1312.1622", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, - "commands": { "test": "xunit.runner.aspnet" }, "frameworks" : { - "dnx451" : { } + "dnx451": { }, + "dnxcore50": { } } } From 976f58925dbfc794dd7244520af09fb9c4d32ffd Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Tue, 22 Sep 2015 15:51:21 -0700 Subject: [PATCH 061/271] Enabling NuGetPackageVerifier --- NuGetPackageVerifier.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 NuGetPackageVerifier.json diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json new file mode 100644 index 0000000000..c9492f583d --- /dev/null +++ b/NuGetPackageVerifier.json @@ -0,0 +1,26 @@ +{ + "adx": { // Packages written by the ADX team and that ship on NuGet.org + "rules": [ + "AssemblyHasDocumentFileRule", + "AssemblyHasVersionAttributesRule", + "AssemblyHasServicingAttributeRule", + "AssemblyHasNeutralResourcesLanguageAttributeRule", + "SatellitePackageRule", + "StrictSemanticVersionValidationRule" + ], + "packages": { + "Microsoft.AspNet.Cors": { }, + "Microsoft.AspNet.Cors.Core": { } + } + }, + "Default": { // Rules to run for packages not listed in any other set. + "rules": [ + "AssemblyHasDocumentFileRule", + "AssemblyHasVersionAttributesRule", + "AssemblyHasServicingAttributeRule", + "AssemblyHasNeutralResourcesLanguageAttributeRule", + "SatellitePackageRule", + "StrictSemanticVersionValidationRule" + ] + } +} \ No newline at end of file From 7548eed53076748c61fb2e53cccd9b1e2e1b4d04 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 28 Sep 2015 23:15:48 -0700 Subject: [PATCH 062/271] Updating to release NuGet.config. --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index d6745f70b5..2344257191 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + From a14adf4d30d05f3828e41ffda3c1777061f49887 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 1 Oct 2015 11:58:33 -0700 Subject: [PATCH 063/271] Update 'build.cmd' alias parameter to use full name. --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index 177997c42e..70d974a61f 100644 --- a/build.cmd +++ b/build.cmd @@ -30,7 +30,7 @@ IF "%SKIP_DNX_INSTALL%"=="1" goto run IF %BUILDCMD_DNX_VERSION%=="" ( CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 ) ELSE ( - CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -a default + CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -alias default ) CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 From 5ce58c790f38e64f57907a8c6ea767b62b8a3810 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sat, 3 Oct 2015 15:44:47 -0700 Subject: [PATCH 064/271] Renaming Microsoft.Framework.* -> Microsoft.Extensions.* --- samples/UseOptions/Startup.cs | 4 ++-- samples/UseOptions/project.json | 4 ++-- samples/UsePolicyBuilder/Startup.cs | 4 ++-- samples/UsePolicyBuilder/project.json | 4 ++-- src/Microsoft.AspNet.Cors.Core/CorsService.cs | 4 ++-- .../CorsServiceCollectionExtensions.cs | 8 ++++---- .../DefaultCorsPolicyProvider.cs | 2 +- src/Microsoft.AspNet.Cors.Core/project.json | 6 +++--- src/Microsoft.AspNet.Cors/CorsMiddleware.cs | 2 +- test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs | 4 ++-- test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/samples/UseOptions/Startup.cs b/samples/UseOptions/Startup.cs index 732cfbca1e..c2e8299fc0 100644 --- a/samples/UseOptions/Startup.cs +++ b/samples/UseOptions/Startup.cs @@ -1,7 +1,7 @@ -using System; +using System; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; -using Microsoft.Framework.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; namespace UseOptions { diff --git a/samples/UseOptions/project.json b/samples/UseOptions/project.json index 7d68c72128..2733f72e2f 100644 --- a/samples/UseOptions/project.json +++ b/samples/UseOptions/project.json @@ -1,4 +1,4 @@ -{ +{ "webroot": "wwwroot", "version": "1.0.0-*", "dependencies": { @@ -6,7 +6,7 @@ "Microsoft.AspNet.Diagnostics": "1.0.0-*", "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.Framework.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" diff --git a/samples/UsePolicyBuilder/Startup.cs b/samples/UsePolicyBuilder/Startup.cs index de8233cfbb..bbc269f970 100644 --- a/samples/UsePolicyBuilder/Startup.cs +++ b/samples/UsePolicyBuilder/Startup.cs @@ -1,8 +1,8 @@ -using System; +using System; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; -using Microsoft.Framework.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; namespace UsePolicy { diff --git a/samples/UsePolicyBuilder/project.json b/samples/UsePolicyBuilder/project.json index 7d68c72128..2733f72e2f 100644 --- a/samples/UsePolicyBuilder/project.json +++ b/samples/UsePolicyBuilder/project.json @@ -1,4 +1,4 @@ -{ +{ "webroot": "wwwroot", "version": "1.0.0-*", "dependencies": { @@ -6,7 +6,7 @@ "Microsoft.AspNet.Diagnostics": "1.0.0-*", "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.Framework.Logging.Console": "1.0.0-*" + "Microsoft.Extensions.Logging.Console": "1.0.0-*" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors.Core/CorsService.cs index de4a1cd8fc..f4d06c9395 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsService.cs @@ -6,8 +6,8 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using Microsoft.AspNet.Http; -using Microsoft.Framework.OptionsModel; -using Microsoft.Framework.Primitives; +using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Primitives; namespace Microsoft.AspNet.Cors.Core { diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs index e4e3eccf6b..ed4544b91e 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs @@ -4,11 +4,11 @@ using System; using Microsoft.AspNet.Cors; using Microsoft.AspNet.Cors.Core; -using Microsoft.Framework.Configuration; -using Microsoft.Framework.DependencyInjection.Extensions; -using Microsoft.Framework.Internal; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Internal; -namespace Microsoft.Framework.DependencyInjection +namespace Microsoft.Extensions.DependencyInjection { /// /// The extensions for enabling CORS support. diff --git a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs index 188b8930fe..01f4574a8b 100644 --- a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Http; -using Microsoft.Framework.OptionsModel; +using Microsoft.Extensions.OptionsModel; namespace Microsoft.AspNet.Cors.Core { diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json index 239620ae72..bf2c81b3d2 100644 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ b/src/Microsoft.AspNet.Cors.Core/project.json @@ -9,9 +9,9 @@ }, "dependencies": { "Microsoft.AspNet.Http.Extensions": "1.0.0-*", - "Microsoft.Framework.Configuration.Abstractions": "1.0.0-*", - "Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-*", - "Microsoft.Framework.OptionsModel": "1.0.0-*" + "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", + "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", + "Microsoft.Extensions.OptionsModel": "1.0.0-*" }, "frameworks" : { diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs index cccac69fec..1ab7bc2917 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; -using Microsoft.Framework.Primitives; +using Microsoft.Extensions.Primitives; namespace Microsoft.AspNet.Cors { diff --git a/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs b/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs index 5bce510449..fa8e0059a5 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs +++ b/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs @@ -1,7 +1,7 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.OptionsModel; +using Microsoft.Extensions.OptionsModel; namespace Microsoft.AspNet.Cors.Core.Test { diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index a8906b1f49..ba3759a5a7 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -9,7 +9,7 @@ using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.TestHost; -using Microsoft.Framework.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Moq; using Xunit; From f643d9b1910d07e9c3b7e546d2e23b80c562a021 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 8 Oct 2015 19:00:35 -0700 Subject: [PATCH 065/271] React to aspnet/Universe#290 fix --- build.cmd | 25 +++++++++++++------------ build.sh | 12 +++++++----- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/build.cmd b/build.cmd index 70d974a61f..84dc87e480 100644 --- a/build.cmd +++ b/build.cmd @@ -18,22 +18,23 @@ md .nuget copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore -IF EXIST packages\KoreBuild goto run +IF EXIST packages\Sake goto getdnx IF %BUILDCMD_KOREBUILD_VERSION%=="" ( - .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre ) ELSE ( - .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre + .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre ) -.nuget\nuget.exe install Sake -ExcludeVersion -Out packages +.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages -IF "%SKIP_DNX_INSTALL%"=="1" goto run -IF %BUILDCMD_DNX_VERSION%=="" ( - CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +:getdnx +IF "%SKIP_DNX_INSTALL%"=="" ( + IF "%BUILDCMD_DNX_VERSION%"=="" ( + BUILDCMD_DNX_VERSION=latest + ) + CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default + CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default ) ELSE ( - CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CLR -arch x86 -alias default + CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 ) -CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 -:run -CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* \ No newline at end of file +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index 0c66139817..da4e3fcd1c 100755 --- a/build.sh +++ b/build.sh @@ -24,18 +24,20 @@ if test ! -e .nuget; then cp $cachePath .nuget/nuget.exe fi -if test ! -d packages/KoreBuild; then +if test ! -d packages/Sake; then mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -ExcludeVersion -Out packages + mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages fi if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi -if ! type dnx > /dev/null 2>&1; then - dnvm upgrade +if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then + dnvm install latest -runtime coreclr -alias default + dnvm install default -runtime mono -alias default +else + dnvm use default -runtime mono fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" - From eef2d5e94f4d5f23892df040e18a8aa8bcae69b8 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Mon, 12 Oct 2015 12:50:17 -0700 Subject: [PATCH 066/271] Fix local build break --- build.cmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index 84dc87e480..553e3929a0 100644 --- a/build.cmd +++ b/build.cmd @@ -4,8 +4,8 @@ cd %~dp0 SETLOCAL SET NUGET_VERSION=latest SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe -SET BUILDCMD_KOREBUILD_VERSION="" -SET BUILDCMD_DNX_VERSION="" +SET BUILDCMD_KOREBUILD_VERSION= +SET BUILDCMD_DNX_VERSION= IF EXIST %CACHED_NUGET% goto copynuget echo Downloading latest version of NuGet.exe... @@ -19,7 +19,7 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul :restore IF EXIST packages\Sake goto getdnx -IF %BUILDCMD_KOREBUILD_VERSION%=="" ( +IF "%BUILDCMD_KOREBUILD_VERSION%"=="" ( .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre ) ELSE ( .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre @@ -27,10 +27,10 @@ IF %BUILDCMD_KOREBUILD_VERSION%=="" ( .nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages :getdnx +IF "%BUILDCMD_DNX_VERSION%"=="" ( + SET BUILDCMD_DNX_VERSION=latest +) IF "%SKIP_DNX_INSTALL%"=="" ( - IF "%BUILDCMD_DNX_VERSION%"=="" ( - BUILDCMD_DNX_VERSION=latest - ) CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default ) ELSE ( From 475771250bf4f6b8b03ee1c7d30c9f4e4b4816e8 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 8 Oct 2015 11:51:12 -0700 Subject: [PATCH 067/271] [Fixes #41] Api review changes --- CORS.sln | 16 +---- NuGetPackageVerifier.json | 3 +- samples/UsePolicyBuilder/Startup.cs | 1 - .../Microsoft.AspNet.Cors.Core.xproj | 17 ----- .../Properties/AssemblyInfo.cs | 8 --- .../Properties/Resources.Designer.cs | 46 ------------ src/Microsoft.AspNet.Cors.Core/project.json | 21 ------ .../CorsConstants.cs | 2 +- src/Microsoft.AspNet.Cors/CorsMiddleware.cs | 3 +- .../CorsMiddlewareExtensions.cs | 2 +- .../CorsOptions.cs | 2 +- .../CorsPolicy.cs | 5 +- .../CorsPolicyBuilder.cs | 3 +- .../CorsResult.cs | 4 +- .../CorsService.cs | 2 +- .../CorsServiceCollectionExtensions.cs | 5 +- .../DefaultCorsPolicyProvider.cs | 2 +- .../DisableCorsAttribute.cs | 3 +- .../EnableCorsAttribute.cs | 3 +- .../ICorsPolicyProvider.cs | 2 +- .../ICorsService.cs | 4 +- .../IDisableCorsAttribute.cs | 2 +- .../IEnableCorsAttribute.cs | 2 +- .../Resources.Designer.cs | 71 +++++++++++++++++++ .../Resources.resx | 0 src/Microsoft.AspNet.Cors/project.json | 11 +-- .../Microsoft.AspNet.Cors.Core.Test.xproj | 17 ----- .../project.json | 17 ----- .../CorsMiddlewareTests.cs | 3 +- .../CorsPolicyBuilderTests.cs | 2 +- .../CorsPolicyTests.cs | 2 +- .../CorsResultTests.cs | 4 +- .../CorsServiceTests.cs | 2 +- .../DefaultCorsPolicyProviderTests.cs | 2 +- .../TestCorsOptions.cs | 2 +- 35 files changed, 108 insertions(+), 183 deletions(-) delete mode 100644 src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj delete mode 100644 src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs delete mode 100644 src/Microsoft.AspNet.Cors.Core/project.json rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/CorsConstants.cs (98%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/CorsOptions.cs (98%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/CorsPolicy.cs (97%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/CorsPolicyBuilder.cs (98%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/CorsResult.cs (97%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/CorsService.cs (99%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/CorsServiceCollectionExtensions.cs (94%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/DefaultCorsPolicyProvider.cs (95%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/DisableCorsAttribute.cs (84%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/EnableCorsAttribute.cs (91%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/ICorsPolicyProvider.cs (94%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/ICorsService.cs (92%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/IDisableCorsAttribute.cs (88%) rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/IEnableCorsAttribute.cs (91%) create mode 100644 src/Microsoft.AspNet.Cors/Resources.Designer.cs rename src/{Microsoft.AspNet.Cors.Core => Microsoft.AspNet.Cors}/Resources.resx (100%) delete mode 100644 test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj delete mode 100644 test/Microsoft.AspNet.Cors.Core.Test/project.json rename test/{Microsoft.AspNet.Cors.Core.Test => Microsoft.AspNet.Cors.Test}/CorsPolicyBuilderTests.cs (99%) rename test/{Microsoft.AspNet.Cors.Core.Test => Microsoft.AspNet.Cors.Test}/CorsPolicyTests.cs (98%) rename test/{Microsoft.AspNet.Cors.Core.Test => Microsoft.AspNet.Cors.Test}/CorsResultTests.cs (96%) rename test/{Microsoft.AspNet.Cors.Core.Test => Microsoft.AspNet.Cors.Test}/CorsServiceTests.cs (99%) rename test/{Microsoft.AspNet.Cors.Core.Test => Microsoft.AspNet.Cors.Test}/DefaultCorsPolicyProviderTests.cs (97%) rename test/{Microsoft.AspNet.Cors.Core.Test => Microsoft.AspNet.Cors.Test}/TestCorsOptions.cs (87%) diff --git a/CORS.sln b/CORS.sln index f3d81e9fcd..7af505a971 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22711.0 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" EndProject @@ -10,12 +10,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution global.json = global.json EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core", "src\Microsoft.AspNet.Cors.Core\Microsoft.AspNet.Cors.Core.xproj", "{C573AEE1-8D54-4A83-8D6B-61C85E8F713E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F32074C7-087C-46CC-A913-422BFD2D6E0A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Core.Test", "test\Microsoft.AspNet.Cors.Core.Test\Microsoft.AspNet.Cors.Core.Test.xproj", "{B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors", "src\Microsoft.AspNet.Cors\Microsoft.AspNet.Cors.xproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Test", "test\Microsoft.AspNet.Cors.Test\Microsoft.AspNet.Cors.Test.xproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" @@ -32,14 +28,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C573AEE1-8D54-4A83-8D6B-61C85E8F713E}.Release|Any CPU.Build.0 = Release|Any CPU - {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4}.Release|Any CPU.Build.0 = Release|Any CPU {41349FCD-D1C4-47A6-82D0-D16D00A8D59D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {41349FCD-D1C4-47A6-82D0-D16D00A8D59D}.Debug|Any CPU.Build.0 = Debug|Any CPU {41349FCD-D1C4-47A6-82D0-D16D00A8D59D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -61,8 +49,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {C573AEE1-8D54-4A83-8D6B-61C85E8F713E} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} - {B4F83A06-EB8E-4186-84C4-C6DAF7EB03D4} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} {41349FCD-D1C4-47A6-82D0-D16D00A8D59D} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} {F05BE96F-F869-4408-A480-96935B4835EE} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} {8DC90D0F-9660-42AD-BE08-4A7643A8F46E} = {EEF80A8E-F334-4C66-9537-8D24D002149D} diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index c9492f583d..86ea14ef19 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -9,8 +9,7 @@ "StrictSemanticVersionValidationRule" ], "packages": { - "Microsoft.AspNet.Cors": { }, - "Microsoft.AspNet.Cors.Core": { } + "Microsoft.AspNet.Cors": { } } }, "Default": { // Rules to run for packages not listed in any other set. diff --git a/samples/UsePolicyBuilder/Startup.cs b/samples/UsePolicyBuilder/Startup.cs index bbc269f970..539f9a808e 100644 --- a/samples/UsePolicyBuilder/Startup.cs +++ b/samples/UsePolicyBuilder/Startup.cs @@ -1,6 +1,5 @@ using System; using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; diff --git a/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj b/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj deleted file mode 100644 index 197beaeb9e..0000000000 --- a/src/Microsoft.AspNet.Cors.Core/Microsoft.AspNet.Cors.Core.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - c573aee1-8d54-4a83-8d6b-61c85e8f713e - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs deleted file mode 100644 index 3f4a3b62e0..0000000000 --- a/src/Microsoft.AspNet.Cors.Core/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-US")] diff --git a/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs deleted file mode 100644 index 8b6e085a94..0000000000 --- a/src/Microsoft.AspNet.Cors.Core/Properties/Resources.Designer.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -namespace Microsoft.AspNet.Cors.Core -{ - using System.Globalization; - using System.Reflection; - using System.Resources; - - internal static class Resources - { - private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Cors.Core.Resources", typeof(Resources).GetTypeInfo().Assembly); - - /// - /// PreflightMaxAge must be greater than or equal to 0. - /// - internal static string PreflightMaxAgeOutOfRange - { - get { return GetString("PreflightMaxAgeOutOfRange"); } - } - - /// - /// PreflightMaxAge must be greater than or equal to 0. - /// - internal static string FormatPreflightMaxAgeOutOfRange() - { - return GetString("PreflightMaxAgeOutOfRange"); - } - - private static string GetString(string name, params string[] formatterNames) - { - var value = _resourceManager.GetString(name); - - System.Diagnostics.Debug.Assert(value != null); - - if (formatterNames != null) - { - for (var i = 0; i < formatterNames.Length; i++) - { - value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); - } - } - - return value; - } - } -} diff --git a/src/Microsoft.AspNet.Cors.Core/project.json b/src/Microsoft.AspNet.Cors.Core/project.json deleted file mode 100644 index bf2c81b3d2..0000000000 --- a/src/Microsoft.AspNet.Cors.Core/project.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": "6.0.0-*", - "repository": { - "type": "git", - "url": "https://github.com/aspnet/cors" - }, - "compilationOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "Microsoft.AspNet.Http.Extensions": "1.0.0-*", - "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", - "Microsoft.Extensions.OptionsModel": "1.0.0-*" - }, - - "frameworks" : { - "dnx451" : { }, - "dnxcore50" : { } - } -} diff --git a/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs b/src/Microsoft.AspNet.Cors/CorsConstants.cs similarity index 98% rename from src/Microsoft.AspNet.Cors.Core/CorsConstants.cs rename to src/Microsoft.AspNet.Cors/CorsConstants.cs index e38da324b3..b777a80e6a 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsConstants.cs +++ b/src/Microsoft.AspNet.Cors/CorsConstants.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// CORS-related constants. diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs index 1ab7bc2917..7779eb2291 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs @@ -4,11 +4,10 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; using Microsoft.Extensions.Primitives; -namespace Microsoft.AspNet.Cors +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// An ASP.NET middleware for handling CORS. diff --git a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs index b92a22180e..d3acfa0065 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Cors; +using Microsoft.AspNet.Cors.Infrastructure; namespace Microsoft.AspNet.Builder { diff --git a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs b/src/Microsoft.AspNet.Cors/CorsOptions.cs similarity index 98% rename from src/Microsoft.AspNet.Cors.Core/CorsOptions.cs rename to src/Microsoft.AspNet.Cors/CorsOptions.cs index 27fe79aee8..bab1c2e68d 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsOptions.cs +++ b/src/Microsoft.AspNet.Cors/CorsOptions.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// Provides programmatic configuration for Cors. diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs b/src/Microsoft.AspNet.Cors/CorsPolicy.cs similarity index 97% rename from src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs rename to src/Microsoft.AspNet.Cors/CorsPolicy.cs index b14d52b844..3be8589b5b 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsPolicy.cs +++ b/src/Microsoft.AspNet.Cors/CorsPolicy.cs @@ -3,10 +3,9 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Text; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// Defines the policy for Cross-Origin requests based on the CORS specifications. @@ -124,7 +123,7 @@ namespace Microsoft.AspNet.Cors.Core builder.Append(", AllowAnyOrigin: "); builder.Append(AllowAnyOrigin); builder.Append(", PreflightMaxAge: "); - builder.Append(PreflightMaxAge.HasValue ? + builder.Append(PreflightMaxAge.HasValue ? PreflightMaxAge.Value.TotalSeconds.ToString() : "null"); builder.Append(", SupportsCredentials: "); builder.Append(SupportsCredentials); diff --git a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs b/src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs similarity index 98% rename from src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs rename to src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs index 99c1a0b795..71b500cd48 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs +++ b/src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs @@ -3,9 +3,8 @@ using System; using System.Linq; -using Microsoft.AspNet.Cors.Core; -namespace Microsoft.AspNet.Cors +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// Exposes methods to build a policy. diff --git a/src/Microsoft.AspNet.Cors.Core/CorsResult.cs b/src/Microsoft.AspNet.Cors/CorsResult.cs similarity index 97% rename from src/Microsoft.AspNet.Cors.Core/CorsResult.cs rename to src/Microsoft.AspNet.Cors/CorsResult.cs index 8b0f39a9cb..bb5e458dd3 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsResult.cs +++ b/src/Microsoft.AspNet.Cors/CorsResult.cs @@ -3,11 +3,9 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; using System.Text; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// Results returned by . diff --git a/src/Microsoft.AspNet.Cors.Core/CorsService.cs b/src/Microsoft.AspNet.Cors/CorsService.cs similarity index 99% rename from src/Microsoft.AspNet.Cors.Core/CorsService.cs rename to src/Microsoft.AspNet.Cors/CorsService.cs index f4d06c9395..e8e2875731 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsService.cs +++ b/src/Microsoft.AspNet.Cors/CorsService.cs @@ -9,7 +9,7 @@ using Microsoft.AspNet.Http; using Microsoft.Extensions.OptionsModel; using Microsoft.Extensions.Primitives; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// Default implementation of . diff --git a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs similarity index 94% rename from src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs rename to src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs index ed4544b91e..08b7928b74 100644 --- a/src/Microsoft.AspNet.Cors.Core/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs @@ -2,11 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Cors; -using Microsoft.AspNet.Cors.Core; -using Microsoft.Extensions.Configuration; +using Microsoft.AspNet.Cors.Infrastructure; using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Internal; namespace Microsoft.Extensions.DependencyInjection { diff --git a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs similarity index 95% rename from src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs rename to src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs index 01f4574a8b..d714231cf9 100644 --- a/src/Microsoft.AspNet.Cors.Core/DefaultCorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.Extensions.OptionsModel; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// public class DefaultCorsPolicyProvider : ICorsPolicyProvider diff --git a/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs b/src/Microsoft.AspNet.Cors/DisableCorsAttribute.cs similarity index 84% rename from src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs rename to src/Microsoft.AspNet.Cors/DisableCorsAttribute.cs index dfc07b3f22..5727b98d52 100644 --- a/src/Microsoft.AspNet.Cors.Core/DisableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors/DisableCorsAttribute.cs @@ -2,8 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Cors.Infrastructure; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors { /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] diff --git a/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs b/src/Microsoft.AspNet.Cors/EnableCorsAttribute.cs similarity index 91% rename from src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs rename to src/Microsoft.AspNet.Cors/EnableCorsAttribute.cs index 03294db22e..23b2b5443f 100644 --- a/src/Microsoft.AspNet.Cors.Core/EnableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors/EnableCorsAttribute.cs @@ -2,8 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Cors.Infrastructure; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors { /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors/ICorsPolicyProvider.cs similarity index 94% rename from src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs rename to src/Microsoft.AspNet.Cors/ICorsPolicyProvider.cs index fa13aab7e4..a69df524e9 100644 --- a/src/Microsoft.AspNet.Cors.Core/ICorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors/ICorsPolicyProvider.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// A type which can provide a for a particular . diff --git a/src/Microsoft.AspNet.Cors.Core/ICorsService.cs b/src/Microsoft.AspNet.Cors/ICorsService.cs similarity index 92% rename from src/Microsoft.AspNet.Cors.Core/ICorsService.cs rename to src/Microsoft.AspNet.Cors/ICorsService.cs index 3c94859856..faabc5867c 100644 --- a/src/Microsoft.AspNet.Cors.Core/ICorsService.cs +++ b/src/Microsoft.AspNet.Cors/ICorsService.cs @@ -3,7 +3,7 @@ using Microsoft.AspNet.Http; -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// A type which can evaluate a policy for a particular . @@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Cors.Core /// The associated with the call. /// The which needs to be evaluated. /// A which contains the result of policy evaluation and can be - /// used by the caller to set apporpriate response headers. + /// used by the caller to set appropriate response headers. CorsResult EvaluatePolicy(HttpContext context, CorsPolicy policy); diff --git a/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs b/src/Microsoft.AspNet.Cors/IDisableCorsAttribute.cs similarity index 88% rename from src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs rename to src/Microsoft.AspNet.Cors/IDisableCorsAttribute.cs index ae06fcb216..63e2e5c5a9 100644 --- a/src/Microsoft.AspNet.Cors.Core/IDisableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors/IDisableCorsAttribute.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// An interface which can be used to identify a type which provides metdata to disable cors for a resource. diff --git a/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs b/src/Microsoft.AspNet.Cors/IEnableCorsAttribute.cs similarity index 91% rename from src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs rename to src/Microsoft.AspNet.Cors/IEnableCorsAttribute.cs index 0531b5b847..724f3a0e0f 100644 --- a/src/Microsoft.AspNet.Cors.Core/IEnableCorsAttribute.cs +++ b/src/Microsoft.AspNet.Cors/IEnableCorsAttribute.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Cors.Core +namespace Microsoft.AspNet.Cors.Infrastructure { /// /// An interface which can be used to identify a type which provides metadata needed for enabling CORS support. diff --git a/src/Microsoft.AspNet.Cors/Resources.Designer.cs b/src/Microsoft.AspNet.Cors/Resources.Designer.cs new file mode 100644 index 0000000000..72b39342e9 --- /dev/null +++ b/src/Microsoft.AspNet.Cors/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.AspNet.Cors { + using System; + using System.Reflection; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.Cors.Resources", typeof(Resources).GetTypeInfo().Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to PreflightMaxAge must be greater than or equal to 0.. + /// + internal static string PreflightMaxAgeOutOfRange { + get { + return ResourceManager.GetString("PreflightMaxAgeOutOfRange", resourceCulture); + } + } + } +} diff --git a/src/Microsoft.AspNet.Cors.Core/Resources.resx b/src/Microsoft.AspNet.Cors/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Cors.Core/Resources.resx rename to src/Microsoft.AspNet.Cors/Resources.resx diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index c0e28d8f10..966011fe66 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -8,11 +8,14 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.Cors.Core": "6.0.0-*" + "Microsoft.AspNet.Http.Extensions": "1.0.0-*", + "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", + "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", + "Microsoft.Extensions.OptionsModel": "1.0.0-*" }, - "frameworks" : { - "dnx451" : { }, - "dnxcore50" : { } + "frameworks": { + "dnx451": { }, + "dnxcore50": { } } } diff --git a/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj b/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj deleted file mode 100644 index 760025e155..0000000000 --- a/test/Microsoft.AspNet.Cors.Core.Test/Microsoft.AspNet.Cors.Core.Test.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - b4f83a06-eb8e-4186-84c4-c6daf7eb03d4 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Core.Test/project.json b/test/Microsoft.AspNet.Cors.Core.Test/project.json deleted file mode 100644 index 8d78c46151..0000000000 --- a/test/Microsoft.AspNet.Cors.Core.Test/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "Microsoft.AspNet.Cors.Core": "6.0.0-*", - "Microsoft.AspNet.Http": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "commands": { - "test": "xunit.runner.aspnet" - }, - - "frameworks" : { - "dnx451": { }, - "dnxcore50": { } - } -} diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index ba3759a5a7..fc4c7c7bcc 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Net; using System.Threading.Tasks; using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.TestHost; @@ -13,7 +12,7 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using Xunit; -namespace Microsoft.AspNet.Cors.Test +namespace Microsoft.AspNet.Cors.Infrastructure { public class CorsMiddlewareTests { diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs similarity index 99% rename from test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs rename to test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs index e0b5e6217d..c16a71aee3 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyBuilderTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using Xunit; -namespace Microsoft.AspNet.Cors.Core.Test +namespace Microsoft.AspNet.Cors.Infrastructure { public class CorsPolicyBuilderTests { diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsPolicyTests.cs similarity index 98% rename from test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs rename to test/Microsoft.AspNet.Cors.Test/CorsPolicyTests.cs index f9e290818e..a4b1d772a3 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsPolicyTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsPolicyTests.cs @@ -4,7 +4,7 @@ using System; using Xunit; -namespace Microsoft.AspNet.Cors.Core.Test +namespace Microsoft.AspNet.Cors.Infrastructure { public class CorsPolicyTest { diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsResultTests.cs similarity index 96% rename from test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs rename to test/Microsoft.AspNet.Cors.Test/CorsResultTests.cs index fca9916c05..949c10854a 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsResultTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsResultTests.cs @@ -4,7 +4,7 @@ using System; using Xunit; -namespace Microsoft.AspNet.Cors.Core.Test +namespace Microsoft.AspNet.Cors.Infrastructure { public class CorsResultTest { @@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Cors.Core.Test corsResult.AllowedHeaders.Add("baz"); corsResult.AllowedMethods.Add("GET"); - // Act + // Act var result = corsResult.ToString(); // Assert diff --git a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsServiceTests.cs similarity index 99% rename from test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs rename to test/Microsoft.AspNet.Cors.Test/CorsServiceTests.cs index 98c0af90b6..1efc473407 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsServiceTests.cs @@ -6,7 +6,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Xunit; -namespace Microsoft.AspNet.Cors.Core.Test +namespace Microsoft.AspNet.Cors.Infrastructure { public class CorsServiceTests { diff --git a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNet.Cors.Test/DefaultCorsPolicyProviderTests.cs similarity index 97% rename from test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs rename to test/Microsoft.AspNet.Cors.Test/DefaultCorsPolicyProviderTests.cs index 0ff2f0b0ef..83a08bec24 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/DefaultCorsPolicyProviderTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http.Internal; using Xunit; -namespace Microsoft.AspNet.Cors.Core.Test +namespace Microsoft.AspNet.Cors.Infrastructure { public class DefaultPolicyProviderTests { diff --git a/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs b/test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs similarity index 87% rename from test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs rename to test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs index fa8e0059a5..41ede97804 100644 --- a/test/Microsoft.AspNet.Cors.Core.Test/TestCorsOptions.cs +++ b/test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.OptionsModel; -namespace Microsoft.AspNet.Cors.Core.Test +namespace Microsoft.AspNet.Cors.Infrastructure { public class TestCorsOptions : IOptions { From 3a0080439b8f09e78cf34f217c96e15df3aae12a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 22 Oct 2015 00:23:51 -0700 Subject: [PATCH 068/271] Switching to generations TFMs --- src/Microsoft.AspNet.Cors/project.json | 39 +++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index 966011fe66..a21984ec16 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -1,21 +1,20 @@ { - "version": "6.0.0-*", - "repository": { - "type": "git", - "url": "https://github.com/aspnet/cors" - }, - "compilationOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "Microsoft.AspNet.Http.Extensions": "1.0.0-*", - "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", - "Microsoft.Extensions.OptionsModel": "1.0.0-*" - }, - - "frameworks": { - "dnx451": { }, - "dnxcore50": { } - } -} + "version": "6.0.0-*", + "repository": { + "type": "git", + "url": "https://github.com/aspnet/cors" + }, + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.AspNet.Http.Extensions": "1.0.0-*", + "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", + "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", + "Microsoft.Extensions.OptionsModel": "1.0.0-*" + }, + "frameworks": { + "net451": {}, + "dotnet5.4": {} + } +} \ No newline at end of file From 29f576f6eeb9f8cf204855d2f99159834249fd55 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 28 Oct 2015 12:43:08 -0700 Subject: [PATCH 069/271] Updating to release NuGet.config. --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index d6745f70b5..2344257191 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + From 926a6a7affd6a2a2b3e05a996b48da8a8997fd43 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Tue, 3 Nov 2015 12:53:40 -0800 Subject: [PATCH 070/271] Strong name Microsoft.AspNet.Cors. --- src/Microsoft.AspNet.Cors/project.json | 3 ++- tools/Key.snk | Bin 0 -> 596 bytes 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 tools/Key.snk diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index a21984ec16..508cb6cd61 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -5,7 +5,8 @@ "url": "https://github.com/aspnet/cors" }, "compilationOptions": { - "warningsAsErrors": true + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk" }, "dependencies": { "Microsoft.AspNet.Http.Extensions": "1.0.0-*", diff --git a/tools/Key.snk b/tools/Key.snk new file mode 100644 index 0000000000000000000000000000000000000000..e10e4889c125d3120cd9e81582243d70f7cbb806 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098=Iw=HCsnz~#iVhm& zj%TU(_THUee?3yHBjk$37ysB?i5#7WD$={H zV4B!OxRPrb|8)HPg~A}8P>^=#y<)56#=E&NzcjOtPK~<4n6GHt=K$ro*T(lhby_@U zEk(hLzk1H)0yXj{A_5>fk-TgNoP|q6(tP2xo8zt8i%212CWM#AeCd?`hS|4~L({h~Moo(~vy&3Z z1uI}`fd^*>o=rwbAGymj6RM^pZm(*Kfhs+Y1#`-2JPWZMK8@;ZWCk2+9bX4YP);~fj-BU*R zQPvWv$89!{Rl9wM+zR>_TSkn^voYxA?2G iKnV#iZ6Ah`K>b=@=IjYJXrxL124zR(38)nxe+&q_$QXwJ literal 0 HcmV?d00001 From a7951a1d8dcbe7debc478c1cdef8bb573158e2f6 Mon Sep 17 00:00:00 2001 From: ryanbrandenburg Date: Thu, 12 Nov 2015 10:06:50 -0800 Subject: [PATCH 071/271] * Remove samples --- CORS.sln | 16 -- samples/UseOptions/Project_Readme.html | 204 ------------------ samples/UseOptions/Startup.cs | 21 -- samples/UseOptions/UseOptions.xproj | 18 -- samples/UseOptions/project.json | 30 --- samples/UsePolicyBuilder/Project_Readme.html | 204 ------------------ samples/UsePolicyBuilder/Startup.cs | 20 -- .../UsePolicyBuilder/UsePolicyBuilder.xproj | 18 -- samples/UsePolicyBuilder/project.json | 30 --- 9 files changed, 561 deletions(-) delete mode 100644 samples/UseOptions/Project_Readme.html delete mode 100644 samples/UseOptions/Startup.cs delete mode 100644 samples/UseOptions/UseOptions.xproj delete mode 100644 samples/UseOptions/project.json delete mode 100644 samples/UsePolicyBuilder/Project_Readme.html delete mode 100644 samples/UsePolicyBuilder/Startup.cs delete mode 100644 samples/UsePolicyBuilder/UsePolicyBuilder.xproj delete mode 100644 samples/UsePolicyBuilder/project.json diff --git a/CORS.sln b/CORS.sln index 7af505a971..0d3ab28c1b 100644 --- a/CORS.sln +++ b/CORS.sln @@ -16,12 +16,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors", "sr EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Test", "test\Microsoft.AspNet.Cors.Test\Microsoft.AspNet.Cors.Test.xproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{EEF80A8E-F334-4C66-9537-8D24D002149D}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UseOptions", "samples\UseOptions\UseOptions.xproj", "{8DC90D0F-9660-42AD-BE08-4A7643A8F46E}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UsePolicyBuilder", "samples\UsePolicyBuilder\UsePolicyBuilder.xproj", "{6916DB8A-0246-45F8-9C64-9B05556C1A5D}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -36,14 +30,6 @@ Global {F05BE96F-F869-4408-A480-96935B4835EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {F05BE96F-F869-4408-A480-96935B4835EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {F05BE96F-F869-4408-A480-96935B4835EE}.Release|Any CPU.Build.0 = Release|Any CPU - {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8DC90D0F-9660-42AD-BE08-4A7643A8F46E}.Release|Any CPU.Build.0 = Release|Any CPU - {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6916DB8A-0246-45F8-9C64-9B05556C1A5D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -51,7 +37,5 @@ Global GlobalSection(NestedProjects) = preSolution {41349FCD-D1C4-47A6-82D0-D16D00A8D59D} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} {F05BE96F-F869-4408-A480-96935B4835EE} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} - {8DC90D0F-9660-42AD-BE08-4A7643A8F46E} = {EEF80A8E-F334-4C66-9537-8D24D002149D} - {6916DB8A-0246-45F8-9C64-9B05556C1A5D} = {EEF80A8E-F334-4C66-9537-8D24D002149D} EndGlobalSection EndGlobal diff --git a/samples/UseOptions/Project_Readme.html b/samples/UseOptions/Project_Readme.html deleted file mode 100644 index b693be4eba..0000000000 --- a/samples/UseOptions/Project_Readme.html +++ /dev/null @@ -1,204 +0,0 @@ - - - - - Welcome to ASP.NET 5 - - - - - - - - - - \ No newline at end of file diff --git a/samples/UseOptions/Startup.cs b/samples/UseOptions/Startup.cs deleted file mode 100644 index c2e8299fc0..0000000000 --- a/samples/UseOptions/Startup.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.Extensions.DependencyInjection; - -namespace UseOptions -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddCors(options => - options.AddPolicy("allowSingleOrigin", builder => builder.WithOrigins("http://example.com"))); - } - - public void Configure(IApplicationBuilder app) - { - app.UseCors("allowSingleOrigin"); - } - } -} diff --git a/samples/UseOptions/UseOptions.xproj b/samples/UseOptions/UseOptions.xproj deleted file mode 100644 index 93e6c00701..0000000000 --- a/samples/UseOptions/UseOptions.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 8dc90d0f-9660-42ad-be08-4a7643a8f46e - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - 5442 - - - \ No newline at end of file diff --git a/samples/UseOptions/project.json b/samples/UseOptions/project.json deleted file mode 100644 index 2733f72e2f..0000000000 --- a/samples/UseOptions/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "webroot": "wwwroot", - "version": "1.0.0-*", - "dependencies": { - "Microsoft.AspNet.Cors": "6.0.0-*", - "Microsoft.AspNet.Diagnostics": "1.0.0-*", - "Microsoft.AspNet.Server.IIS": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" - }, - "commands": { - "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" - }, - "frameworks": { - "dnx451": {}, - "dnxcore50": {} - }, - "publishExclude": [ - "node_modules", - "bower_components", - "**.kproj", - "**.user", - "**.vspscc" - ], - "exclude": [ - "wwwroot", - "node_modules", - "bower_components" - ] -} \ No newline at end of file diff --git a/samples/UsePolicyBuilder/Project_Readme.html b/samples/UsePolicyBuilder/Project_Readme.html deleted file mode 100644 index b693be4eba..0000000000 --- a/samples/UsePolicyBuilder/Project_Readme.html +++ /dev/null @@ -1,204 +0,0 @@ - - - - - Welcome to ASP.NET 5 - - - - - - - - - - \ No newline at end of file diff --git a/samples/UsePolicyBuilder/Startup.cs b/samples/UsePolicyBuilder/Startup.cs deleted file mode 100644 index 539f9a808e..0000000000 --- a/samples/UsePolicyBuilder/Startup.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.Extensions.DependencyInjection; - -namespace UsePolicy -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddCors(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseCors(policy => policy.WithOrigins("http://example.com")); - } - } -} diff --git a/samples/UsePolicyBuilder/UsePolicyBuilder.xproj b/samples/UsePolicyBuilder/UsePolicyBuilder.xproj deleted file mode 100644 index f75668321b..0000000000 --- a/samples/UsePolicyBuilder/UsePolicyBuilder.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 6916db8a-0246-45f8-9c64-9b05556c1a5d - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - 12497 - - - \ No newline at end of file diff --git a/samples/UsePolicyBuilder/project.json b/samples/UsePolicyBuilder/project.json deleted file mode 100644 index 2733f72e2f..0000000000 --- a/samples/UsePolicyBuilder/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "webroot": "wwwroot", - "version": "1.0.0-*", - "dependencies": { - "Microsoft.AspNet.Cors": "6.0.0-*", - "Microsoft.AspNet.Diagnostics": "1.0.0-*", - "Microsoft.AspNet.Server.IIS": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-*" - }, - "commands": { - "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" - }, - "frameworks": { - "dnx451": {}, - "dnxcore50": {} - }, - "publishExclude": [ - "node_modules", - "bower_components", - "**.kproj", - "**.user", - "**.vspscc" - ], - "exclude": [ - "wwwroot", - "node_modules", - "bower_components" - ] -} \ No newline at end of file From df024976f32a53ecdcd10880a1e5bf6953c33099 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 17 Nov 2015 10:53:39 -0800 Subject: [PATCH 072/271] Explicitly choose Mono 4.0.5 - avoids future problems related to aspnet/External#48 - e.g. when Travis updates default Mono version in `csharp` bundle --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 947bf868ee..dc44c0f660 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: csharp sudo: false +mono: + - 4.0.5 script: - ./build.sh --quiet verify \ No newline at end of file From d88646cb7b0c6d1c5f98ee58cc0af46b1b79301c Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 17 Nov 2015 12:33:16 -0800 Subject: [PATCH 073/271] Move Travis to supported Linux distribution - use Ubuntu 14.04 (Trusty) - Travis support for Trusty is in Beta and currently requires `sudo` - run `dnu restore` with DNX Core since aspnet/External#49 is not fixed in Mono versions we can use - add required dependencies for DNX Core to `.travis.yml` - addresses part of aspnet/Universe#290 --- .travis.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc44c0f660..2fc624899f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,18 @@ language: csharp -sudo: false +sudo: required +dist: trusty +addons: + apt: + packages: + - gettext + - libcurl4-openssl-dev + - libicu-dev + - libssl-dev + - libunwind8 + - zlib1g +env: + - KOREBUILD_DNU_RESTORE_CORECLR=true mono: - 4.0.5 script: - - ./build.sh --quiet verify \ No newline at end of file + - ./build.sh --quiet verify From 80f16554785afd246c0417775802ffc1867dfae3 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Mon, 23 Nov 2015 10:17:43 -0800 Subject: [PATCH 074/271] [Fixes #51] Missing null check in CorsPolicyBuilder --- .../CorsPolicyBuilder.cs | 6 ++- .../CorsPolicyBuilderTests.cs | 53 ++++++++++++++----- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs b/src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs index 71b500cd48..d018b92a68 100644 --- a/src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs +++ b/src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs @@ -180,7 +180,11 @@ namespace Microsoft.AspNet.Cors.Infrastructure WithHeaders(policy.Headers.ToArray()); WithExposedHeaders(policy.ExposedHeaders.ToArray()); WithMethods(policy.Methods.ToArray()); - SetPreflightMaxAge(policy.PreflightMaxAge.Value); + + if (policy.PreflightMaxAge.HasValue) + { + SetPreflightMaxAge(policy.PreflightMaxAge.Value); + } if (policy.SupportsCredentials) { diff --git a/test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs index c16a71aee3..5f9f6fe737 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs @@ -14,16 +14,16 @@ namespace Microsoft.AspNet.Cors.Infrastructure public void Constructor_WithPolicy_AddsTheGivenPolicy() { // Arrange - var policy = new CorsPolicy(); - policy.Origins.Add("http://existing.com"); - policy.Headers.Add("Existing"); - policy.Methods.Add("GET"); - policy.ExposedHeaders.Add("ExistingExposed"); - policy.SupportsCredentials = true; - policy.PreflightMaxAge = TimeSpan.FromSeconds(12); + var originalPolicy = new CorsPolicy(); + originalPolicy.Origins.Add("http://existing.com"); + originalPolicy.Headers.Add("Existing"); + originalPolicy.Methods.Add("GET"); + originalPolicy.ExposedHeaders.Add("ExistingExposed"); + originalPolicy.SupportsCredentials = true; + originalPolicy.PreflightMaxAge = TimeSpan.FromSeconds(12); // Act - var builder = new CorsPolicyBuilder(policy); + var builder = new CorsPolicyBuilder(originalPolicy); // Assert var corsPolicy = builder.Build(); @@ -32,13 +32,41 @@ namespace Microsoft.AspNet.Cors.Infrastructure Assert.False(corsPolicy.AllowAnyMethod); Assert.False(corsPolicy.AllowAnyOrigin); Assert.True(corsPolicy.SupportsCredentials); - Assert.Equal(policy.Headers, corsPolicy.Headers); - Assert.Equal(policy.Methods, corsPolicy.Methods); - Assert.Equal(policy.Origins, corsPolicy.Origins); - Assert.Equal(policy.ExposedHeaders, corsPolicy.ExposedHeaders); + Assert.NotSame(originalPolicy.Headers, corsPolicy.Headers); + Assert.Equal(originalPolicy.Headers, corsPolicy.Headers); + Assert.NotSame(originalPolicy.Methods, corsPolicy.Methods); + Assert.Equal(originalPolicy.Methods, corsPolicy.Methods); + Assert.NotSame(originalPolicy.Origins, corsPolicy.Origins); + Assert.Equal(originalPolicy.Origins, corsPolicy.Origins); + Assert.NotSame(originalPolicy.ExposedHeaders, corsPolicy.ExposedHeaders); + Assert.Equal(originalPolicy.ExposedHeaders, corsPolicy.ExposedHeaders); Assert.Equal(TimeSpan.FromSeconds(12), corsPolicy.PreflightMaxAge); } + [Fact] + public void ConstructorWithPolicy_HavingNullPreflightMaxAge_AddsTheGivenPolicy() + { + // Arrange + var originalPolicy = new CorsPolicy(); + originalPolicy.Origins.Add("http://existing.com"); + + // Act + var builder = new CorsPolicyBuilder(originalPolicy); + + // Assert + var corsPolicy = builder.Build(); + + Assert.Null(corsPolicy.PreflightMaxAge); + Assert.False(corsPolicy.AllowAnyHeader); + Assert.False(corsPolicy.AllowAnyMethod); + Assert.False(corsPolicy.AllowAnyOrigin); + Assert.NotSame(originalPolicy.Origins, corsPolicy.Origins); + Assert.Equal(originalPolicy.Origins, corsPolicy.Origins); + Assert.Empty(corsPolicy.Headers); + Assert.Empty(corsPolicy.Methods); + Assert.Empty(corsPolicy.ExposedHeaders); + } + [Fact] public void Constructor_WithNoOrigin() { @@ -112,7 +140,6 @@ namespace Microsoft.AspNet.Cors.Infrastructure Assert.Equal(new List() { "*" }, corsPolicy.Origins); } - [Fact] public void WithMethods_AddsMethods() { From a45c08a4c4f3d7a08f94548015317f435e6a8409 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 10 Nov 2015 15:06:41 -0800 Subject: [PATCH 075/271] Updating tests to use moq.netcore --- test/Microsoft.AspNet.Cors.Test/project.json | 30 ++++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/test/Microsoft.AspNet.Cors.Test/project.json b/test/Microsoft.AspNet.Cors.Test/project.json index 270d1860d3..28524e36ec 100644 --- a/test/Microsoft.AspNet.Cors.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Test/project.json @@ -1,17 +1,23 @@ { - "version": "1.0.0-*", - "dependencies": { - "Microsoft.AspNet.Cors": "6.0.0-*", - "Microsoft.AspNet.TestHost": "1.0.0-*", + "version": "1.0.0-*", + "dependencies": { + "Microsoft.AspNet.Cors": "6.0.0-*", + "Microsoft.AspNet.TestHost": "1.0.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { + "dependencies": { "Moq": "4.2.1312.1622", - "xunit.runner.aspnet": "2.0.0-aspnet-*" + } }, - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { - "dependencies": {} - } + "dnxcore50": { + "dependencies": { + "moq.netcore": "4.4.0-beta8" + } } + } } \ No newline at end of file From 0d042572b98964a8e17767660b5b32df49278fcf Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 1 Dec 2015 12:47:49 -0800 Subject: [PATCH 076/271] Allowing CoreCLR tests to run on Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2fc624899f..c0befaffcf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ addons: - libunwind8 - zlib1g env: - - KOREBUILD_DNU_RESTORE_CORECLR=true + - KOREBUILD_DNU_RESTORE_CORECLR=true KOREBUILD_TEST_DNXCORE=true mono: - 4.0.5 script: From b3649ea79a18ac1a58331ecbc50a6407507ec791 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 11 Dec 2015 12:23:51 -0800 Subject: [PATCH 077/271] Updating to release NuGet.config. --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index d6745f70b5..2344257191 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + From c3c0b452256849e6efa09d2d27e34d54396b649f Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Fri, 11 Dec 2015 21:53:45 -0800 Subject: [PATCH 078/271] Move functional tests of CORS middleware to this repo - related to aspnet/Mvc#3612 --- .gitignore | 1 + CORS.sln | 12 ++- global.json | 2 +- src/Microsoft.AspNet.Cors/CorsMiddleware.cs | 1 - .../CorsMiddlewareFunctionalTest.cs | 98 +++++++++++++++++++ .../CorsTestFixtureOfT.cs | 33 +++++++ .../Microsoft.AspNet.Cors.Test.xproj | 3 + test/Microsoft.AspNet.Cors.Test/project.json | 4 +- .../CorsMiddlewareWebSite.xproj | 18 ++++ .../CorsMiddlewareWebSite/EchoMiddleware.cs | 38 +++++++ .../WebSites/CorsMiddlewareWebSite/Startup.cs | 22 +++++ .../CorsMiddlewareWebSite/project.json | 15 +++ test/WebSites/CorsMiddlewareWebSite/readme.md | 4 + .../CorsMiddlewareWebSite/wwwroot/web.config | 9 ++ 14 files changed, 256 insertions(+), 4 deletions(-) create mode 100644 test/Microsoft.AspNet.Cors.Test/CorsMiddlewareFunctionalTest.cs create mode 100644 test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs create mode 100644 test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj create mode 100644 test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs create mode 100644 test/WebSites/CorsMiddlewareWebSite/Startup.cs create mode 100644 test/WebSites/CorsMiddlewareWebSite/project.json create mode 100644 test/WebSites/CorsMiddlewareWebSite/readme.md create mode 100644 test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config diff --git a/.gitignore b/.gitignore index 8a9bbc3a43..329a307cda 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ nuget.exe *.sln.ide node_modules **/[Cc]ompiler/[Rr]esources/**/*.js +*launchSettings.json diff --git a/CORS.sln b/CORS.sln index 0d3ab28c1b..a0d8647301 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" EndProject @@ -16,6 +16,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors", "sr EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Test", "test\Microsoft.AspNet.Cors.Test\Microsoft.AspNet.Cors.Test.xproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{538380BF-0D4C-4E30-8F41-E75C4B1C01FA}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CorsMiddlewareWebSite", "test\WebSites\CorsMiddlewareWebSite\CorsMiddlewareWebSite.xproj", "{B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,6 +34,10 @@ Global {F05BE96F-F869-4408-A480-96935B4835EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {F05BE96F-F869-4408-A480-96935B4835EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {F05BE96F-F869-4408-A480-96935B4835EE}.Release|Any CPU.Build.0 = Release|Any CPU + {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -37,5 +45,7 @@ Global GlobalSection(NestedProjects) = preSolution {41349FCD-D1C4-47A6-82D0-D16D00A8D59D} = {84FE6872-A610-4CEC-855F-A84CBF1F40FC} {F05BE96F-F869-4408-A480-96935B4835EE} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} + {538380BF-0D4C-4E30-8F41-E75C4B1C01FA} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} + {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB} = {538380BF-0D4C-4E30-8F41-E75C4B1C01FA} EndGlobalSection EndGlobal diff --git a/global.json b/global.json index ec2e704f70..262a7f2b59 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,3 @@ { - "projects": ["src", "test"] + "projects": ["src", "test/WebSites"] } diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs index 7779eb2291..f8d3042277 100644 --- a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs +++ b/src/Microsoft.AspNet.Cors/CorsMiddleware.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Extensions.Primitives; diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareFunctionalTest.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareFunctionalTest.cs new file mode 100644 index 0000000000..6be83fed21 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareFunctionalTest.cs @@ -0,0 +1,98 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNet.Cors.Infrastructure +{ + public class CorsMiddlewareFunctionalTests : IClassFixture> + { + public CorsMiddlewareFunctionalTests(CorsTestFixture fixture) + { + Client = fixture.Client; + } + + public HttpClient Client { get; } + + [Theory] + [InlineData("GET")] + [InlineData("HEAD")] + [InlineData("POST")] + public async Task ResourceWithSimpleRequestPolicy_Allows_SimpleRequests(string method) + { + // Arrange + var path = "/CorsMiddleware/EC6AA70D-BA3E-4B71-A87F-18625ADDB2BD"; + var origin = "http://example.com"; + var request = new HttpRequestMessage(new HttpMethod(method), path); + request.Headers.Add(CorsConstants.Origin, origin); + + // Act + var response = await Client.SendAsync(request); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + var content = await response.Content.ReadAsStringAsync(); + Assert.Equal(path, content); + var responseHeaders = response.Headers; + var header = Assert.Single(response.Headers); + Assert.Equal(CorsConstants.AccessControlAllowOrigin, header.Key); + Assert.Equal(new[] { "http://example.com" }, header.Value.ToArray()); + } + + [Theory] + [InlineData("GET")] + [InlineData("HEAD")] + [InlineData("POST")] + [InlineData("PUT")] + public async Task PolicyFailed_Disallows_PreFlightRequest(string method) + { + // Arrange + var path = "/CorsMiddleware/9B8BB9C6-5BF2-4255-A636-DCB450D51AAE"; + var request = new HttpRequestMessage(new HttpMethod(CorsConstants.PreflightHttpMethod), path); + + // Adding a custom header makes it a non-simple request. + request.Headers.Add(CorsConstants.Origin, "http://example.com"); + request.Headers.Add(CorsConstants.AccessControlRequestMethod, method); + request.Headers.Add(CorsConstants.AccessControlRequestHeaders, "Custom"); + + // Act + var response = await Client.SendAsync(request); + + // Assert + // Middleware applied the policy and since that did not pass, there were no access control headers. + Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); + Assert.Empty(response.Headers); + + // It should short circuit and hence no result. + var content = await response.Content.ReadAsStringAsync(); + Assert.Equal(string.Empty, content); + } + + [Fact] + public async Task PolicyFailed_Allows_ActualRequest_WithMissingResponseHeaders() + { + // Arrange + var path = "/CorsMiddleware/1E6C6F4D-1E1C-450E-8BD0-73DBF089A78F"; + var request = new HttpRequestMessage(HttpMethod.Put, path); + + // Adding a custom header makes it a non simple request. + request.Headers.Add(CorsConstants.Origin, "http://example2.com"); + + // Act + var response = await Client.SendAsync(request); + + // Assert + // Middleware applied the policy and since that did not pass, there were no access control headers. + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + Assert.Empty(response.Headers); + + // It still has executed the action. + var content = await response.Content.ReadAsStringAsync(); + Assert.Equal(path, content); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs b/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs new file mode 100644 index 0000000000..f3c11d50b0 --- /dev/null +++ b/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Net.Http; +using Microsoft.AspNet.Hosting; +using Microsoft.AspNet.TestHost; + +namespace Microsoft.AspNet.Cors.Infrastructure +{ + public class CorsTestFixture : IDisposable + where TStartup : class + { + private readonly TestServer _server; + + public CorsTestFixture() + { + var builder = new WebHostBuilder().UseStartup(); + _server = new TestServer(builder); + + Client = _server.CreateClient(); + Client.BaseAddress = new Uri("http://localhost"); + } + + public HttpClient Client { get; } + + public void Dispose() + { + Client.Dispose(); + _server.Dispose(); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj b/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj index cb9268f4ad..3dc6401fe9 100644 --- a/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj +++ b/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj @@ -13,5 +13,8 @@ 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Cors.Test/project.json b/test/Microsoft.AspNet.Cors.Test/project.json index 28524e36ec..e444740695 100644 --- a/test/Microsoft.AspNet.Cors.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Test/project.json @@ -1,8 +1,10 @@ -{ +{ "version": "1.0.0-*", "dependencies": { + "CorsMiddlewareWebSite": "1.0.0-*", "Microsoft.AspNet.Cors": "6.0.0-*", "Microsoft.AspNet.TestHost": "1.0.0-*", + "Microsoft.Extensions.Logging.Testing": "1.0.0-*", "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "commands": { diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj new file mode 100644 index 0000000000..7e7d95f9c7 --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj @@ -0,0 +1,18 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + b42d4844-fff8-4ec2-88d1-3ae95234d9eb + ..\..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + 41642 + + + \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs b/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs new file mode 100644 index 0000000000..fbc07dacde --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNet.Http; + +namespace CorsMiddlewareWebSite +{ + public class EchoMiddleware + { + /// + /// Instantiates a new . + /// + /// The next middleware in the pipeline. + public EchoMiddleware(RequestDelegate next) + { + } + + /// + /// Echo the request's path in the response. Does not invoke later middleware in the pipeline. + /// + /// The of the current request. + /// A that completes when writing to the response is done. + public Task Invoke(HttpContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + context.Response.ContentType = "text/plain; charset=utf-8"; + var path = context.Request.PathBase + context.Request.Path + context.Request.QueryString; + return context.Response.WriteAsync(path, Encoding.UTF8); + } + } +} \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs new file mode 100644 index 0000000000..43008f4719 --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -0,0 +1,22 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace CorsMiddlewareWebSite +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddCors(); + } + + public void Configure(IApplicationBuilder app) + { + app.UseCors(policy => policy.WithOrigins("http://example.com")); + app.UseMiddleware(); + } + } +} \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json new file mode 100644 index 0000000000..b6c30ac9fa --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -0,0 +1,15 @@ +{ + "commands": { + "web": "Microsoft.AspNet.Server.Kestrel", + "weblistener": "Microsoft.AspNet.Server.WebListener" + }, + "dependencies": { + "Microsoft.AspNet.Cors": "6.0.0-*", + "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-*" + }, + "frameworks": { + "dnx451": { }, + "dnxcore50": { } + } +} \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/readme.md b/test/WebSites/CorsMiddlewareWebSite/readme.md new file mode 100644 index 0000000000..d7f8b28106 --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/readme.md @@ -0,0 +1,4 @@ +CorsMiddlewareWebSite +=== + +This web site illustrates how to use CorsMiddleware to apply a policy for entire application. diff --git a/test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config b/test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config new file mode 100644 index 0000000000..8485f6719f --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config @@ -0,0 +1,9 @@ + + + + + + + + + From 09df979acf31b41a54b0467bee6c13c0cf9ee8e9 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 17 Dec 2015 20:55:30 -0800 Subject: [PATCH 079/271] Reacting to new Hosting API --- .../CorsMiddlewareTests.cs | 109 ++++++++++-------- .../CorsTestFixtureOfT.cs | 2 +- .../WebSites/CorsMiddlewareWebSite/Startup.cs | 10 ++ .../CorsMiddlewareWebSite/hosting.json | 3 + .../CorsMiddlewareWebSite/project.json | 9 +- 5 files changed, 80 insertions(+), 53 deletions(-) create mode 100644 test/WebSites/CorsMiddlewareWebSite/hosting.json diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index fc4c7c7bcc..2f755316d0 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.TestHost; @@ -20,19 +21,22 @@ namespace Microsoft.AspNet.Cors.Infrastructure public async Task CorsRequest_MatchPolicy_SetsResponseHeaders() { // Arrange - using (var server = TestServer.Create(app => - { - app.UseCors(builder => - builder.WithOrigins("http://localhost:5001") - .WithMethods("PUT") - .WithHeaders("Header1") - .WithExposedHeaders("AllowedHeader")); - app.Run(async context => + var appBuilder = new WebApplicationBuilder() + .Configure(app => { - await context.Response.WriteAsync("Cross origin response"); - }); - }, - services => services.AddCors())) + app.UseCors(builder => + builder.WithOrigins("http://localhost:5001") + .WithMethods("PUT") + .WithHeaders("Header1") + .WithExposedHeaders("AllowedHeader")); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + }) + .ConfigureServices(services => services.AddCors()); + + using (var server = new TestServer(appBuilder)) { // Act // Actual request. @@ -59,21 +63,24 @@ namespace Microsoft.AspNet.Cors.Infrastructure policy.Headers.Add("Header1"); policy.ExposedHeaders.Add("AllowedHeader"); - using (var server = TestServer.Create(app => - { - app.UseCors("customPolicy"); - app.Run(async context => + var appBuilder = new WebApplicationBuilder() + .Configure(app => { - await context.Response.WriteAsync("Cross origin response"); - }); - }, - services => - { - services.AddCors(options => + app.UseCors("customPolicy"); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + }) + .ConfigureServices(services => { - options.AddPolicy("customPolicy", policy); + services.AddCors(options => + { + options.AddPolicy("customPolicy", policy); + }); }); - })) + + using (var server = new TestServer(appBuilder)) { // Act // Preflight request. @@ -94,19 +101,22 @@ namespace Microsoft.AspNet.Cors.Infrastructure public async Task PreFlightRequest_DoesNotMatchPolicy_DoesNotSetHeaders() { // Arrange - using (var server = TestServer.Create(app => - { - app.UseCors(builder => - builder.WithOrigins("http://localhost:5001") - .WithMethods("PUT") - .WithHeaders("Header1") - .WithExposedHeaders("AllowedHeader")); - app.Run(async context => + var appBuilder = new WebApplicationBuilder() + .Configure(app => { - await context.Response.WriteAsync("Cross origin response"); - }); - }, - services => services.AddCors())) + app.UseCors(builder => + builder.WithOrigins("http://localhost:5001") + .WithMethods("PUT") + .WithHeaders("Header1") + .WithExposedHeaders("AllowedHeader")); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + }) + .ConfigureServices(services => services.AddCors()); + + using (var server = new TestServer(appBuilder)) { // Act // Preflight request. @@ -125,19 +135,22 @@ namespace Microsoft.AspNet.Cors.Infrastructure public async Task CorsRequest_DoesNotMatchPolicy_DoesNotSetHeaders() { // Arrange - using (var server = TestServer.Create(app => - { - app.UseCors(builder => - builder.WithOrigins("http://localhost:5001") - .WithMethods("PUT") - .WithHeaders("Header1") - .WithExposedHeaders("AllowedHeader")); - app.Run(async context => + var appBuilder = new WebApplicationBuilder() + .Configure(app => { - await context.Response.WriteAsync("Cross origin response"); - }); - }, - services => services.AddCors())) + app.UseCors(builder => + builder.WithOrigins("http://localhost:5001") + .WithMethods("PUT") + .WithHeaders("Header1") + .WithExposedHeaders("AllowedHeader")); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + }) + .ConfigureServices(services => services.AddCors()); + + using (var server = new TestServer(appBuilder)) { // Act // Actual request. diff --git a/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs b/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs index f3c11d50b0..1f83c6497d 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure public CorsTestFixture() { - var builder = new WebHostBuilder().UseStartup(); + var builder = new WebApplicationBuilder().UseStartup(); _server = new TestServer(builder); Client = _server.CreateClient(); diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index 43008f4719..8c276659a9 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Hosting; using Microsoft.Extensions.DependencyInjection; namespace CorsMiddlewareWebSite @@ -18,5 +19,14 @@ namespace CorsMiddlewareWebSite app.UseCors(policy => policy.WithOrigins("http://example.com")); app.UseMiddleware(); } + public static void Main(string[] args) + { + var application = new WebApplicationBuilder() + .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseStartup() + .Build(); + + application.Run(); + } } } \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/hosting.json b/test/WebSites/CorsMiddlewareWebSite/hosting.json new file mode 100644 index 0000000000..f8ef14574d --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/hosting.json @@ -0,0 +1,3 @@ +{ + "server": "Microsoft.AspNet.Server.Kestrel" +} diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index b6c30ac9fa..fc95a8482d 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -1,12 +1,13 @@ { + "compilationOptions": { + "emitEntryPoint": true + }, "commands": { - "web": "Microsoft.AspNet.Server.Kestrel", - "weblistener": "Microsoft.AspNet.Server.WebListener" + "web": "CorsMiddlewareWebSite" }, "dependencies": { "Microsoft.AspNet.Cors": "6.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*" + "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" }, "frameworks": { "dnx451": { }, From d79969aecb27eb87de6cf7ddfc6527f554203724 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 21 Dec 2015 14:41:52 -0800 Subject: [PATCH 080/271] React to OptionsModel => Options --- src/Microsoft.AspNet.Cors/CorsService.cs | 2 +- src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs | 2 +- src/Microsoft.AspNet.Cors/project.json | 2 +- test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.Cors/CorsService.cs b/src/Microsoft.AspNet.Cors/CorsService.cs index e8e2875731..5ec194e575 100644 --- a/src/Microsoft.AspNet.Cors/CorsService.cs +++ b/src/Microsoft.AspNet.Cors/CorsService.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using Microsoft.AspNet.Http; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; namespace Microsoft.AspNet.Cors.Infrastructure diff --git a/src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs index d714231cf9..b0887a9315 100644 --- a/src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs +++ b/src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Http; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Cors.Infrastructure { diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNet.Cors/project.json index 508cb6cd61..17732ed627 100644 --- a/src/Microsoft.AspNet.Cors/project.json +++ b/src/Microsoft.AspNet.Cors/project.json @@ -12,7 +12,7 @@ "Microsoft.AspNet.Http.Extensions": "1.0.0-*", "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", - "Microsoft.Extensions.OptionsModel": "1.0.0-*" + "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { "net451": {}, diff --git a/test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs b/test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs index 41ede97804..e7630f9a8f 100644 --- a/test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs +++ b/test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace Microsoft.AspNet.Cors.Infrastructure { From 5bf58a08e9664c63bf153c09b8f3f1b7dd7d5e33 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 7 Jan 2016 17:26:50 -0800 Subject: [PATCH 081/271] Remove redundant AddOptions which is now a default hosting service --- src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs index 08b7928b74..3a683d03d2 100644 --- a/src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs @@ -23,8 +23,7 @@ namespace Microsoft.Extensions.DependencyInjection { throw new ArgumentNullException(nameof(serviceCollection)); } - - serviceCollection.AddOptions(); + serviceCollection.TryAdd(ServiceDescriptor.Transient()); serviceCollection.TryAdd(ServiceDescriptor.Transient()); return serviceCollection; From bab41f2fbde497f152beaa2666167c65d0fd88e1 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 12 Jan 2016 15:27:00 -0800 Subject: [PATCH 082/271] React to Hosting API changes. --- test/WebSites/CorsMiddlewareWebSite/Startup.cs | 1 + test/WebSites/CorsMiddlewareWebSite/project.json | 1 + 2 files changed, 2 insertions(+) diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index 8c276659a9..08f828322c 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -23,6 +23,7 @@ namespace CorsMiddlewareWebSite { var application = new WebApplicationBuilder() .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index fc95a8482d..2214e8fa01 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -7,6 +7,7 @@ }, "dependencies": { "Microsoft.AspNet.Cors": "6.0.0-*", + "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" }, "frameworks": { From 1a3f9eda840c812994b4152eaa289207692485c5 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Tue, 12 Jan 2016 09:54:12 -0800 Subject: [PATCH 083/271] Build with dotnet --- .gitattributes | 1 + .gitignore | 2 + .travis.yml | 8 ++- appveyor.yml | 2 +- build.cmd | 68 ++++++++++---------- build.sh | 47 ++++++++------ makefile.shade | 12 ---- test/Microsoft.AspNet.Cors.Test/project.json | 11 +++- 8 files changed, 78 insertions(+), 73 deletions(-) delete mode 100644 makefile.shade diff --git a/.gitattributes b/.gitattributes index bdaa5ba982..97b827b758 100644 --- a/.gitattributes +++ b/.gitattributes @@ -48,3 +48,4 @@ *.fsproj text=auto *.dbproj text=auto *.sln text=auto eol=crlf +*.sh eol=lf diff --git a/.gitignore b/.gitignore index 329a307cda..5daa6eed09 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ nuget.exe node_modules **/[Cc]ompiler/[Rr]esources/**/*.js *launchSettings.json +.build/ +.testPublish/ diff --git a/.travis.yml b/.travis.yml index c0befaffcf..bf811dc26a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,11 @@ addons: - libssl-dev - libunwind8 - zlib1g -env: - - KOREBUILD_DNU_RESTORE_CORECLR=true KOREBUILD_TEST_DNXCORE=true mono: - 4.0.5 +os: + - linux + - osx +osx_image: xcode7.1 script: - - ./build.sh --quiet verify + - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 636a7618d3..3fab83e134 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ init: - git config --global core.autocrlf true build_script: - - build.cmd --quiet verify + - build.cmd verify clone_depth: 1 test: off deploy: off \ No newline at end of file diff --git a/build.cmd b/build.cmd index 553e3929a0..ebb619e737 100644 --- a/build.cmd +++ b/build.cmd @@ -1,40 +1,40 @@ -@echo off -cd %~dp0 - +@ECHO off SETLOCAL + +SET REPO_FOLDER=%~dp0 +CD %REPO_FOLDER% + +SET BUILD_FOLDER=.build +SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet +SET KOREBUILD_VERSION= + +SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe SET NUGET_VERSION=latest SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe -SET BUILDCMD_KOREBUILD_VERSION= -SET BUILDCMD_DNX_VERSION= -IF EXIST %CACHED_NUGET% goto copynuget -echo Downloading latest version of NuGet.exe... -IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet -@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" - -:copynuget -IF EXIST .nuget\nuget.exe goto restore -md .nuget -copy %CACHED_NUGET% .nuget\nuget.exe > nul - -:restore -IF EXIST packages\Sake goto getdnx -IF "%BUILDCMD_KOREBUILD_VERSION%"=="" ( - .nuget\nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre -) ELSE ( - .nuget\nuget.exe install KoreBuild -version %BUILDCMD_KOREBUILD_VERSION% -ExcludeVersion -o packages -nocache -pre -) -.nuget\NuGet.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages - -:getdnx -IF "%BUILDCMD_DNX_VERSION%"=="" ( - SET BUILDCMD_DNX_VERSION=latest -) -IF "%SKIP_DNX_INSTALL%"=="" ( - CALL packages\KoreBuild\build\dnvm install %BUILDCMD_DNX_VERSION% -runtime CoreCLR -arch x86 -alias default - CALL packages\KoreBuild\build\dnvm install default -runtime CLR -arch x86 -alias default -) ELSE ( - CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 +IF NOT EXIST %BUILD_FOLDER% ( + md %BUILD_FOLDER% ) -packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* +IF NOT EXIST %NUGET_PATH% ( + IF NOT EXIST %CACHED_NUGET% ( + echo Downloading latest version of NuGet.exe... + IF NOT EXIST %LocalAppData%\NuGet ( + md %LocalAppData%\NuGet + ) + @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" + ) + + copy %CACHED_NUGET% %NUGET_PATH% > nul +) + +IF NOT EXIST %KOREBUILD_FOLDER% ( + SET KOREBUILD_DOWNLOAD_ARGS= + IF NOT "%KOREBUILD_VERSION%"=="" ( + SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% + ) + + %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% +) + +"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* diff --git a/build.sh b/build.sh index da4e3fcd1c..7b5e25e3a8 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,18 @@ #!/usr/bin/env bash +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +repoFolder="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +buildFolder=.build +koreBuildFolder=$buildFolder/KoreBuild-dotnet + +nugetPath=$buildFolder/nuget.exe + if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild else @@ -11,33 +24,25 @@ else fi mkdir -p $cachedir nugetVersion=latest -cachePath=$cachedir/nuget.$nugetVersion.exe +cacheNuget=$cachedir/nuget.$nugetVersion.exe -url=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe +nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe -if test ! -f $cachePath; then - wget -O $cachePath $url 2>/dev/null || curl -o $cachePath --location $url /dev/null +if test ! -d $buildFolder; then + mkdir $buildFolder fi -if test ! -e .nuget; then - mkdir .nuget - cp $cachePath .nuget/nuget.exe +if test ! -f $nugetPath; then + if test ! -f $cacheNuget; then + wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null + fi + + cp $cacheNuget $nugetPath fi -if test ! -d packages/Sake; then - mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre - mono .nuget/nuget.exe install Sake -ExcludeVersion -Source https://www.nuget.org/api/v2/ -Out packages +if test ! -d $koreBuildFolder; then + mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre fi -if ! type dnvm > /dev/null 2>&1; then - source packages/KoreBuild/build/dnvm.sh -fi +source $koreBuildFolder/build/KoreBuild.sh -if ! type dnx > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then - dnvm install latest -runtime coreclr -alias default - dnvm install default -runtime mono -alias default -else - dnvm use default -runtime mono -fi - -mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" diff --git a/makefile.shade b/makefile.shade deleted file mode 100644 index cf2ed944c2..0000000000 --- a/makefile.shade +++ /dev/null @@ -1,12 +0,0 @@ - -var VERSION='0.1' -var FULL_VERSION='0.1' -var AUTHORS='Microsoft Open Technologies, Inc.' - -use-standard-lifecycle -k-standard-goals - -#xml-docs-test .clean .build-compile description='Check generated XML documentation files for errors' target='test' - k-xml-docs-test - - diff --git a/test/Microsoft.AspNet.Cors.Test/project.json b/test/Microsoft.AspNet.Cors.Test/project.json index e444740695..54ce584dfc 100644 --- a/test/Microsoft.AspNet.Cors.Test/project.json +++ b/test/Microsoft.AspNet.Cors.Test/project.json @@ -5,20 +5,27 @@ "Microsoft.AspNet.Cors": "6.0.0-*", "Microsoft.AspNet.TestHost": "1.0.0-*", "Microsoft.Extensions.Logging.Testing": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" + "xunit": "2.1.0" }, + "testRunner": "xunit", "commands": { "test": "xunit.runner.aspnet" }, "frameworks": { "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "", + "System.Threading.Tasks": "" + }, "dependencies": { "Moq": "4.2.1312.1622", + "xunit.runner.console": "2.1.0" } }, "dnxcore50": { "dependencies": { - "moq.netcore": "4.4.0-beta8" + "moq.netcore": "4.4.0-beta8", + "xunit.runner.aspnet": "2.0.0-aspnet-*" } } } From 1d572c11de5e1dc0c93bf7878c7a09356875ba82 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 14 Jan 2016 16:41:15 -0800 Subject: [PATCH 084/271] Updating build script --- build.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 7b5e25e3a8..263fb667a8 100755 --- a/build.sh +++ b/build.sh @@ -1,13 +1,5 @@ #!/usr/bin/env bash -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located -done -repoFolder="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - buildFolder=.build koreBuildFolder=$buildFolder/KoreBuild-dotnet @@ -42,7 +34,12 @@ fi if test ! -d $koreBuildFolder; then mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre + chmod +x $koreBuildFolder/build/KoreBuild.sh fi -source $koreBuildFolder/build/KoreBuild.sh +makeFile=makefile.shade +if [ ! -e $makeFile ]; then + makeFile=$koreBuildFolder/build/makefile.shade +fi +./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@" From 7ab5f67708c5a0449b9d22bae715d9aee04f5639 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 17 Jan 2016 17:22:39 -0800 Subject: [PATCH 085/271] Reacting to hosting rename --- .../CorsMiddlewareTests.cs | 16 ++++++++-------- .../CorsTestFixtureOfT.cs | 2 +- test/WebSites/CorsMiddlewareWebSite/Startup.cs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs index 2f755316d0..0e8e718232 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure public async Task CorsRequest_MatchPolicy_SetsResponseHeaders() { // Arrange - var appBuilder = new WebApplicationBuilder() + var hostBuilder = new WebHostBuilder() .Configure(app => { app.UseCors(builder => @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure }) .ConfigureServices(services => services.AddCors()); - using (var server = new TestServer(appBuilder)) + using (var server = new TestServer(hostBuilder)) { // Act // Actual request. @@ -63,7 +63,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure policy.Headers.Add("Header1"); policy.ExposedHeaders.Add("AllowedHeader"); - var appBuilder = new WebApplicationBuilder() + var hostBuilder = new WebHostBuilder() .Configure(app => { app.UseCors("customPolicy"); @@ -80,7 +80,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure }); }); - using (var server = new TestServer(appBuilder)) + using (var server = new TestServer(hostBuilder)) { // Act // Preflight request. @@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure public async Task PreFlightRequest_DoesNotMatchPolicy_DoesNotSetHeaders() { // Arrange - var appBuilder = new WebApplicationBuilder() + var hostBuilder = new WebHostBuilder() .Configure(app => { app.UseCors(builder => @@ -116,7 +116,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure }) .ConfigureServices(services => services.AddCors()); - using (var server = new TestServer(appBuilder)) + using (var server = new TestServer(hostBuilder)) { // Act // Preflight request. @@ -135,7 +135,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure public async Task CorsRequest_DoesNotMatchPolicy_DoesNotSetHeaders() { // Arrange - var appBuilder = new WebApplicationBuilder() + var hostBuilder = new WebHostBuilder() .Configure(app => { app.UseCors(builder => @@ -150,7 +150,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure }) .ConfigureServices(services => services.AddCors()); - using (var server = new TestServer(appBuilder)) + using (var server = new TestServer(hostBuilder)) { // Act // Actual request. diff --git a/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs b/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs index 1f83c6497d..f3c11d50b0 100644 --- a/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs +++ b/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Cors.Infrastructure public CorsTestFixture() { - var builder = new WebApplicationBuilder().UseStartup(); + var builder = new WebHostBuilder().UseStartup(); _server = new TestServer(builder); Client = _server.CreateClient(); diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index 08f828322c..436b8cd788 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -21,13 +21,13 @@ namespace CorsMiddlewareWebSite } public static void Main(string[] args) { - var application = new WebApplicationBuilder() - .UseConfiguration(WebApplicationConfiguration.GetDefault(args)) + var host = new WebHostBuilder() + .UseDefaultConfiguration(args) .UseIISPlatformHandlerUrl() .UseStartup() .Build(); - application.Run(); + host.Run(); } } } \ No newline at end of file From 28c03ef2e79c31d11c28af64339642262ffb2529 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:24:25 -0800 Subject: [PATCH 086/271] Rename AspNet 5 folders and files. See https://github.com/aspnet/Announcements/issues/144 for more information. --- .../CorsConstants.cs | 0 .../CorsMiddleware.cs | 0 .../CorsMiddlewareExtensions.cs | 0 .../CorsOptions.cs | 0 .../CorsPolicy.cs | 0 .../CorsPolicyBuilder.cs | 0 .../CorsResult.cs | 0 .../CorsService.cs | 0 .../CorsServiceCollectionExtensions.cs | 0 .../DefaultCorsPolicyProvider.cs | 0 .../DisableCorsAttribute.cs | 0 .../EnableCorsAttribute.cs | 0 .../ICorsPolicyProvider.cs | 0 .../ICorsService.cs | 0 .../IDisableCorsAttribute.cs | 0 .../IEnableCorsAttribute.cs | 0 .../Microsoft.AspNetCore.Cors.xproj} | 0 .../Properties/AssemblyInfo.cs | 0 .../Resources.Designer.cs | 0 .../Resources.resx | 0 .../project.json | 0 .../CorsMiddlewareFunctionalTest.cs | 0 .../CorsMiddlewareTests.cs | 0 .../CorsPolicyBuilderTests.cs | 0 .../CorsPolicyTests.cs | 0 .../CorsResultTests.cs | 0 .../CorsServiceTests.cs | 0 .../CorsTestFixtureOfT.cs | 0 .../DefaultCorsPolicyProviderTests.cs | 0 .../Microsoft.AspNetCore.Cors.Test.xproj} | 0 .../TestCorsOptions.cs | 0 .../project.json | 0 32 files changed, 0 insertions(+), 0 deletions(-) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsConstants.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsMiddleware.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsMiddlewareExtensions.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsOptions.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsPolicy.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsPolicyBuilder.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsResult.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsService.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/CorsServiceCollectionExtensions.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/DefaultCorsPolicyProvider.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/DisableCorsAttribute.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/EnableCorsAttribute.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/ICorsPolicyProvider.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/ICorsService.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/IDisableCorsAttribute.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/IEnableCorsAttribute.cs (100%) rename src/{Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj => Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj} (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/Properties/AssemblyInfo.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/Resources.Designer.cs (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/Resources.resx (100%) rename src/{Microsoft.AspNet.Cors => Microsoft.AspNetCore.Cors}/project.json (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/CorsMiddlewareFunctionalTest.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/CorsMiddlewareTests.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/CorsPolicyBuilderTests.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/CorsPolicyTests.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/CorsResultTests.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/CorsServiceTests.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/CorsTestFixtureOfT.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/DefaultCorsPolicyProviderTests.cs (100%) rename test/{Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj => Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj} (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/TestCorsOptions.cs (100%) rename test/{Microsoft.AspNet.Cors.Test => Microsoft.AspNetCore.Cors.Test}/project.json (100%) diff --git a/src/Microsoft.AspNet.Cors/CorsConstants.cs b/src/Microsoft.AspNetCore.Cors/CorsConstants.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsConstants.cs rename to src/Microsoft.AspNetCore.Cors/CorsConstants.cs diff --git a/src/Microsoft.AspNet.Cors/CorsMiddleware.cs b/src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsMiddleware.cs rename to src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs diff --git a/src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsMiddlewareExtensions.cs rename to src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs diff --git a/src/Microsoft.AspNet.Cors/CorsOptions.cs b/src/Microsoft.AspNetCore.Cors/CorsOptions.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsOptions.cs rename to src/Microsoft.AspNetCore.Cors/CorsOptions.cs diff --git a/src/Microsoft.AspNet.Cors/CorsPolicy.cs b/src/Microsoft.AspNetCore.Cors/CorsPolicy.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsPolicy.cs rename to src/Microsoft.AspNetCore.Cors/CorsPolicy.cs diff --git a/src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs b/src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsPolicyBuilder.cs rename to src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs diff --git a/src/Microsoft.AspNet.Cors/CorsResult.cs b/src/Microsoft.AspNetCore.Cors/CorsResult.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsResult.cs rename to src/Microsoft.AspNetCore.Cors/CorsResult.cs diff --git a/src/Microsoft.AspNet.Cors/CorsService.cs b/src/Microsoft.AspNetCore.Cors/CorsService.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsService.cs rename to src/Microsoft.AspNetCore.Cors/CorsService.cs diff --git a/src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/CorsServiceCollectionExtensions.cs rename to src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/DefaultCorsPolicyProvider.cs rename to src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs diff --git a/src/Microsoft.AspNet.Cors/DisableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/DisableCorsAttribute.cs rename to src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs diff --git a/src/Microsoft.AspNet.Cors/EnableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/EnableCorsAttribute.cs rename to src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs diff --git a/src/Microsoft.AspNet.Cors/ICorsPolicyProvider.cs b/src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/ICorsPolicyProvider.cs rename to src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs diff --git a/src/Microsoft.AspNet.Cors/ICorsService.cs b/src/Microsoft.AspNetCore.Cors/ICorsService.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/ICorsService.cs rename to src/Microsoft.AspNetCore.Cors/ICorsService.cs diff --git a/src/Microsoft.AspNet.Cors/IDisableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/IDisableCorsAttribute.cs rename to src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs diff --git a/src/Microsoft.AspNet.Cors/IEnableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/IEnableCorsAttribute.cs rename to src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs diff --git a/src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj similarity index 100% rename from src/Microsoft.AspNet.Cors/Microsoft.AspNet.Cors.xproj rename to src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj diff --git a/src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/Properties/AssemblyInfo.cs rename to src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNet.Cors/Resources.Designer.cs b/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNet.Cors/Resources.Designer.cs rename to src/Microsoft.AspNetCore.Cors/Resources.Designer.cs diff --git a/src/Microsoft.AspNet.Cors/Resources.resx b/src/Microsoft.AspNetCore.Cors/Resources.resx similarity index 100% rename from src/Microsoft.AspNet.Cors/Resources.resx rename to src/Microsoft.AspNetCore.Cors/Resources.resx diff --git a/src/Microsoft.AspNet.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json similarity index 100% rename from src/Microsoft.AspNet.Cors/project.json rename to src/Microsoft.AspNetCore.Cors/project.json diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareFunctionalTest.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/CorsMiddlewareFunctionalTest.cs rename to test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs diff --git a/test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/CorsMiddlewareTests.cs rename to test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs diff --git a/test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/CorsPolicyBuilderTests.cs rename to test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs diff --git a/test/Microsoft.AspNet.Cors.Test/CorsPolicyTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/CorsPolicyTests.cs rename to test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs diff --git a/test/Microsoft.AspNet.Cors.Test/CorsResultTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/CorsResultTests.cs rename to test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs diff --git a/test/Microsoft.AspNet.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/CorsServiceTests.cs rename to test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs diff --git a/test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/CorsTestFixtureOfT.cs rename to test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs diff --git a/test/Microsoft.AspNet.Cors.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/DefaultCorsPolicyProviderTests.cs rename to test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs diff --git a/test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/Microsoft.AspNet.Cors.Test.xproj rename to test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj diff --git a/test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs b/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/TestCorsOptions.cs rename to test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs diff --git a/test/Microsoft.AspNet.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json similarity index 100% rename from test/Microsoft.AspNet.Cors.Test/project.json rename to test/Microsoft.AspNetCore.Cors.Test/project.json From 8ed31de91774eda118cb5db73dfa6bb740b595e9 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:24:27 -0800 Subject: [PATCH 087/271] Rename AspNet 5 file contents. See https://github.com/aspnet/Announcements/issues/144 for more information. --- CORS.sln | 6 +++--- NuGetPackageVerifier.json | 2 +- src/Microsoft.AspNetCore.Cors/CorsConstants.cs | 2 +- src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs | 4 ++-- .../CorsMiddlewareExtensions.cs | 4 ++-- src/Microsoft.AspNetCore.Cors/CorsOptions.cs | 2 +- src/Microsoft.AspNetCore.Cors/CorsPolicy.cs | 2 +- src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs | 2 +- src/Microsoft.AspNetCore.Cors/CorsResult.cs | 2 +- src/Microsoft.AspNetCore.Cors/CorsService.cs | 4 ++-- .../CorsServiceCollectionExtensions.cs | 2 +- .../DefaultCorsPolicyProvider.cs | 4 ++-- .../DisableCorsAttribute.cs | 4 ++-- src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs | 4 ++-- src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs | 4 ++-- src/Microsoft.AspNetCore.Cors/ICorsService.cs | 4 ++-- .../IDisableCorsAttribute.cs | 2 +- .../IEnableCorsAttribute.cs | 2 +- src/Microsoft.AspNetCore.Cors/Resources.Designer.cs | 6 +++--- src/Microsoft.AspNetCore.Cors/project.json | 2 +- .../CorsMiddlewareFunctionalTest.cs | 2 +- .../CorsMiddlewareTests.cs | 12 ++++++------ .../CorsPolicyBuilderTests.cs | 2 +- .../CorsPolicyTests.cs | 2 +- .../CorsResultTests.cs | 2 +- .../CorsServiceTests.cs | 6 +++--- .../CorsTestFixtureOfT.cs | 8 ++++---- .../DefaultCorsPolicyProviderTests.cs | 4 ++-- .../TestCorsOptions.cs | 2 +- test/Microsoft.AspNetCore.Cors.Test/project.json | 4 ++-- .../WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs | 4 ++-- test/WebSites/CorsMiddlewareWebSite/Startup.cs | 4 ++-- test/WebSites/CorsMiddlewareWebSite/hosting.json | 4 ++-- test/WebSites/CorsMiddlewareWebSite/project.json | 8 ++++---- 34 files changed, 64 insertions(+), 64 deletions(-) diff --git a/CORS.sln b/CORS.sln index a0d8647301..9f3b2ba560 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.24720.0 @@ -12,9 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F32074C7-087C-46CC-A913-422BFD2D6E0A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors", "src\Microsoft.AspNet.Cors\Microsoft.AspNet.Cors.xproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Cors", "src\Microsoft.AspNetCore.Cors\Microsoft.AspNetCore.Cors.xproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Cors.Test", "test\Microsoft.AspNet.Cors.Test\Microsoft.AspNet.Cors.Test.xproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Cors.Test", "test\Microsoft.AspNetCore.Cors.Test\Microsoft.AspNetCore.Cors.Test.xproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{538380BF-0D4C-4E30-8F41-E75C4B1C01FA}" EndProject diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index 86ea14ef19..cd22de67e9 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -9,7 +9,7 @@ "StrictSemanticVersionValidationRule" ], "packages": { - "Microsoft.AspNet.Cors": { } + "Microsoft.AspNetCore.Cors": { } } }, "Default": { // Rules to run for packages not listed in any other set. diff --git a/src/Microsoft.AspNetCore.Cors/CorsConstants.cs b/src/Microsoft.AspNetCore.Cors/CorsConstants.cs index b777a80e6a..602f381ae5 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsConstants.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsConstants.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// CORS-related constants. diff --git a/src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs b/src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs index f8d3042277..cae0bbab1c 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs @@ -3,10 +3,10 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// An ASP.NET middleware for handling CORS. diff --git a/src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs index d3acfa0065..aae7ca4602 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Cors.Infrastructure; +using Microsoft.AspNetCore.Cors.Infrastructure; -namespace Microsoft.AspNet.Builder +namespace Microsoft.AspNetCore.Builder { /// /// The extensions for adding CORS middleware support. diff --git a/src/Microsoft.AspNetCore.Cors/CorsOptions.cs b/src/Microsoft.AspNetCore.Cors/CorsOptions.cs index bab1c2e68d..10b046000d 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsOptions.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsOptions.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// Provides programmatic configuration for Cors. diff --git a/src/Microsoft.AspNetCore.Cors/CorsPolicy.cs b/src/Microsoft.AspNetCore.Cors/CorsPolicy.cs index 3be8589b5b..b1fc25a939 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsPolicy.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsPolicy.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Text; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// Defines the policy for Cross-Origin requests based on the CORS specifications. diff --git a/src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs b/src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs index d018b92a68..ed20996e5e 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs @@ -4,7 +4,7 @@ using System; using System.Linq; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// Exposes methods to build a policy. diff --git a/src/Microsoft.AspNetCore.Cors/CorsResult.cs b/src/Microsoft.AspNetCore.Cors/CorsResult.cs index bb5e458dd3..99d38b9fd1 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsResult.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsResult.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Text; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// Results returned by . diff --git a/src/Microsoft.AspNetCore.Cors/CorsService.cs b/src/Microsoft.AspNetCore.Cors/CorsService.cs index 5ec194e575..7e45c6b7ce 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsService.cs @@ -5,11 +5,11 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// Default implementation of . diff --git a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs index 3a683d03d2..6bb7c79d85 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Cors.Infrastructure; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection diff --git a/src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs index b0887a9315..4841d60f75 100644 --- a/src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs @@ -3,10 +3,10 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// public class DefaultCorsPolicyProvider : ICorsPolicyProvider diff --git a/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs index 5727b98d52..ab4c755066 100644 --- a/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs +++ b/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Cors.Infrastructure; +using Microsoft.AspNetCore.Cors.Infrastructure; -namespace Microsoft.AspNet.Cors +namespace Microsoft.AspNetCore.Cors { /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] diff --git a/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs index 23b2b5443f..34bd269d96 100644 --- a/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs +++ b/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Cors.Infrastructure; +using Microsoft.AspNetCore.Cors.Infrastructure; -namespace Microsoft.AspNet.Cors +namespace Microsoft.AspNetCore.Cors { /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] diff --git a/src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs b/src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs index a69df524e9..7785e3de9c 100644 --- a/src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs +++ b/src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// A type which can provide a for a particular . diff --git a/src/Microsoft.AspNetCore.Cors/ICorsService.cs b/src/Microsoft.AspNetCore.Cors/ICorsService.cs index faabc5867c..ab8176a961 100644 --- a/src/Microsoft.AspNetCore.Cors/ICorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/ICorsService.cs @@ -1,9 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// A type which can evaluate a policy for a particular . diff --git a/src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs index 63e2e5c5a9..1e69ba3da3 100644 --- a/src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs +++ b/src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// An interface which can be used to identify a type which provides metdata to disable cors for a resource. diff --git a/src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs index 724f3a0e0f..c58e2a1d96 100644 --- a/src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs +++ b/src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// An interface which can be used to identify a type which provides metadata needed for enabling CORS support. diff --git a/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs b/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs index 72b39342e9..0bc258074c 100644 --- a/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs +++ b/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.AspNet.Cors { +namespace Microsoft.AspNetCore.Cors { using System; using System.Reflection; @@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Cors { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.Cors.Resources", typeof(Resources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNetCore.Cors.Resources", typeof(Resources).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index 17732ed627..7127952712 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -9,7 +9,7 @@ "keyFile": "../../tools/Key.snk" }, "dependencies": { - "Microsoft.AspNet.Http.Extensions": "1.0.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", "Microsoft.Extensions.Options": "1.0.0-*" diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs index 6be83fed21..008a4926d9 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs @@ -7,7 +7,7 @@ using System.Net.Http; using System.Threading.Tasks; using Xunit; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsMiddlewareFunctionalTests : IClassFixture> { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs index 0e8e718232..93e5ace09b 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs @@ -4,16 +4,16 @@ using System.Linq; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Internal; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Internal; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Moq; using Xunit; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsMiddlewareTests { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs index 5f9f6fe737..0ee3b7e524 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Linq; using Xunit; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsPolicyBuilderTests { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs index a4b1d772a3..4264164ed0 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs @@ -4,7 +4,7 @@ using System; using Xunit; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsPolicyTest { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs index 949c10854a..bc6e4a2d3a 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs @@ -4,7 +4,7 @@ using System; using Xunit; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsResultTest { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index 1efc473407..a14c1548a7 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Internal; using Xunit; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsServiceTests { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs index f3c11d50b0..aa698c62f2 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs @@ -1,12 +1,12 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Net.Http; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.TestHost; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsTestFixture : IDisposable where TStartup : class diff --git a/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs index 83a08bec24..1fc86b6d06 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNetCore.Http.Internal; using Xunit; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class DefaultPolicyProviderTests { diff --git a/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs b/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs index e7630f9a8f..782ebb2db7 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Options; -namespace Microsoft.AspNet.Cors.Infrastructure +namespace Microsoft.AspNetCore.Cors.Infrastructure { public class TestCorsOptions : IOptions { diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 54ce584dfc..9247927800 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -2,8 +2,8 @@ "version": "1.0.0-*", "dependencies": { "CorsMiddlewareWebSite": "1.0.0-*", - "Microsoft.AspNet.Cors": "6.0.0-*", - "Microsoft.AspNet.TestHost": "1.0.0-*", + "Microsoft.AspNetCore.Cors": "6.0.0-*", + "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.Logging.Testing": "1.0.0-*", "xunit": "2.1.0" }, diff --git a/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs b/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs index fbc07dacde..9036b33bf6 100644 --- a/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs +++ b/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs @@ -1,10 +1,10 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Text; using System.Threading.Tasks; -using Microsoft.AspNet.Http; +using Microsoft.AspNetCore.Http; namespace CorsMiddlewareWebSite { diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index 436b8cd788..984809db08 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -1,8 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; namespace CorsMiddlewareWebSite diff --git a/test/WebSites/CorsMiddlewareWebSite/hosting.json b/test/WebSites/CorsMiddlewareWebSite/hosting.json index f8ef14574d..6a93dbafa8 100644 --- a/test/WebSites/CorsMiddlewareWebSite/hosting.json +++ b/test/WebSites/CorsMiddlewareWebSite/hosting.json @@ -1,3 +1,3 @@ -{ - "server": "Microsoft.AspNet.Server.Kestrel" +{ + "server": "Microsoft.AspNetCore.Server.Kestrel" } diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 2214e8fa01..c83f576ed2 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -1,4 +1,4 @@ -{ +{ "compilationOptions": { "emitEntryPoint": true }, @@ -6,9 +6,9 @@ "web": "CorsMiddlewareWebSite" }, "dependencies": { - "Microsoft.AspNet.Cors": "6.0.0-*", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*" + "Microsoft.AspNetCore.Cors": "6.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, "frameworks": { "dnx451": { }, From d858078d6948e7954431a906e3c0ef67b492aaec Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 22 Jan 2016 12:28:37 -0800 Subject: [PATCH 088/271] Update ASP.NET 5 versions for ASP.NET Core. See https://github.com/aspnet/Announcements/issues/144 for more information. --- src/Microsoft.AspNetCore.Cors/project.json | 2 +- test/Microsoft.AspNetCore.Cors.Test/project.json | 2 +- test/WebSites/CorsMiddlewareWebSite/project.json | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index 7127952712..3390787ad5 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -1,5 +1,5 @@ { - "version": "6.0.0-*", + "version": "1.0.0-*", "repository": { "type": "git", "url": "https://github.com/aspnet/cors" diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 9247927800..b2feca8832 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { "CorsMiddlewareWebSite": "1.0.0-*", - "Microsoft.AspNetCore.Cors": "6.0.0-*", + "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.Logging.Testing": "1.0.0-*", "xunit": "2.1.0" diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index c83f576ed2..5d9595957c 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -6,12 +6,12 @@ "web": "CorsMiddlewareWebSite" }, "dependencies": { - "Microsoft.AspNetCore.Cors": "6.0.0-*", + "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "dnx451": {}, + "dnxcore50": {} } } \ No newline at end of file From 1d22eed129083294c60b20a9ea06e8f4c0fd0c3d Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 2 Feb 2016 18:37:48 -0800 Subject: [PATCH 089/271] Updating to new CLI --- test/Microsoft.AspNetCore.Cors.Test/project.json | 4 +++- test/WebSites/CorsMiddlewareWebSite/project.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index b2feca8832..05f1dabd05 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -5,6 +5,7 @@ "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.Logging.Testing": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "testRunner": "xunit", @@ -26,7 +27,8 @@ "dependencies": { "moq.netcore": "4.4.0-beta8", "xunit.runner.aspnet": "2.0.0-aspnet-*" - } + }, + "imports": "portable-net451+win8" } } } \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 5d9595957c..755cd4507c 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -8,7 +8,8 @@ "dependencies": { "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*" }, "frameworks": { "dnx451": {}, From 72f8b04a33363bb7ec3ca1e6b8ad939510530b36 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Tue, 9 Feb 2016 21:38:43 -0800 Subject: [PATCH 090/271] Enable tests to run using dotnet xunit runner --- .../Microsoft.AspNetCore.Cors.Test/project.json | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 05f1dabd05..bfb8b11dc6 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -9,10 +9,14 @@ "xunit": "2.1.0" }, "testRunner": "xunit", - "commands": { - "test": "xunit.runner.aspnet" - }, "frameworks": { + "dnxcore50": { + "dependencies": { + "dotnet-test-xunit": "1.0.0-dev-*", + "moq.netcore": "4.4.0-beta8" + }, + "imports": "portable-net451+win8" + }, "dnx451": { "frameworkAssemblies": { "System.Runtime": "", @@ -22,13 +26,6 @@ "Moq": "4.2.1312.1622", "xunit.runner.console": "2.1.0" } - }, - "dnxcore50": { - "dependencies": { - "moq.netcore": "4.4.0-beta8", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "imports": "portable-net451+win8" } } } \ No newline at end of file From 80ea4b90353b6686a2cd21ef936b05e76e87144a Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Wed, 17 Feb 2016 15:40:13 -0800 Subject: [PATCH 091/271] Enabled xml doc generation --- NuGetPackageVerifier.json | 14 ++------------ src/Microsoft.AspNetCore.Cors/CorsService.cs | 2 +- src/Microsoft.AspNetCore.Cors/project.json | 4 +++- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index cd22de67e9..bf2544859f 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,12 +1,7 @@ { "adx": { // Packages written by the ADX team and that ship on NuGet.org "rules": [ - "AssemblyHasDocumentFileRule", - "AssemblyHasVersionAttributesRule", - "AssemblyHasServicingAttributeRule", - "AssemblyHasNeutralResourcesLanguageAttributeRule", - "SatellitePackageRule", - "StrictSemanticVersionValidationRule" + "AdxVerificationCompositeRule" ], "packages": { "Microsoft.AspNetCore.Cors": { } @@ -14,12 +9,7 @@ }, "Default": { // Rules to run for packages not listed in any other set. "rules": [ - "AssemblyHasDocumentFileRule", - "AssemblyHasVersionAttributesRule", - "AssemblyHasServicingAttributeRule", - "AssemblyHasNeutralResourcesLanguageAttributeRule", - "SatellitePackageRule", - "StrictSemanticVersionValidationRule" + "DefaultCompositeRule" ] } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/CorsService.cs b/src/Microsoft.AspNetCore.Cors/CorsService.cs index 7e45c6b7ce..3f792e72af 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsService.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// Looks up a policy using the and then evaluates the policy using the passed in /// . /// - /// + /// /// /// A which contains the result of policy evaluation and can be /// used by the caller to set appropriate response headers. diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index 3390787ad5..c25d5452dc 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -6,7 +6,9 @@ }, "compilationOptions": { "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" + "keyFile": "../../tools/Key.snk", + "nowarn": [ "CS1591" ], + "xmlDoc": true }, "dependencies": { "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", From 24ce2c9cdf29352f5e622e2d2b10d11c3e881478 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 24 Feb 2016 12:33:47 -0800 Subject: [PATCH 092/271] Update `build.cmd` to match latest template - aspnet/Universe#347 - `%KOREBUILD_VERSION%` doesn't work without this fix --- build.cmd | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index ebb619e737..95b049cf63 100644 --- a/build.cmd +++ b/build.cmd @@ -2,7 +2,7 @@ SETLOCAL SET REPO_FOLDER=%~dp0 -CD %REPO_FOLDER% +CD "%REPO_FOLDER%" SET BUILD_FOLDER=.build SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet @@ -28,12 +28,11 @@ IF NOT EXIST %NUGET_PATH% ( copy %CACHED_NUGET% %NUGET_PATH% > nul ) +SET KOREBUILD_DOWNLOAD_ARGS= +IF NOT "%KOREBUILD_VERSION%"=="" ( + SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% +) IF NOT EXIST %KOREBUILD_FOLDER% ( - SET KOREBUILD_DOWNLOAD_ARGS= - IF NOT "%KOREBUILD_VERSION%"=="" ( - SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% - ) - %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% ) From 342617414bf38fc348fa3781336aae450370d74f Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Sat, 27 Feb 2016 12:51:13 -0800 Subject: [PATCH 093/271] Update the build scripts --- build.cmd | 41 ++----------------------------------- build.ps1 | 36 +++++++++++++++++++++++++++++++++ build.sh | 60 +++++++++++++++++++++++-------------------------------- 3 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 build.ps1 diff --git a/build.cmd b/build.cmd index 95b049cf63..2fa024b15e 100644 --- a/build.cmd +++ b/build.cmd @@ -1,39 +1,2 @@ -@ECHO off -SETLOCAL - -SET REPO_FOLDER=%~dp0 -CD "%REPO_FOLDER%" - -SET BUILD_FOLDER=.build -SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet -SET KOREBUILD_VERSION= - -SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe -SET NUGET_VERSION=latest -SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe - -IF NOT EXIST %BUILD_FOLDER% ( - md %BUILD_FOLDER% -) - -IF NOT EXIST %NUGET_PATH% ( - IF NOT EXIST %CACHED_NUGET% ( - echo Downloading latest version of NuGet.exe... - IF NOT EXIST %LocalAppData%\NuGet ( - md %LocalAppData%\NuGet - ) - @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'" - ) - - copy %CACHED_NUGET% %NUGET_PATH% > nul -) - -SET KOREBUILD_DOWNLOAD_ARGS= -IF NOT "%KOREBUILD_VERSION%"=="" ( - SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION% -) -IF NOT EXIST %KOREBUILD_FOLDER% ( - %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS% -) - -"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %* +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*" \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..4fd24a30d5 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,36 @@ +cd $PSScriptRoot + +$repoFolder = $PSScriptRoot +$env:REPO_FOLDER = $repoFolder + +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if ($env:KOREBUILD_ZIP) +{ + $koreBuildZip=$env:KOREBUILD_ZIP +} + +$buildFolder = ".build" +$buildFile="$buildFolder\KoreBuild.ps1" + +if (!(Test-Path $buildFolder)) { + Write-Host "Downloading KoreBuild from $koreBuildZip" + + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() + New-Item -Path "$tempFolder" -Type directory | Out-Null + + $localZipFile="$tempFolder\korebuild.zip" + + Invoke-WebRequest $koreBuildZip -OutFile $localZipFile + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) + + New-Item -Path "$buildFolder" -Type directory | Out-Null + copy-item "$tempFolder\**\build\*" $buildFolder -Recurse + + # Cleanup + if (Test-Path $tempFolder) { + Remove-Item -Recurse -Force $tempFolder + } +} + +&"$buildFile" $args \ No newline at end of file diff --git a/build.sh b/build.sh index 263fb667a8..79638d06b6 100755 --- a/build.sh +++ b/build.sh @@ -1,45 +1,35 @@ #!/usr/bin/env bash +repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $repoFolder -buildFolder=.build -koreBuildFolder=$buildFolder/KoreBuild-dotnet - -nugetPath=$buildFolder/nuget.exe - -if test `uname` = Darwin; then - cachedir=~/Library/Caches/KBuild -else - if [ -z $XDG_DATA_HOME ]; then - cachedir=$HOME/.local/share - else - cachedir=$XDG_DATA_HOME; - fi +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +if [ ! -z $KOREBUILD_ZIP ]; then + koreBuildZip=$KOREBUILD_ZIP fi -mkdir -p $cachedir -nugetVersion=latest -cacheNuget=$cachedir/nuget.$nugetVersion.exe -nugetUrl=https://dist.nuget.org/win-x86-commandline/$nugetVersion/nuget.exe +buildFolder=".build" +buildFile="$buildFolder/KoreBuild.sh" if test ! -d $buildFolder; then + echo "Downloading KoreBuild from $koreBuildZip" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" + mkdir $tempFolder + + localZipFile="$tempFolder/korebuild.zip" + + wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null + unzip -q -d $tempFolder $localZipFile + mkdir $buildFolder -fi - -if test ! -f $nugetPath; then - if test ! -f $cacheNuget; then - wget -O $cacheNuget $nugetUrl 2>/dev/null || curl -o $cacheNuget --location $nugetUrl /dev/null + cp -r $tempFolder/**/build/** $buildFolder + + chmod +x $buildFile + + # Cleanup + if test ! -d $tempFolder; then + rm -rf $tempFolder fi - - cp $cacheNuget $nugetPath fi -if test ! -d $koreBuildFolder; then - mono $nugetPath install KoreBuild-dotnet -ExcludeVersion -o $buildFolder -nocache -pre - chmod +x $koreBuildFolder/build/KoreBuild.sh -fi - -makeFile=makefile.shade -if [ ! -e $makeFile ]; then - makeFile=$koreBuildFolder/build/makefile.shade -fi - -./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@" +$buildFile -r $repoFolder "$@" From 12eeed038f849539e0221b43873a8127a6202f21 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Sun, 28 Feb 2016 10:12:17 -0800 Subject: [PATCH 094/271] Return the error code from build.cmd --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index 2fa024b15e..7d4894cb4a 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file From 7ed26eabf7f61540dd7a8f8fc82cb2f57d4935d8 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Sun, 28 Feb 2016 15:53:51 -0800 Subject: [PATCH 095/271] Move files to the right folder --- .../{ => Infrastructure}/CorsConstants.cs | 0 .../{ => Infrastructure}/CorsMiddleware.cs | 0 .../{ => Infrastructure}/CorsMiddlewareExtensions.cs | 0 src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsOptions.cs | 0 src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsPolicy.cs | 0 .../{ => Infrastructure}/CorsPolicyBuilder.cs | 0 src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsResult.cs | 0 src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsService.cs | 0 .../{ => Infrastructure}/DefaultCorsPolicyProvider.cs | 0 .../{ => Infrastructure}/ICorsPolicyProvider.cs | 0 .../{ => Infrastructure}/ICorsService.cs | 0 .../{ => Infrastructure}/IDisableCorsAttribute.cs | 0 .../{ => Infrastructure}/IEnableCorsAttribute.cs | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsConstants.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsMiddleware.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsMiddlewareExtensions.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsOptions.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsPolicy.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsPolicyBuilder.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsResult.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/CorsService.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/DefaultCorsPolicyProvider.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/ICorsPolicyProvider.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/ICorsService.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/IDisableCorsAttribute.cs (100%) rename src/Microsoft.AspNetCore.Cors/{ => Infrastructure}/IEnableCorsAttribute.cs (100%) diff --git a/src/Microsoft.AspNetCore.Cors/CorsConstants.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsConstants.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs diff --git a/src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsMiddleware.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs diff --git a/src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsMiddlewareExtensions.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs diff --git a/src/Microsoft.AspNetCore.Cors/CorsOptions.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsOptions.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs diff --git a/src/Microsoft.AspNetCore.Cors/CorsPolicy.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsPolicy.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs diff --git a/src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsPolicyBuilder.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs diff --git a/src/Microsoft.AspNetCore.Cors/CorsResult.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsResult.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsResult.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsResult.cs diff --git a/src/Microsoft.AspNetCore.Cors/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsService.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs diff --git a/src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/DefaultCorsPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/DefaultCorsPolicyProvider.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/DefaultCorsPolicyProvider.cs diff --git a/src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/ICorsPolicyProvider.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsPolicyProvider.cs diff --git a/src/Microsoft.AspNetCore.Cors/ICorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsService.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/ICorsService.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsService.cs diff --git a/src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/IDisableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/IDisableCorsAttribute.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/IDisableCorsAttribute.cs diff --git a/src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/IEnableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/IEnableCorsAttribute.cs rename to src/Microsoft.AspNetCore.Cors/Infrastructure/IEnableCorsAttribute.cs From f29649c749aaad1b59c80e97d77dc34871889603 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Sun, 28 Feb 2016 15:53:57 -0800 Subject: [PATCH 096/271] Fix package metadata --- README.md | 3 ++- src/Microsoft.AspNetCore.Cors/project.json | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5ed1513680..795d311da9 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,5 @@ AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/yi0m8evjtg107 Travis: [![Travis](https://travis-ci.org/aspnet/CORS.svg?branch=dev)](https://travis-ci.org/aspnet/CORS) CORS repository includes the core implementation for CORS policy, utilized by the CORS middleware and MVC. -This project is part of ASP.NET 5. You can find samples, documentation and getting started instructions for ASP.NET 5 at the [Home](https://github.com/aspnet/home) repo. + +This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index c25d5452dc..b3060e9135 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -4,6 +4,9 @@ "type": "git", "url": "https://github.com/aspnet/cors" }, + "description": "CORS middleware and policy for ASP.NET Core to enable cross-origin resource sharing.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Cors.DisableCorsAttribute\r\nMicrosoft.AspNetCore.Cors.EnableCorsAttribute", + "tags": [ "aspnetcore", "cors" ], + "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", @@ -17,7 +20,7 @@ "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { - "net451": {}, - "dotnet5.4": {} + "net451": { }, + "dotnet5.4": { } } } \ No newline at end of file From 140cdfb2d2b0f5ff2bec11d70e956850d5be7488 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Thu, 25 Feb 2016 11:06:47 -0800 Subject: [PATCH 097/271] Make ServiceCollectionExtensions consistent --- .../CorsServiceCollectionExtensions.cs | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs index 6bb7c79d85..a37681f8d4 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs @@ -8,49 +8,46 @@ using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection { /// - /// The extensions for enabling CORS support. + /// Extension methods for setting up cross-origin resource sharing services in an . /// public static class CorsServiceCollectionExtensions { /// - /// Add services needed to support CORS to the given . + /// Adds cross-origin resource sharing services to the specified . /// - /// The service collection to which CORS services are added. - /// The updated . - public static IServiceCollection AddCors(this IServiceCollection serviceCollection) + /// The to add services to. + public static void AddCors(this IServiceCollection services) { - if (serviceCollection == null) + if (services == null) { - throw new ArgumentNullException(nameof(serviceCollection)); + throw new ArgumentNullException(nameof(services)); } - - serviceCollection.TryAdd(ServiceDescriptor.Transient()); - serviceCollection.TryAdd(ServiceDescriptor.Transient()); - return serviceCollection; + + services.AddOptions(); + + services.TryAdd(ServiceDescriptor.Transient()); + services.TryAdd(ServiceDescriptor.Transient()); } /// - /// Add services needed to support CORS to the given . + /// Adds cross-origin resource sharing services to the specified . /// - /// The service collection to which CORS services are added. - /// A delegate which is run to configure the services. - /// The updated . - public static IServiceCollection AddCors( - this IServiceCollection serviceCollection, - Action configure) + /// The to add services to. + /// An to configure the provided . + public static void AddCors(this IServiceCollection services, Action setupAction) { - if (serviceCollection == null) + if (services == null) { - throw new ArgumentNullException(nameof(serviceCollection)); + throw new ArgumentNullException(nameof(services)); } - if (configure == null) + if (setupAction == null) { - throw new ArgumentNullException(nameof(configure)); + throw new ArgumentNullException(nameof(setupAction)); } - serviceCollection.Configure(configure); - return serviceCollection.AddCors(); + services.AddCors(); + services.Configure(setupAction); } } } \ No newline at end of file From d237c78278cb6f5aea86769764040129218b8633 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 1 Mar 2016 13:36:40 -0800 Subject: [PATCH 098/271] Transition to netstandard. - dotnet5.X => netstandard1.y (where y = x-1). - DNXCore50 => netstandardapp1.5. - Applied the same changes to ifdefs. --- src/Microsoft.AspNetCore.Cors/project.json | 18 +++++++++++++----- .../project.json | 7 +++++-- .../CorsMiddlewareWebSite/project.json | 6 +++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index b3060e9135..17ea4c6b4e 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -5,12 +5,16 @@ "url": "https://github.com/aspnet/cors" }, "description": "CORS middleware and policy for ASP.NET Core to enable cross-origin resource sharing.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Cors.DisableCorsAttribute\r\nMicrosoft.AspNetCore.Cors.EnableCorsAttribute", - "tags": [ "aspnetcore", "cors" ], - + "tags": [ + "aspnetcore", + "cors" + ], "compilationOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", - "nowarn": [ "CS1591" ], + "nowarn": [ + "CS1591" + ], "xmlDoc": true }, "dependencies": { @@ -20,7 +24,11 @@ "Microsoft.Extensions.Options": "1.0.0-*" }, "frameworks": { - "net451": { }, - "dotnet5.4": { } + "net451": {}, + "netstandard1.3": { + "imports": [ + "dotnet5.4" + ] + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index bfb8b11dc6..c06dce53ae 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -10,12 +10,15 @@ }, "testRunner": "xunit", "frameworks": { - "dnxcore50": { + "netstandardapp1.5": { "dependencies": { "dotnet-test-xunit": "1.0.0-dev-*", "moq.netcore": "4.4.0-beta8" }, - "imports": "portable-net451+win8" + "imports": [ + "dnxcore50", + "portable-net451+win8" + ] }, "dnx451": { "frameworkAssemblies": { diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 755cd4507c..5ec542644c 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -13,6 +13,10 @@ }, "frameworks": { "dnx451": {}, - "dnxcore50": {} + "netstandardapp1.5": { + "imports": [ + "dnxcore50" + ] + } } } \ No newline at end of file From 36adff25e4c3be60d5ec5d32349364f21adb3e1b Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 2 Mar 2016 16:35:52 -0800 Subject: [PATCH 099/271] Remove project name from output path - aspnet/Coherence-Signed#187 - remove `` settings but maintain other unique aspects e.g. `` - in a few cases, standardize on VS version `14.0` and not something more specific --- src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj | 2 +- .../Microsoft.AspNetCore.Cors.Test.xproj | 2 +- test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj index 19173e3a64..c8239c9cfe 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj @@ -8,7 +8,7 @@ 41349fcd-d1c4-47a6-82d0-d16d00a8d59d ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj index 3dc6401fe9..3851945c08 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj @@ -8,7 +8,7 @@ f05be96f-f869-4408-a480-96935b4835ee ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\artifacts\bin\ 2.0 diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj index 7e7d95f9c7..a572a9933f 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj @@ -8,7 +8,7 @@ b42d4844-fff8-4ec2-88d1-3ae95234d9eb ..\..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\..\artifacts\bin\$(MSBuildProjectName)\ + ..\..\..\artifacts\bin\ 2.0 From 553e2e3c01b63c2588943d92aa4e8cc5a3444417 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 3 Mar 2016 17:33:04 -0800 Subject: [PATCH 100/271] Added Company, Copyright and Product attributes to AssemblyInfo --- src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs index 3f4a3b62e0..e3ae91c58b 100644 --- a/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs @@ -6,3 +6,6 @@ using System.Resources; [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: NeutralResourcesLanguage("en-US")] +[assembly: AssemblyCompany("Microsoft Corporation.")] +[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] +[assembly: AssemblyProduct("Microsoft ASP.NET Core")] From ce80c50425c86f532784c566ba25726f0505f324 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Mon, 7 Mar 2016 20:55:02 -0800 Subject: [PATCH 101/271] Update the build scripts to the latest version --- build.ps1 | 33 ++++++++++++++++++++++++++++++++- build.sh | 15 +++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index 4fd24a30d5..8f2f99691a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,33 @@ +$ErrorActionPreference = "Stop" + +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +{ + while($true) + { + try + { + Invoke-WebRequest $url -OutFile $downloadLocation + break + } + catch + { + $exceptionMessage = $_.Exception.Message + Write-Host "Failed to download '$url': $exceptionMessage" + if ($retries -gt 0) { + $retries-- + Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" + Start-Sleep -Seconds 10 + + } + else + { + $exception = $_.Exception + throw $exception + } + } + } +} + cd $PSScriptRoot $repoFolder = $PSScriptRoot @@ -20,7 +50,8 @@ if (!(Test-Path $buildFolder)) { $localZipFile="$tempFolder\korebuild.zip" - Invoke-WebRequest $koreBuildZip -OutFile $localZipFile + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 + Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) diff --git a/build.sh b/build.sh index 79638d06b6..f4208100eb 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,18 @@ if test ! -d $buildFolder; then localZipFile="$tempFolder/korebuild.zip" - wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null + retries=6 + until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) + do + echo "Failed to download '$koreBuildZip'" + if [ "$retries" -le 0 ]; then + exit 1 + fi + retries=$((retries - 1)) + echo "Waiting 10 seconds before retrying. Retries left: $retries" + sleep 10s + done + unzip -q -d $tempFolder $localZipFile mkdir $buildFolder @@ -32,4 +43,4 @@ if test ! -d $buildFolder; then fi fi -$buildFile -r $repoFolder "$@" +$buildFile -r $repoFolder "$@" \ No newline at end of file From 73014d2fa1d6a417f7d32bab1fe332d71da12623 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 9 Mar 2016 16:35:10 -0800 Subject: [PATCH 102/271] Limit the branches that build on our public CI. [ci skip] --- .travis.yml | 6 ++++++ appveyor.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index bf811dc26a..dd4686f39c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,11 @@ os: - linux - osx osx_image: xcode7.1 +branches: + only: + - master + - release + - dev + - /^(.*\\/)?ci-.*$/ script: - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 3fab83e134..c6d5f7d997 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,11 @@ init: - git config --global core.autocrlf true +branches: + only: + - master + - release + - dev + - /^(.*\\/)?ci-.*$/ build_script: - build.cmd verify clone_depth: 1 From f99a150dd3b7f8fc5a7a12775ec9e1674aa62278 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 9 Mar 2016 16:46:54 -0800 Subject: [PATCH 103/271] Target net451 so functional tests execute with xunit runner --- test/Microsoft.AspNetCore.Cors.Test/project.json | 9 ++------- test/WebSites/CorsMiddlewareWebSite/project.json | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index c06dce53ae..6430e9aaf3 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -20,14 +20,9 @@ "portable-net451+win8" ] }, - "dnx451": { - "frameworkAssemblies": { - "System.Runtime": "", - "System.Threading.Tasks": "" - }, + "net451": { "dependencies": { - "Moq": "4.2.1312.1622", - "xunit.runner.console": "2.1.0" + "Moq": "4.2.1312.1622" } } } diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 5ec542644c..d1a488a3d5 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -12,7 +12,7 @@ "Microsoft.NETCore.Platforms": "1.0.1-*" }, "frameworks": { - "dnx451": {}, + "net451": {}, "netstandardapp1.5": { "imports": [ "dnxcore50" From 72134d7d467a7a9b924473601b7492d83db83cf3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 9 Mar 2016 17:44:48 -0800 Subject: [PATCH 104/271] Fix backslashes in yml config. [ci skip] --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd4686f39c..df22f7a880 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,6 @@ branches: - master - release - dev - - /^(.*\\/)?ci-.*$/ + - /^(.*\/)?ci-.*$/ script: - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index c6d5f7d997..b9a9bcd1e6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ branches: - master - release - dev - - /^(.*\\/)?ci-.*$/ + - /^(.*\/)?ci-.*$/ build_script: - build.cmd verify clone_depth: 1 From a81f417b5e0c14ea9454942d589a4fb9696a31f3 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 22 Mar 2016 12:02:01 -0700 Subject: [PATCH 105/271] React to Hosting changes --- test/WebSites/CorsMiddlewareWebSite/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index 984809db08..33768e1858 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -22,7 +22,7 @@ namespace CorsMiddlewareWebSite public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultConfiguration(args) + .UseDefaultHostingConfiguration(args) .UseIISPlatformHandlerUrl() .UseStartup() .Build(); From 866f155bc68929a81d90a1a17057e05ffd5edafd Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 25 Mar 2016 01:16:32 -0700 Subject: [PATCH 106/271] Fixed the build --- test/Microsoft.AspNetCore.Cors.Test/project.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 6430e9aaf3..452981a962 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -5,7 +5,6 @@ "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", "Microsoft.Extensions.Logging.Testing": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "xunit": "2.1.0" }, "testRunner": "xunit", @@ -13,7 +12,9 @@ "netstandardapp1.5": { "dependencies": { "dotnet-test-xunit": "1.0.0-dev-*", - "moq.netcore": "4.4.0-beta8" + "moq.netcore": "4.4.0-beta8", + "NETStandard.Library": "1.5.0-*", + "System.Diagnostics.Process": "4.1.0-*" }, "imports": [ "dnxcore50", From e68df4611e66ab7a2c0585a1e19cf617f2c610ff Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 28 Mar 2016 15:08:58 -0700 Subject: [PATCH 107/271] Return IServiceCollection from AddCors extension methods --- .../CorsServiceCollectionExtensions.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs index a37681f8d4..430621d2fd 100644 --- a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs @@ -16,7 +16,8 @@ namespace Microsoft.Extensions.DependencyInjection /// Adds cross-origin resource sharing services to the specified . /// /// The to add services to. - public static void AddCors(this IServiceCollection services) + /// The so that additional calls can be chained. + public static IServiceCollection AddCors(this IServiceCollection services) { if (services == null) { @@ -27,6 +28,8 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAdd(ServiceDescriptor.Transient()); services.TryAdd(ServiceDescriptor.Transient()); + + return services; } /// @@ -34,7 +37,8 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The to add services to. /// An to configure the provided . - public static void AddCors(this IServiceCollection services, Action setupAction) + /// The so that additional calls can be chained. + public static IServiceCollection AddCors(this IServiceCollection services, Action setupAction) { if (services == null) { @@ -48,6 +52,8 @@ namespace Microsoft.Extensions.DependencyInjection services.AddCors(); services.Configure(setupAction); + + return services; } } } \ No newline at end of file From bc84437881e3abbb74fca04aac017a356f0c05cf Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 30 Mar 2016 14:00:57 -0700 Subject: [PATCH 108/271] Webhook notifications --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index df22f7a880..6a6d22bdfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,10 @@ branches: - dev - /^(.*\/)?ci-.*$/ script: - - ./build.sh verify \ No newline at end of file + - ./build.sh verify +notifications: + webhooks: + secure: "V+ynhkZnRWn9VemSgBKI6KB5WxSE/SuoIKFnBQFb/1O0r15aac4/VyzuRdTK8V29OxdI1vK0J3UET2c2v2Q2IusFc4rCHGcRIobjHq+YW8944betuYfHkpVgniHofaGLgJH8gdlZv4elDdVHWKndYIGTaBU8+dO8ktp+9BFGYhs=" + on_success: always + on_failure: always + on_start: always \ No newline at end of file From 20295109999f49bbe8331ebb90ebfd22d322634c Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 30 Mar 2016 16:21:56 -0700 Subject: [PATCH 109/271] Remove hosting.json --- test/WebSites/CorsMiddlewareWebSite/Startup.cs | 1 + test/WebSites/CorsMiddlewareWebSite/hosting.json | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 test/WebSites/CorsMiddlewareWebSite/hosting.json diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index 33768e1858..cc4770292f 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -23,6 +23,7 @@ namespace CorsMiddlewareWebSite { var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) + .UseKestrel() .UseIISPlatformHandlerUrl() .UseStartup() .Build(); diff --git a/test/WebSites/CorsMiddlewareWebSite/hosting.json b/test/WebSites/CorsMiddlewareWebSite/hosting.json deleted file mode 100644 index 6a93dbafa8..0000000000 --- a/test/WebSites/CorsMiddlewareWebSite/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server": "Microsoft.AspNetCore.Server.Kestrel" -} From 5a3ea74ffa4c508036fca564c04cbbb4affeec85 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 29 Mar 2016 08:54:37 -0700 Subject: [PATCH 110/271] React to HttpAbstractions namespace changes - aspnet/HttpAbstractions#549 and aspnet/HttpAbstractions#592 - clean up `using`s --- test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs | 1 - test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs | 1 - .../DefaultCorsPolicyProviderTests.cs | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs index 93e5ace09b..7fc712aaef 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Moq; diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index a14c1548a7..fbdfd25dc0 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -3,7 +3,6 @@ using System; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Internal; using Xunit; namespace Microsoft.AspNetCore.Cors.Infrastructure diff --git a/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs b/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs index 1fc86b6d06..d66b0e5653 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Microsoft.AspNetCore.Http.Internal; +using Microsoft.AspNetCore.Http; using Xunit; namespace Microsoft.AspNetCore.Cors.Infrastructure @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure }; var policyProvider = new DefaultCorsPolicyProvider(corsOptions); - // Act + // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName: null); // Assert @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure }; var policyProvider = new DefaultCorsPolicyProvider(corsOptions); - // Act + // Act var actualPolicy = await policyProvider.GetPolicyAsync(new DefaultHttpContext(), policyName); // Assert From 1ba2402e48e1dc7fc060cd45cc9fb6c83d2742e3 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Apr 2016 09:47:20 -0700 Subject: [PATCH 111/271] Updating to release. --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index d6745f70b5..2344257191 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..cf8bff13bb 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..f88fe4052e 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 909f22df38e68e582805439989753b1a4d63ef99 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 7 Apr 2016 15:43:46 -0700 Subject: [PATCH 112/271] Removing imports from src projects --- src/Microsoft.AspNetCore.Cors/project.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index 17ea4c6b4e..9668d74a7c 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -25,10 +25,6 @@ }, "frameworks": { "net451": {}, - "netstandard1.3": { - "imports": [ - "dotnet5.4" - ] - } + "netstandard1.3": {} } } \ No newline at end of file From 03fcadc576f23f4fae2211e9a25c9593c4224703 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 6 Apr 2016 18:04:45 -0700 Subject: [PATCH 113/271] Moving web.config and use ANCM --- test/WebSites/CorsMiddlewareWebSite/Startup.cs | 2 +- test/WebSites/CorsMiddlewareWebSite/project.json | 13 ++++++++----- test/WebSites/CorsMiddlewareWebSite/web.config | 9 +++++++++ .../CorsMiddlewareWebSite/wwwroot/web.config | 9 --------- 4 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 test/WebSites/CorsMiddlewareWebSite/web.config delete mode 100644 test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index cc4770292f..8446784c4d 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -24,7 +24,7 @@ namespace CorsMiddlewareWebSite var host = new WebHostBuilder() .UseDefaultHostingConfiguration(args) .UseKestrel() - .UseIISPlatformHandlerUrl() + .UseIISIntegration() .UseStartup() .Build(); diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index d1a488a3d5..dc7c4a41c0 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -2,21 +2,24 @@ "compilationOptions": { "emitEntryPoint": true }, - "commands": { - "web": "CorsMiddlewareWebSite" - }, "dependencies": { "Microsoft.AspNetCore.Cors": "1.0.0-*", - "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*" }, "frameworks": { "net451": {}, "netstandardapp1.5": { + "dependencies": { + "NETStandard.Library": "1.5.0-*" + }, "imports": [ "dnxcore50" ] } - } + }, + "content": [ + "web.config" + ] } \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/web.config b/test/WebSites/CorsMiddlewareWebSite/web.config new file mode 100644 index 0000000000..3f9c5ddd75 --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/web.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config b/test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config deleted file mode 100644 index 8485f6719f..0000000000 --- a/test/WebSites/CorsMiddlewareWebSite/wwwroot/web.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - From 80f665491187f24c1a0929fe1ad4232024c86cf4 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 14 Apr 2016 16:14:05 -0700 Subject: [PATCH 114/271] Migrate tests, tools and samples to portable --- test/Microsoft.AspNetCore.Cors.Test/project.json | 10 +++++++--- test/WebSites/CorsMiddlewareWebSite/project.json | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 452981a962..59305ebd81 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -9,12 +9,16 @@ }, "testRunner": "xunit", "frameworks": { - "netstandardapp1.5": { + "netcoreapp1.0": { "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + }, "dotnet-test-xunit": "1.0.0-dev-*", "moq.netcore": "4.4.0-beta8", - "NETStandard.Library": "1.5.0-*", - "System.Diagnostics.Process": "4.1.0-*" + "System.Diagnostics.Process": "4.1.0-*", + "System.Diagnostics.TraceSource": "4.0.0-*" }, "imports": [ "dnxcore50", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index dc7c4a41c0..16ec6f13d0 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -5,14 +5,16 @@ "dependencies": { "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*" + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" }, "frameworks": { "net451": {}, - "netstandardapp1.5": { + "netcoreapp1.0": { "dependencies": { - "NETStandard.Library": "1.5.0-*" + "Microsoft.NETCore.App": { + "version": "1.0.0-*", + "type": "platform" + } }, "imports": [ "dnxcore50" From 67ea570e8794d19c1d88ae31b9fdbc07abcb6f99 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 18 Apr 2016 17:02:45 -0700 Subject: [PATCH 115/271] Bring Microsoft.NETCore.Platforms dependency back --- test/Microsoft.AspNetCore.Cors.Test/project.json | 1 + test/WebSites/CorsMiddlewareWebSite/project.json | 1 + 2 files changed, 2 insertions(+) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 59305ebd81..7bc0ceee0b 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -1,6 +1,7 @@ { "version": "1.0.0-*", "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "CorsMiddlewareWebSite": "1.0.0-*", "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 16ec6f13d0..e5fffffc67 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -3,6 +3,7 @@ "emitEntryPoint": true }, "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" From 162034dc7b76d3836fbddeab2b2787a7a87b2a9d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 19 Apr 2016 14:53:53 -0700 Subject: [PATCH 116/271] Use latest build of dotnet-test-xunit --- test/Microsoft.AspNetCore.Cors.Test/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 7bc0ceee0b..dc0288f93f 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -16,7 +16,7 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-dev-*", + "dotnet-test-xunit": "1.0.0-*", "moq.netcore": "4.4.0-beta8", "System.Diagnostics.Process": "4.1.0-*", "System.Diagnostics.TraceSource": "4.0.0-*" From 630a0a7de3d3d7b92af944084ed2694eb88daafb Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 25 Apr 2016 10:48:23 -0700 Subject: [PATCH 117/271] Update web.config and add publish tool --- NuGet.config | 2 +- test/WebSites/CorsMiddlewareWebSite/project.json | 11 ++++++++++- test/WebSites/CorsMiddlewareWebSite/web.config | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 2344257191..71b9724a09 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,6 +2,6 @@ - + diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index e5fffffc67..48131a314d 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -24,5 +24,14 @@ }, "content": [ "web.config" - ] + ], + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": { + "version": "1.0.0-*", + "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" + } + }, + "scripts": { + "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" + } } \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/web.config b/test/WebSites/CorsMiddlewareWebSite/web.config index 3f9c5ddd75..f7ac679334 100644 --- a/test/WebSites/CorsMiddlewareWebSite/web.config +++ b/test/WebSites/CorsMiddlewareWebSite/web.config @@ -4,6 +4,6 @@ - + \ No newline at end of file From 5a34796463f818868bab3acabf8c6e0e968a970a Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 27 Apr 2016 16:30:18 -0700 Subject: [PATCH 118/271] Remove reference to UseDefaultHostingConfiguration --- test/WebSites/CorsMiddlewareWebSite/Startup.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/test/WebSites/CorsMiddlewareWebSite/Startup.cs index 8446784c4d..3043f59bcd 100644 --- a/test/WebSites/CorsMiddlewareWebSite/Startup.cs +++ b/test/WebSites/CorsMiddlewareWebSite/Startup.cs @@ -22,7 +22,6 @@ namespace CorsMiddlewareWebSite public static void Main(string[] args) { var host = new WebHostBuilder() - .UseDefaultHostingConfiguration(args) .UseKestrel() .UseIISIntegration() .UseStartup() From 02f86494a9707f1004ab24ff88d65781376fe66c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 2 May 2016 11:27:07 -0700 Subject: [PATCH 119/271] Fix build warnings --- src/Microsoft.AspNetCore.Cors/project.json | 18 ++++++++++-------- .../project.json | 2 +- .../CorsMiddlewareWebSite/project.json | 10 ++++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index 9668d74a7c..ae5e6ff74d 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -1,15 +1,17 @@ { "version": "1.0.0-*", - "repository": { - "type": "git", - "url": "https://github.com/aspnet/cors" + "packOptions": { + "repository": { + "type": "git", + "url": "https://github.com/aspnet/cors" + }, + "tags": [ + "aspnetcore", + "cors" + ] }, "description": "CORS middleware and policy for ASP.NET Core to enable cross-origin resource sharing.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Cors.DisableCorsAttribute\r\nMicrosoft.AspNetCore.Cors.EnableCorsAttribute", - "tags": [ - "aspnetcore", - "cors" - ], - "compilationOptions": { + "buildOptions": { "warningsAsErrors": true, "keyFile": "../../tools/Key.snk", "nowarn": [ diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index dc0288f93f..437096d781 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -1,6 +1,7 @@ { "version": "1.0.0-*", "dependencies": { + "dotnet-test-xunit": "1.0.0-*", "Microsoft.NETCore.Platforms": "1.0.1-*", "CorsMiddlewareWebSite": "1.0.0-*", "Microsoft.AspNetCore.Cors": "1.0.0-*", @@ -16,7 +17,6 @@ "version": "1.0.0-*", "type": "platform" }, - "dotnet-test-xunit": "1.0.0-*", "moq.netcore": "4.4.0-beta8", "System.Diagnostics.Process": "4.1.0-*", "System.Diagnostics.TraceSource": "4.0.0-*" diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 48131a314d..00a9d003f3 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -1,5 +1,5 @@ { - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "dependencies": { @@ -22,9 +22,11 @@ ] } }, - "content": [ - "web.config" - ], + "publishOptions": { + "include": [ + "web.config" + ] + }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-*", From 0fd876a7b33f6d95d114e7eb288cb11648ce52e2 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Fri, 27 May 2016 12:08:30 -0700 Subject: [PATCH 120/271] Fix OSX build on Travis. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6a6d22bdfc..5d9d4cdb1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ branches: - release - dev - /^(.*\/)?ci-.*$/ +before_install: + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; brew link --force openssl; fi script: - ./build.sh verify notifications: From bb864304805c5237fdb00baba65e23066759b6b5 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 13 Jun 2016 15:29:34 -0700 Subject: [PATCH 121/271] Remove direct Microsoft.NETCore.Platforms dependency. - Microsoft.NETCore.App now pulls this package in. aspnet/Coherence-Signed#344 --- test/Microsoft.AspNetCore.Cors.Test/project.json | 1 - test/WebSites/CorsMiddlewareWebSite/project.json | 1 - 2 files changed, 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 437096d781..bf99f6e35a 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -2,7 +2,6 @@ "version": "1.0.0-*", "dependencies": { "dotnet-test-xunit": "1.0.0-*", - "Microsoft.NETCore.Platforms": "1.0.1-*", "CorsMiddlewareWebSite": "1.0.0-*", "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.TestHost": "1.0.0-*", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 00a9d003f3..1cf28bbbf6 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -3,7 +3,6 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*", "Microsoft.AspNetCore.Cors": "1.0.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" From 9d14ded22380982e95095fdc1a5756d4d35c98a2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 14 Jun 2016 16:22:52 -0700 Subject: [PATCH 122/271] Updating to release. --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 52bf414192..71b9724a09 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..cf8bff13bb 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..f88fe4052e 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/release.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From f742566f3f62718639a3802a84098d4ac82aa7fd Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Jun 2016 10:17:38 -0700 Subject: [PATCH 123/271] Updating to dev versions --- src/Microsoft.AspNetCore.Cors/project.json | 10 +++++----- test/Microsoft.AspNetCore.Cors.Test/project.json | 8 ++++---- test/WebSites/CorsMiddlewareWebSite/project.json | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index ae5e6ff74d..8f3b9de311 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "packOptions": { "repository": { "type": "git", @@ -20,10 +20,10 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Http.Extensions": "1.0.0-*", - "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-*", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-*", - "Microsoft.Extensions.Options": "1.0.0-*" + "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", + "Microsoft.Extensions.Configuration.Abstractions": "1.1.0-*", + "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0-*", + "Microsoft.Extensions.Options": "1.1.0-*" }, "frameworks": { "net451": {}, diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index bf99f6e35a..ee8c8fde44 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -1,11 +1,11 @@ { - "version": "1.0.0-*", + "version": "1.1.0-*", "dependencies": { "dotnet-test-xunit": "1.0.0-*", "CorsMiddlewareWebSite": "1.0.0-*", - "Microsoft.AspNetCore.Cors": "1.0.0-*", - "Microsoft.AspNetCore.TestHost": "1.0.0-*", - "Microsoft.Extensions.Logging.Testing": "1.0.0-*", + "Microsoft.AspNetCore.Cors": "1.1.0-*", + "Microsoft.AspNetCore.TestHost": "1.1.0-*", + "Microsoft.Extensions.Logging.Testing": "1.1.0-*", "xunit": "2.1.0" }, "testRunner": "xunit", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 1cf28bbbf6..9432c31074 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -3,9 +3,9 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.AspNetCore.Cors": "1.0.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*" + "Microsoft.AspNetCore.Cors": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*" }, "frameworks": { "net451": {}, From 21e097b9e71c8b46eea4c7f099e655e8d739e21e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 5 Jul 2016 21:32:19 -0700 Subject: [PATCH 124/271] Updating to RTM builds of xunit and Moq --- .../project.json | 18 +++++------------- .../CorsMiddlewareWebSite/project.json | 10 ++-------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index ee8c8fde44..ca496125e2 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -1,12 +1,13 @@ { "version": "1.1.0-*", "dependencies": { - "dotnet-test-xunit": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "CorsMiddlewareWebSite": "1.0.0-*", "Microsoft.AspNetCore.Cors": "1.1.0-*", "Microsoft.AspNetCore.TestHost": "1.1.0-*", "Microsoft.Extensions.Logging.Testing": "1.1.0-*", - "xunit": "2.1.0" + "Moq": "4.6.25-*", + "xunit": "2.2.0-*" }, "testRunner": "xunit", "frameworks": { @@ -16,19 +17,10 @@ "version": "1.0.0-*", "type": "platform" }, - "moq.netcore": "4.4.0-beta8", - "System.Diagnostics.Process": "4.1.0-*", "System.Diagnostics.TraceSource": "4.0.0-*" }, - "imports": [ - "dnxcore50", - "portable-net451+win8" - ] + "imports": "dotnet5.4" }, - "net451": { - "dependencies": { - "Moq": "4.2.1312.1622" - } - } + "net451": {} } } \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 9432c31074..6bfc7b06e3 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -15,10 +15,7 @@ "version": "1.0.0-*", "type": "platform" } - }, - "imports": [ - "dnxcore50" - ] + } } }, "publishOptions": { @@ -27,10 +24,7 @@ ] }, "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-*", - "imports": "portable-net45+wp80+win8+wpa81+dnxcore50" - } + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" }, "scripts": { "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" From 584296491924bb048cee342912b4a39273f221ae Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 6 Jul 2016 22:02:12 -0700 Subject: [PATCH 125/271] One build to rule them all - well, at least VS and command-line builds will share output - part of aspnet/Coherence-Signed#277 --- src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj | 4 ++-- .../Microsoft.AspNetCore.Cors.Test.xproj | 4 ++-- .../CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj index c8239c9cfe..6692475384 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj @@ -7,8 +7,8 @@ 41349fcd-d1c4-47a6-82d0-d16d00a8d59d - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj index 3851945c08..f2351a724c 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj @@ -7,8 +7,8 @@ f05be96f-f869-4408-a480-96935b4835ee - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj index a572a9933f..f4d5720f67 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj @@ -7,8 +7,8 @@ b42d4844-fff8-4ec2-88d1-3ae95234d9eb - ..\..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\..\artifacts\bin\ + .\obj + .\bin\ 2.0 From c86bf2cda78b05b13115670c7cc1d8b2b669f794 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 2 Aug 2016 13:15:30 -0700 Subject: [PATCH 126/271] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5d9d4cdb1d..6ce4d51319 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ branches: - dev - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; brew link --force openssl; fi + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - ./build.sh verify notifications: @@ -31,4 +31,4 @@ notifications: secure: "V+ynhkZnRWn9VemSgBKI6KB5WxSE/SuoIKFnBQFb/1O0r15aac4/VyzuRdTK8V29OxdI1vK0J3UET2c2v2Q2IusFc4rCHGcRIobjHq+YW8944betuYfHkpVgniHofaGLgJH8gdlZv4elDdVHWKndYIGTaBU8+dO8ktp+9BFGYhs=" on_success: always on_failure: always - on_start: always \ No newline at end of file + on_start: always From b5abd73e349d6825e06a0484550a408760445202 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 8 Aug 2016 12:32:20 -0700 Subject: [PATCH 127/271] Updating to Moq \ Castle.Core that does not require imports --- test/Microsoft.AspNetCore.Cors.Test/project.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index ca496125e2..47a1a61948 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -6,7 +6,7 @@ "Microsoft.AspNetCore.Cors": "1.1.0-*", "Microsoft.AspNetCore.TestHost": "1.1.0-*", "Microsoft.Extensions.Logging.Testing": "1.1.0-*", - "Moq": "4.6.25-*", + "Moq": "4.6.36-*", "xunit": "2.2.0-*" }, "testRunner": "xunit", @@ -18,8 +18,7 @@ "type": "platform" }, "System.Diagnostics.TraceSource": "4.0.0-*" - }, - "imports": "dotnet5.4" + } }, "net451": {} } From 15b66cec1fac1b12614e23f556bb01b26eb4476a Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 3 Aug 2016 09:28:08 -0700 Subject: [PATCH 128/271] [Fixes #77] Make HTTP method match as case-insensitive --- .../Infrastructure/CorsMiddleware.cs | 2 +- .../Infrastructure/CorsService.cs | 20 ++++- .../CorsMiddlewareTests.cs | 77 +++++++++++++++++++ .../CorsServiceTests.cs | 24 ++++-- 4 files changed, 112 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs index cae0bbab1c..a5dd632d38 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs @@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure if (string.Equals( context.Request.Method, CorsConstants.PreflightHttpMethod, - StringComparison.Ordinal) && + StringComparison.OrdinalIgnoreCase) && !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { // Since there is a policy which was identified, diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index 3f792e72af..6af9dafc7d 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var corsResult = new CorsResult(); var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; - if (string.Equals(context.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.Ordinal) && + if (string.Equals(context.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.OrdinalIgnoreCase) && !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { EvaluatePreflightRequest(context, policy, corsResult); @@ -109,9 +109,23 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var requestHeaders = context.Request.Headers.GetCommaSeparatedValues(CorsConstants.AccessControlRequestHeaders); - if (!policy.AllowAnyMethod && !policy.Methods.Contains(accessControlRequestMethod)) + if (!policy.AllowAnyMethod) { - return; + var found = false; + for (var i = 0; i < policy.Methods.Count; i++) + { + var method = policy.Methods[i]; + if (string.Equals(method, accessControlRequestMethod, StringComparison.OrdinalIgnoreCase)) + { + found = true; + break; + } + } + + if (!found) + { + return; + } } if (!policy.AllowAnyHeader && diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs index 7fc712aaef..d884293e81 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs @@ -16,6 +16,41 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure { public class CorsMiddlewareTests { + [Theory] + [InlineData("PuT")] + [InlineData("PUT")] + public async Task CorsRequest_MatchesPolicy_OnCaseInsensitiveAccessControlRequestMethod(string accessControlRequestMethod) + { + // Arrange + var hostBuilder = new WebHostBuilder() + .Configure(app => + { + app.UseCors(builder => + builder.WithOrigins("http://localhost:5001") + .WithMethods("PUT")); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + }) + .ConfigureServices(services => services.AddCors()); + + using (var server = new TestServer(hostBuilder)) + { + // Act + // Actual request. + var response = await server.CreateRequest("/") + .AddHeader(CorsConstants.Origin, "http://localhost:5001") + .SendAsync(accessControlRequestMethod); + + // Assert + response.EnsureSuccessStatusCode(); + Assert.Equal(1, response.Headers.Count()); + Assert.Equal("Cross origin response", await response.Content.ReadAsStringAsync()); + Assert.Equal("http://localhost:5001", response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault()); + } + } + [Fact] public async Task CorsRequest_MatchPolicy_SetsResponseHeaders() { @@ -52,6 +87,48 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure } } + [Theory] + [InlineData("OpTions")] + [InlineData("OPTIONS")] + public async Task PreFlight_MatchesPolicy_OnCaseInsensitiveOptionsMethod(string preflightMethod) + { + // Arrange + var policy = new CorsPolicy(); + policy.Origins.Add("http://localhost:5001"); + policy.Methods.Add("PUT"); + + var hostBuilder = new WebHostBuilder() + .Configure(app => + { + app.UseCors("customPolicy"); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + }) + .ConfigureServices(services => + { + services.AddCors(options => + { + options.AddPolicy("customPolicy", policy); + }); + }); + + using (var server = new TestServer(hostBuilder)) + { + // Act + // Preflight request. + var response = await server.CreateRequest("/") + .AddHeader(CorsConstants.Origin, "http://localhost:5001") + .SendAsync(preflightMethod); + + // Assert + response.EnsureSuccessStatusCode(); + Assert.Equal(1, response.Headers.Count()); + Assert.Equal("http://localhost:5001", response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault()); + } + } + [Fact] public async Task PreFlight_MatchesPolicy_SetsResponseHeaders() { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index fbdfd25dc0..c88eccd6fa 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -227,12 +227,17 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Contains("PUT", result.AllowedMethods); } - [Fact] - public void EvaluatePolicy_PreflightRequest_OriginAllowed_ReturnsOrigin() + [Theory] + [InlineData("OpTions")] + [InlineData("OPTIONS")] + public void EvaluatePolicy_CaseInsensitivePreflightRequest_OriginAllowed_ReturnsOrigin(string preflightMethod) { // Arrange var corsService = new CorsService(new TestCorsOptions()); - var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var requestContext = GetHttpContext( + method: preflightMethod, + origin: "http://example.com", + accessControlRequestMethod: "PUT"); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); policy.Origins.Add("http://example.com"); @@ -323,12 +328,17 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Contains("GET", result.AllowedMethods); } - [Fact] - public void EvaluatePolicy_PreflightRequest_ListedMethod_ReturnsSubsetOfListedMethods() + [Theory] + [InlineData("Put")] + [InlineData("PUT")] + public void EvaluatePolicy_CaseInsensitivePreflightRequest_ListedMethod_ReturnsSubsetOfListedMethods(string method) { // Arrange var corsService = new CorsService(new TestCorsOptions()); - var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://example.com", accessControlRequestMethod: "PUT"); + var requestContext = GetHttpContext( + method: "OPTIONS", + origin: "http://example.com", + accessControlRequestMethod: method); var policy = new CorsPolicy(); policy.Origins.Add(CorsConstants.AnyOrigin); policy.Methods.Add("PUT"); @@ -339,7 +349,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Assert Assert.Equal(1, result.AllowedMethods.Count); - Assert.Contains("PUT", result.AllowedMethods); + Assert.Contains(method, result.AllowedMethods); } [Fact] From 66abd74142f05b6605d2407cbb98f2e05682fc74 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 9 Aug 2016 14:57:24 -0700 Subject: [PATCH 129/271] Switching to dotnet.myget.org feed --- NuGet.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 52bf414192..0fd623ffdd 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + From bfd2c36783a5a6feec51318cbc1e26dc3f963545 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sat, 3 Sep 2016 22:22:50 -0700 Subject: [PATCH 130/271] Increase .travis.yml consistency between repos - aspnet/Universe#349 - minimize `dotnet` setup time; no need for caching - build with `--quiet` --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ce4d51319..a84a024b7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ addons: - libssl-dev - libunwind8 - zlib1g +env: + global: + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: - 4.0.5 os: @@ -25,7 +29,7 @@ branches: before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - - ./build.sh verify + - ./build.sh --quiet verify notifications: webhooks: secure: "V+ynhkZnRWn9VemSgBKI6KB5WxSE/SuoIKFnBQFb/1O0r15aac4/VyzuRdTK8V29OxdI1vK0J3UET2c2v2Q2IusFc4rCHGcRIobjHq+YW8944betuYfHkpVgniHofaGLgJH8gdlZv4elDdVHWKndYIGTaBU8+dO8ktp+9BFGYhs=" From fa5dcf55a6d135f4d35f4beb066f6eadd35ac762 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 28 Sep 2016 11:49:51 -0700 Subject: [PATCH 131/271] Updating partner package versions --- src/Microsoft.AspNetCore.Cors/project.json | 3 ++- test/Microsoft.AspNetCore.Cors.Test/project.json | 6 +++--- test/WebSites/CorsMiddlewareWebSite/project.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index 8f3b9de311..07dc264192 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -23,7 +23,8 @@ "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", "Microsoft.Extensions.Configuration.Abstractions": "1.1.0-*", "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*" + "Microsoft.Extensions.Options": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "net451": {}, diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 47a1a61948..e5085ce552 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -1,8 +1,8 @@ { "version": "1.1.0-*", "dependencies": { - "dotnet-test-xunit": "2.2.0-*", "CorsMiddlewareWebSite": "1.0.0-*", + "dotnet-test-xunit": "2.2.0-*", "Microsoft.AspNetCore.Cors": "1.1.0-*", "Microsoft.AspNetCore.TestHost": "1.1.0-*", "Microsoft.Extensions.Logging.Testing": "1.1.0-*", @@ -14,10 +14,10 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" }, - "System.Diagnostics.TraceSource": "4.0.0-*" + "System.Diagnostics.TraceSource": "4.3.0-*" } }, "net451": {} diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 6bfc7b06e3..a14d882508 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -12,7 +12,7 @@ "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0-*", + "version": "1.1.0-*", "type": "platform" } } From 9c80faa4984ecf0682be772a3fbdaa4e69608745 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 12 Oct 2016 13:44:57 -0700 Subject: [PATCH 132/271] Updating to netcoreapp1.1 --- test/Microsoft.AspNetCore.Cors.Test/project.json | 2 +- test/WebSites/CorsMiddlewareWebSite/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index e5085ce552..d267325a99 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -11,7 +11,7 @@ }, "testRunner": "xunit", "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index a14d882508..3b18d126fd 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -9,7 +9,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From f9193cb2850169ebc9696cbadf0d7a98af801f6e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 12 Oct 2016 16:08:08 -0700 Subject: [PATCH 133/271] Revert "Updating to netcoreapp1.1" This reverts commit 9c80faa4984ecf0682be772a3fbdaa4e69608745. --- test/Microsoft.AspNetCore.Cors.Test/project.json | 2 +- test/WebSites/CorsMiddlewareWebSite/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index d267325a99..e5085ce552 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -11,7 +11,7 @@ }, "testRunner": "xunit", "frameworks": { - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 3b18d126fd..a14d882508 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -9,7 +9,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.1": { + "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From 8cd356f1703141efc3d16dc010ef25f16d25e4b5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 13 Oct 2016 11:13:08 -0700 Subject: [PATCH 134/271] Updating to netcoreapp1.1 --- test/Microsoft.AspNetCore.Cors.Test/project.json | 2 +- test/WebSites/CorsMiddlewareWebSite/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index e5085ce552..d267325a99 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -11,7 +11,7 @@ }, "testRunner": "xunit", "frameworks": { - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index a14d882508..3b18d126fd 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -9,7 +9,7 @@ }, "frameworks": { "net451": {}, - "netcoreapp1.0": { + "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0-*", From 5fb075bd3b3b4a9bd8d414f9f28360fa873aad8b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 17 Oct 2016 09:48:47 -0700 Subject: [PATCH 135/271] Branching for 1.1.0-preview1 --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 0fd623ffdd..ad973186eb 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..787f63ac02 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0-preview1.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..355c682856 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0-preview1.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 9b95754b0f4c94d5ba5c5c8510b2d2cbba2c636b Mon Sep 17 00:00:00 2001 From: jacalvar Date: Fri, 4 Nov 2016 13:00:30 -0700 Subject: [PATCH 136/271] Created public API baselines --- .../baseline.net45.json | 1124 +++++++++++++++++ .../baseline.netcore.json | 1124 +++++++++++++++++ 2 files changed, 2248 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Cors/baseline.net45.json create mode 100644 src/Microsoft.AspNetCore.Cors/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore.Cors/baseline.net45.json b/src/Microsoft.AspNetCore.Cors/baseline.net45.json new file mode 100644 index 0000000000..b9e31fcb82 --- /dev/null +++ b/src/Microsoft.AspNetCore.Cors/baseline.net45.json @@ -0,0 +1,1124 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Cors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseCors", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseCors", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "configurePolicy", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.DisableCorsAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.IDisableCorsAttribute" + ], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.EnableCorsAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_PolicyName", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PolicyName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policyName", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsConstants", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "PreflightHttpMethod", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Origin", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AnyOrigin", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlRequestMethod", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlRequestHeaders", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowOrigin", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowHeaders", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlExposeHeaders", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowMethods", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowCredentials", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlMaxAge", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "corsService", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" + }, + { + "Name": "policyProvider", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "corsService", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DefaultPolicyName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DefaultPolicyName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "configurePolicy", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AllowAnyHeader", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowAnyMethod", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowAnyOrigin", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExposedHeaders", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Headers", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Methods", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Origins", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PreflightMaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PreflightMaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SupportsCredentials", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SupportsCredentials", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ToString", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "WithOrigins", + "Parameters": [ + { + "Name": "origins", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WithHeaders", + "Parameters": [ + { + "Name": "headers", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WithExposedHeaders", + "Parameters": [ + { + "Name": "exposedHeaders", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WithMethods", + "Parameters": [ + { + "Name": "methods", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowCredentials", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DisallowCredentials", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowAnyOrigin", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowAnyMethod", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowAnyHeader", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetPreflightMaxAge", + "Parameters": [ + { + "Name": "preflightMaxAge", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Build", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "origins", + "Type": "System.String[]", + "IsParams": true + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AllowedOrigin", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AllowedOrigin", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SupportsCredentials", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SupportsCredentials", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedMethods", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedHeaders", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedExposedHeaders", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_VaryByOrigin", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_VaryByOrigin", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PreflightMaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PreflightMaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ToString", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsService", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" + ], + "Members": [ + { + "Kind": "Method", + "Name": "EvaluatePolicy", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "EvaluatePolicy", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "EvaluateRequest", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + }, + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "EvaluatePreflightRequest", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + }, + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ApplyResult", + "Parameters": [ + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + }, + { + "Name": "response", + "Type": "Microsoft.AspNetCore.Http.HttpResponse" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.DefaultCorsPolicyProvider", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "EvaluatePolicy", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ApplyResult", + "Parameters": [ + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + }, + { + "Name": "response", + "Type": "Microsoft.AspNetCore.Http.HttpResponse" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.IDisableCorsAttribute", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_PolicyName", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PolicyName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.CorsServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddCors", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddCors", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "setupAction", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/baseline.netcore.json b/src/Microsoft.AspNetCore.Cors/baseline.netcore.json new file mode 100644 index 0000000000..b9e31fcb82 --- /dev/null +++ b/src/Microsoft.AspNetCore.Cors/baseline.netcore.json @@ -0,0 +1,1124 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore.Cors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "UseCors", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "UseCors", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + }, + { + "Name": "configurePolicy", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.DisableCorsAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.IDisableCorsAttribute" + ], + "Members": [ + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.EnableCorsAttribute", + "Visibility": "Public", + "Kind": "Class", + "BaseType": "System.Attribute", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute" + ], + "Members": [ + { + "Kind": "Method", + "Name": "get_PolicyName", + "Parameters": [], + "ReturnType": "System.String", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PolicyName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policyName", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsConstants", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Field", + "Name": "PreflightHttpMethod", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "Origin", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AnyOrigin", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlRequestMethod", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlRequestHeaders", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowOrigin", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowHeaders", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlExposeHeaders", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowMethods", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlAllowCredentials", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Field", + "Name": "AccessControlMaxAge", + "Parameters": [], + "ReturnType": "System.String", + "Static": true, + "ReadOnly": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Invoke", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "corsService", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" + }, + { + "Name": "policyProvider", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "corsService", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsOptions", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_DefaultPolicyName", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_DefaultPolicyName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + }, + { + "Name": "configurePolicy", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "GetPolicy", + "Parameters": [ + { + "Name": "name", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AllowAnyHeader", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowAnyMethod", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowAnyOrigin", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_ExposedHeaders", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Headers", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Methods", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_Origins", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PreflightMaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PreflightMaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SupportsCredentials", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SupportsCredentials", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ToString", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "WithOrigins", + "Parameters": [ + { + "Name": "origins", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WithHeaders", + "Parameters": [ + { + "Name": "headers", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WithExposedHeaders", + "Parameters": [ + { + "Name": "exposedHeaders", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "WithMethods", + "Parameters": [ + { + "Name": "methods", + "Type": "System.String[]", + "IsParams": true + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowCredentials", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "DisallowCredentials", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowAnyOrigin", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowAnyMethod", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AllowAnyHeader", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetPreflightMaxAge", + "Parameters": [ + { + "Name": "preflightMaxAge", + "Type": "System.TimeSpan" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Build", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "origins", + "Type": "System.String[]", + "IsParams": true + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_AllowedOrigin", + "Parameters": [], + "ReturnType": "System.String", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_AllowedOrigin", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_SupportsCredentials", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_SupportsCredentials", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedMethods", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedHeaders", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_AllowedExposedHeaders", + "Parameters": [], + "ReturnType": "System.Collections.Generic.IList", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_VaryByOrigin", + "Parameters": [], + "ReturnType": "System.Boolean", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_VaryByOrigin", + "Parameters": [ + { + "Name": "value", + "Type": "System.Boolean" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "get_PreflightMaxAge", + "Parameters": [], + "ReturnType": "System.Nullable", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PreflightMaxAge", + "Parameters": [ + { + "Name": "value", + "Type": "System.Nullable" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ToString", + "Parameters": [], + "ReturnType": "System.String", + "Virtual": true, + "Override": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsService", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" + ], + "Members": [ + { + "Kind": "Method", + "Name": "EvaluatePolicy", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "EvaluatePolicy", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "EvaluateRequest", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + }, + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "EvaluatePreflightRequest", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + }, + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ApplyResult", + "Parameters": [ + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + }, + { + "Name": "response", + "Type": "Microsoft.AspNetCore.Http.HttpResponse" + } + ], + "ReturnType": "System.Void", + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.DefaultCorsPolicyProvider", + "Visibility": "Public", + "Kind": "Class", + "ImplementedInterfaces": [ + "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider" + ], + "Members": [ + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "Sealed": true, + "Virtual": true, + "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + } + ], + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "GetPolicyAsync", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policyName", + "Type": "System.String" + } + ], + "ReturnType": "System.Threading.Tasks.Task", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "EvaluatePolicy", + "Parameters": [ + { + "Name": "context", + "Type": "Microsoft.AspNetCore.Http.HttpContext" + }, + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "ApplyResult", + "Parameters": [ + { + "Name": "result", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" + }, + { + "Name": "response", + "Type": "Microsoft.AspNetCore.Http.HttpResponse" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.IDisableCorsAttribute", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [], + "GenericParameters": [] + }, + { + "Name": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", + "Visibility": "Public", + "Kind": "Interface", + "Abstract": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "get_PolicyName", + "Parameters": [], + "ReturnType": "System.String", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_PolicyName", + "Parameters": [ + { + "Name": "value", + "Type": "System.String" + } + ], + "ReturnType": "System.Void", + "GenericParameter": [] + } + ], + "GenericParameters": [] + }, + { + "Name": "Microsoft.Extensions.DependencyInjection.CorsServiceCollectionExtensions", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "AddCors", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddCors", + "Parameters": [ + { + "Name": "services", + "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" + }, + { + "Name": "setupAction", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file From 181f0a03221f86b1453b058a4d567a053aee26d7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 11:29:41 -0800 Subject: [PATCH 137/271] Branching for 1.1.0 --- NuGet.config | 4 ++-- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 0fd623ffdd..ad973186eb 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + - + diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..24ca167cf6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..fea9ac64ad 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From de383b7ee49c23b0ff47ef2276c954bce164a090 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 14:16:56 -0800 Subject: [PATCH 138/271] Updating versions to 1.2.0-* --- src/Microsoft.AspNetCore.Cors/project.json | 10 +++++----- test/Microsoft.AspNetCore.Cors.Test/project.json | 6 +++--- test/WebSites/CorsMiddlewareWebSite/project.json | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index 07dc264192..fae16fb6a1 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -1,5 +1,5 @@ { - "version": "1.1.0-*", + "version": "1.2.0-*", "packOptions": { "repository": { "type": "git", @@ -20,10 +20,10 @@ "xmlDoc": true }, "dependencies": { - "Microsoft.AspNetCore.Http.Extensions": "1.1.0-*", - "Microsoft.Extensions.Configuration.Abstractions": "1.1.0-*", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0-*", - "Microsoft.Extensions.Options": "1.1.0-*", + "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", + "Microsoft.Extensions.Configuration.Abstractions": "1.2.0-*", + "Microsoft.Extensions.DependencyInjection.Abstractions": "1.2.0-*", + "Microsoft.Extensions.Options": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index d267325a99..6ad6917f35 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -3,9 +3,9 @@ "dependencies": { "CorsMiddlewareWebSite": "1.0.0-*", "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Cors": "1.1.0-*", - "Microsoft.AspNetCore.TestHost": "1.1.0-*", - "Microsoft.Extensions.Logging.Testing": "1.1.0-*", + "Microsoft.AspNetCore.Cors": "1.2.0-*", + "Microsoft.AspNetCore.TestHost": "1.2.0-*", + "Microsoft.Extensions.Logging.Testing": "1.2.0-*", "Moq": "4.6.36-*", "xunit": "2.2.0-*" }, diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index 3b18d126fd..f447a14c31 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -3,9 +3,9 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.AspNetCore.Cors": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*" + "Microsoft.AspNetCore.Cors": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*" }, "frameworks": { "net451": {}, From 4de03b6dffda2769d5d0cdd3850229fe3d254c91 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Tue, 15 Nov 2016 10:28:06 -0800 Subject: [PATCH 139/271] Added logging for preflight requests and origin headers --- .../Infrastructure/CorsService.cs | 17 ++++++ .../Internal/CORSLoggerExtensions.cs | 58 +++++++++++++++++++ .../CorsServiceTests.cs | 2 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index 6af9dafc7d..87343b2f9f 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -5,9 +5,11 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using Microsoft.AspNetCore.Cors.Internal; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; +using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Cors.Infrastructure { @@ -17,12 +19,23 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure public class CorsService : ICorsService { private readonly CorsOptions _options; + private readonly ILogger _logger; /// /// Creates a new instance of the . /// /// The option model representing . public CorsService(IOptions options) + :this(options, loggerFactory: null) + { + } + + /// + /// Creates a new instance of the . + /// + /// The option model representing . + /// The . + public CorsService(IOptions options, ILoggerFactory loggerFactory) { if (options == null) { @@ -30,6 +43,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure } _options = options.Value; + _logger = loggerFactory?.CreateLogger(); } /// @@ -70,6 +84,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { EvaluatePreflightRequest(context, policy, corsResult); + _logger?.IsPreflightRequest(); } else { @@ -87,6 +102,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure return; } + _logger?.RequestHasOriginHeader(); AddOriginToResult(origin, policy, result); result.SupportsCredentials = policy.SupportsCredentials; AddHeaderValues(result.AllowedExposedHeaders, policy.ExposedHeaders); @@ -100,6 +116,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure return; } + _logger?.RequestHasOriginHeader(); var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (StringValues.IsNullOrEmpty(accessControlRequestMethod)) { diff --git a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs new file mode 100644 index 0000000000..7672797458 --- /dev/null +++ b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Cors.Internal +{ + internal static class CORSLoggerExtensions + { + private static readonly Action _isPreflightRequest; + private static readonly Action _requestHasOriginHeader; + private static readonly Action _policySuccess; + private static readonly Action _policyFailure; + + static CORSLoggerExtensions() + { + _isPreflightRequest = LoggerMessage.Define( + LogLevel.Debug, + 1, + "The request is preflight."); + + _requestHasOriginHeader = LoggerMessage.Define( + LogLevel.Debug, + 2, + "The request has an origin header."); + + _policySuccess = LoggerMessage.Define( + LogLevel.Information, + 3, + "Policy execution successful."); + + _policyFailure = LoggerMessage.Define( + LogLevel.Information, + 3, + "Policy execution failed. '{FailureReason}'"); + } + + public static void IsPreflightRequest(this ILogger logger) + { + _isPreflightRequest(logger, null); + } + + public static void RequestHasOriginHeader(this ILogger logger) + { + _requestHasOriginHeader(logger, null); + } + + public static void PolicySuccess(this ILogger logger, string failureReason) + { + _policySuccess(logger, null); + } + public static void PolicyFailure(this ILogger logger, string failureReason) + { + _policyFailure(logger, failureReason, null); + } + } +} diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index c88eccd6fa..b3a92a8d68 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -446,7 +446,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure } [Fact] - public void EaluatePolicy_DoesCaseSensitiveComparison() + public void EvaluatePolicy_DoesCaseSensitiveComparison() { // Arrange var corsService = new CorsService(new TestCorsOptions()); From 98bb5d67fdf11e7dc29b34cb562c26979f095484 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Wed, 16 Nov 2016 15:46:47 -0800 Subject: [PATCH 140/271] Design PR for CORS sample and logging --- CORS.sln | 19 ++++++- SampleDestination/Program.cs | 31 ++++++++++++ SampleDestination/SampleDestination.xproj | 25 ++++++++++ SampleDestination/Startup.cs | 36 +++++++++++++ SampleDestination/StatusMiddleware.cs | 35 +++++++++++++ SampleDestination/hosting.json | 3 ++ SampleDestination/project.json | 50 +++++++++++++++++++ SampleDestination/web.config | 14 ++++++ SampleOrigin/Program.cs | 32 ++++++++++++ SampleOrigin/SampleOrigin.xproj | 25 ++++++++++ SampleOrigin/Startup.cs | 35 +++++++++++++ SampleOrigin/hosting.json | 3 ++ SampleOrigin/project.json | 50 +++++++++++++++++++ SampleOrigin/web.config | 14 ++++++ SampleOrigin/wwwroot/Index.html | 49 ++++++++++++++++++ .../Infrastructure/CorsService.cs | 10 ++-- .../Internal/CORSLoggerExtensions.cs | 5 +- src/Microsoft.AspNetCore.Cors/project.json | 1 + 18 files changed, 430 insertions(+), 7 deletions(-) create mode 100644 SampleDestination/Program.cs create mode 100644 SampleDestination/SampleDestination.xproj create mode 100644 SampleDestination/Startup.cs create mode 100644 SampleDestination/StatusMiddleware.cs create mode 100644 SampleDestination/hosting.json create mode 100644 SampleDestination/project.json create mode 100644 SampleDestination/web.config create mode 100644 SampleOrigin/Program.cs create mode 100644 SampleOrigin/SampleOrigin.xproj create mode 100644 SampleOrigin/Startup.cs create mode 100644 SampleOrigin/hosting.json create mode 100644 SampleOrigin/project.json create mode 100644 SampleOrigin/web.config create mode 100644 SampleOrigin/wwwroot/Index.html diff --git a/CORS.sln b/CORS.sln index 9f3b2ba560..87e766660f 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" EndProject @@ -20,6 +19,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{53 EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CorsMiddlewareWebSite", "test\WebSites\CorsMiddlewareWebSite\CorsMiddlewareWebSite.xproj", "{B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{960E0703-A8A5-44DF-AA87-B7C614683B3C}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleDestination", "SampleDestination\SampleDestination.xproj", "{F6675DC1-AA21-453B-89B6-DA425FB9C3A5}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleOrigin", "SampleOrigin\SampleOrigin.xproj", "{99460370-AE5D-4DC9-8DBF-04DF66D6B21D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,6 +43,14 @@ Global {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}.Release|Any CPU.ActiveCfg = Release|Any CPU {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}.Release|Any CPU.Build.0 = Release|Any CPU + {F6675DC1-AA21-453B-89B6-DA425FB9C3A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6675DC1-AA21-453B-89B6-DA425FB9C3A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6675DC1-AA21-453B-89B6-DA425FB9C3A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6675DC1-AA21-453B-89B6-DA425FB9C3A5}.Release|Any CPU.Build.0 = Release|Any CPU + {99460370-AE5D-4DC9-8DBF-04DF66D6B21D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99460370-AE5D-4DC9-8DBF-04DF66D6B21D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99460370-AE5D-4DC9-8DBF-04DF66D6B21D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99460370-AE5D-4DC9-8DBF-04DF66D6B21D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -47,5 +60,7 @@ Global {F05BE96F-F869-4408-A480-96935B4835EE} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} {538380BF-0D4C-4E30-8F41-E75C4B1C01FA} = {F32074C7-087C-46CC-A913-422BFD2D6E0A} {B42D4844-FFF8-4EC2-88D1-3AE95234D9EB} = {538380BF-0D4C-4E30-8F41-E75C4B1C01FA} + {F6675DC1-AA21-453B-89B6-DA425FB9C3A5} = {960E0703-A8A5-44DF-AA87-B7C614683B3C} + {99460370-AE5D-4DC9-8DBF-04DF66D6B21D} = {960E0703-A8A5-44DF-AA87-B7C614683B3C} EndGlobalSection EndGlobal diff --git a/SampleDestination/Program.cs b/SampleDestination/Program.cs new file mode 100644 index 0000000000..972cde8b8b --- /dev/null +++ b/SampleDestination/Program.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace SampleDestination +{ + public class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("hosting.json", optional: true) + .Build(); + + var host = new WebHostBuilder() + .UseKestrel() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/SampleDestination/SampleDestination.xproj b/SampleDestination/SampleDestination.xproj new file mode 100644 index 0000000000..ac33a6f88b --- /dev/null +++ b/SampleDestination/SampleDestination.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + f6675dc1-aa21-453b-89b6-da425fb9c3a5 + SampleDestination + .\obj + .\bin\ + v4.5.2 + + + + 2.0 + + + + + + + diff --git a/SampleDestination/Startup.cs b/SampleDestination/Startup.cs new file mode 100644 index 0000000000..5ea6b6d284 --- /dev/null +++ b/SampleDestination/Startup.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace SampleDestination +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + services.AddCors(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseCors(policy => policy.WithOrigins("http://origin.sample.com:8080").WithMethods("GET")); + app.UseMiddleware(); + } +} +} diff --git a/SampleDestination/StatusMiddleware.cs b/SampleDestination/StatusMiddleware.cs new file mode 100644 index 0000000000..1f47c634ad --- /dev/null +++ b/SampleDestination/StatusMiddleware.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SampleDestination +{ + public class StatusMiddleware + { + /// + /// Instantiates a new . + /// + /// The next middleware in the pipeline. + public StatusMiddleware(RequestDelegate next) + { + } + + /// + /// Writes the status of the request sent in response. Does not invoke later middleware in the pipeline. + /// + /// The of the current request. + /// A that completes when writing to the response is done. + public Task Invoke(HttpContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + return context.Response.WriteAsync(context.Response.StatusCode.ToString()); + } + + } +} diff --git a/SampleDestination/hosting.json b/SampleDestination/hosting.json new file mode 100644 index 0000000000..804f92d481 --- /dev/null +++ b/SampleDestination/hosting.json @@ -0,0 +1,3 @@ +{ + "server.urls": "http://destination.sample.com:80" +} \ No newline at end of file diff --git a/SampleDestination/project.json b/SampleDestination/project.json new file mode 100644 index 0000000000..6cb1686ef0 --- /dev/null +++ b/SampleDestination/project.json @@ -0,0 +1,50 @@ +{ + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.1.0-*", + "type": "platform" + }, + "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", + "Microsoft.AspNetCore.Cors": "1.2.0-*", + "Microsoft.Extensions.Configuration.FileExtensions": "1.2.0-*", + "Microsoft.Extensions.Configuration.Json": "1.2.0-preview1-*" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "web.config" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } +} diff --git a/SampleDestination/web.config b/SampleDestination/web.config new file mode 100644 index 0000000000..dc0514fca5 --- /dev/null +++ b/SampleDestination/web.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/SampleOrigin/Program.cs b/SampleOrigin/Program.cs new file mode 100644 index 0000000000..68ec70a0b2 --- /dev/null +++ b/SampleOrigin/Program.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace SampleOrigin +{ + public class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("hosting.json", optional: true) + .Build(); + + var host = new WebHostBuilder() + .UseKestrel() + .UseConfiguration(config) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } + +} diff --git a/SampleOrigin/SampleOrigin.xproj b/SampleOrigin/SampleOrigin.xproj new file mode 100644 index 0000000000..2241431ad0 --- /dev/null +++ b/SampleOrigin/SampleOrigin.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 99460370-ae5d-4dc9-8dbf-04df66d6b21d + SampleOrigin + .\obj + .\bin\ + v4.5.2 + + + + 2.0 + + + + + + + diff --git a/SampleOrigin/Startup.cs b/SampleOrigin/Startup.cs new file mode 100644 index 0000000000..68a679aec2 --- /dev/null +++ b/SampleOrigin/Startup.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System.IO; + +namespace SampleOrigin +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseDefaultFiles(); + app.UseStaticFiles(); + } + } +} diff --git a/SampleOrigin/hosting.json b/SampleOrigin/hosting.json new file mode 100644 index 0000000000..7d79e9d594 --- /dev/null +++ b/SampleOrigin/hosting.json @@ -0,0 +1,3 @@ +{ + "server.urls": "http://origin.sample.com:8080" +} \ No newline at end of file diff --git a/SampleOrigin/project.json b/SampleOrigin/project.json new file mode 100644 index 0000000000..130536ee70 --- /dev/null +++ b/SampleOrigin/project.json @@ -0,0 +1,50 @@ +{ + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.1.0-*", + "type": "platform" + }, + "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", + "Microsoft.Extensions.Configuration.FileExtensions": "1.2.0-*", + "Microsoft.Extensions.Configuration.Json": "1.2.0-*" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "web.config" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } +} diff --git a/SampleOrigin/web.config b/SampleOrigin/web.config new file mode 100644 index 0000000000..dc0514fca5 --- /dev/null +++ b/SampleOrigin/web.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/SampleOrigin/wwwroot/Index.html b/SampleOrigin/wwwroot/Index.html new file mode 100644 index 0000000000..3bc55efdbe --- /dev/null +++ b/SampleOrigin/wwwroot/Index.html @@ -0,0 +1,49 @@ + + + + + + + + +
+ +
+
+ +
+ + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index 87343b2f9f..b52e000fa8 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -83,8 +83,8 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure if (string.Equals(context.Request.Method, CorsConstants.PreflightHttpMethod, StringComparison.OrdinalIgnoreCase) && !StringValues.IsNullOrEmpty(accessControlRequestMethod)) { - EvaluatePreflightRequest(context, policy, corsResult); _logger?.IsPreflightRequest(); + EvaluatePreflightRequest(context, policy, corsResult); } else { @@ -105,6 +105,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure _logger?.RequestHasOriginHeader(); AddOriginToResult(origin, policy, result); result.SupportsCredentials = policy.SupportsCredentials; + _logger?.PolicySuccess(); AddHeaderValues(result.AllowedExposedHeaders, policy.ExposedHeaders); } @@ -141,7 +142,8 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure if (!found) { - return; + _logger?.PolicyFailure($"Request method {accessControlRequestMethod} not allowed in CORS policy."); + return; } } @@ -150,6 +152,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure !requestHeaders.All(header => CorsConstants.SimpleRequestHeaders.Contains(header, StringComparer.OrdinalIgnoreCase) || policy.Headers.Contains(header, StringComparer.OrdinalIgnoreCase))) { + _logger?.PolicyFailure($"One or more request header(s) not allowed in CORS policy."); return; } @@ -157,7 +160,8 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure result.SupportsCredentials = policy.SupportsCredentials; result.PreflightMaxAge = policy.PreflightMaxAge; result.AllowedMethods.Add(accessControlRequestMethod); - AddHeaderValues(result.AllowedHeaders, requestHeaders); + _logger?.PolicySuccess(); + AddHeaderValues(result.AllowedHeaders, requestHeaders); } /// diff --git a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs index 7672797458..dc63aaf2ae 100644 --- a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs @@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Cors.Internal _policyFailure = LoggerMessage.Define( LogLevel.Information, 3, - "Policy execution failed. '{FailureReason}'"); + "Policy execution failed. {FailureReason}"); } public static void IsPreflightRequest(this ILogger logger) @@ -46,10 +46,11 @@ namespace Microsoft.AspNetCore.Cors.Internal _requestHasOriginHeader(logger, null); } - public static void PolicySuccess(this ILogger logger, string failureReason) + public static void PolicySuccess(this ILogger logger) { _policySuccess(logger, null); } + public static void PolicyFailure(this ILogger logger, string failureReason) { _policyFailure(logger, failureReason, null); diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index fae16fb6a1..c707dd94a2 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -23,6 +23,7 @@ "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", "Microsoft.Extensions.Configuration.Abstractions": "1.2.0-*", "Microsoft.Extensions.DependencyInjection.Abstractions": "1.2.0-*", + "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", "Microsoft.Extensions.Options": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, From 517dc3c86015415c9efe64395c49b90fa2ec909b Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Wed, 16 Nov 2016 18:25:15 -0800 Subject: [PATCH 141/271] Added tests for logging --- .../Infrastructure/CorsService.cs | 22 +++++- .../CorsServiceTests.cs | 76 +++++++++++++++++++ 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index b52e000fa8..72e17d5365 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -97,26 +97,40 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure public virtual void EvaluateRequest(HttpContext context, CorsPolicy policy, CorsResult result) { var origin = context.Request.Headers[CorsConstants.Origin]; - if (StringValues.IsNullOrEmpty(origin) || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + if (StringValues.IsNullOrEmpty(origin)) { return; } + if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + { + _logger?.RequestHasOriginHeader(); + _logger.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); + return; + } + _logger?.RequestHasOriginHeader(); AddOriginToResult(origin, policy, result); result.SupportsCredentials = policy.SupportsCredentials; - _logger?.PolicySuccess(); AddHeaderValues(result.AllowedExposedHeaders, policy.ExposedHeaders); + _logger?.PolicySuccess(); } public virtual void EvaluatePreflightRequest(HttpContext context, CorsPolicy policy, CorsResult result) { var origin = context.Request.Headers[CorsConstants.Origin]; - if (StringValues.IsNullOrEmpty(origin) || !policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + if (StringValues.IsNullOrEmpty(origin)) { return; } + if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) + { + _logger?.RequestHasOriginHeader(); + _logger.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); + return; + } + _logger?.RequestHasOriginHeader(); var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (StringValues.IsNullOrEmpty(accessControlRequestMethod)) @@ -160,8 +174,8 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure result.SupportsCredentials = policy.SupportsCredentials; result.PreflightMaxAge = policy.PreflightMaxAge; result.AllowedMethods.Add(accessControlRequestMethod); + AddHeaderValues(result.AllowedHeaders, requestHeaders); _logger?.PolicySuccess(); - AddHeaderValues(result.AllowedHeaders, requestHeaders); } /// diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index b3a92a8d68..617155ea43 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -4,6 +4,7 @@ using System; using Microsoft.AspNetCore.Http; using Xunit; +using Microsoft.Extensions.Logging.Testing; namespace Microsoft.AspNetCore.Cors.Infrastructure { @@ -227,6 +228,81 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Contains("PUT", result.AllowedMethods); } + public static TheoryData LoggingData + { + get + { + return new TheoryData + { + { + "http://example.com", + "PUT", + null, + "Policy execution failed. Request origin http://example.com does not have permission to access the resource." + }, + { + "http://allowedexample.com", + "DELETE", + null, + "Policy execution failed. Request method DELETE not allowed in CORS policy." + }, + { + "http://allowedexample.com", + "PUT", + new[] { "test" }, + "Policy execution failed. One or more request header(s) not allowed in CORS policy." + }, + { + "http://allowedexample.com", + "PUT", + null, + "Policy execution successful." + }, + }; + } + } + + [Theory] + [MemberData(nameof(LoggingData))] + public void EvaluatePolicy_LoggingForPreflightRequests(string origin, string method, string[] headers, string logMessage) + { + var sink = new TestSink(); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); + + var corsService = new CorsService(new TestCorsOptions(), loggerFactory); + var requestContext = GetHttpContext(method: "OPTIONS", origin: origin, accessControlRequestMethod: method, accessControlRequestHeaders: headers); + var policy = new CorsPolicy(); + policy.Origins.Add("http://allowedexample.com"); + policy.Methods.Add("PUT"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + Assert.Equal("The request is preflight.", sink.Writes[0].State.ToString()); + Assert.Equal("The request has an origin header.", sink.Writes[1].State.ToString()); + Assert.Equal(logMessage, sink.Writes[2].State.ToString()); + } + + [Theory] + [InlineData("http://allowedexample.com", "Policy execution successful.")] + [InlineData("http://example.com", "Policy execution failed. Request origin http://example.com does not have permission to access the resource.")] + public void EvaluatePolicy_LoggingForRequests(string origin, string logMessage) + { + var sink = new TestSink(); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); + + var corsService = new CorsService(new TestCorsOptions(), loggerFactory); + var requestContext = GetHttpContext(origin: origin); + var policy = new CorsPolicy(); + policy.Origins.Add("http://allowedexample.com"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + Assert.Equal("The request has an origin header.", sink.Writes[0].State.ToString()); + Assert.Equal(logMessage, sink.Writes[1].State.ToString()); + } + [Theory] [InlineData("OpTions")] [InlineData("OPTIONS")] From 5dcf47ef121a0a779d4805459ffc0aa6ee26a0f6 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Thu, 17 Nov 2016 17:36:18 -0800 Subject: [PATCH 142/271] PR comments incorporated --- SampleDestination/Startup.cs | 36 ------- SampleDestination/StatusMiddleware.cs | 35 ------- SampleDestination/hosting.json | 3 - SampleOrigin/Startup.cs | 35 ------- SampleOrigin/hosting.json | 3 - samples/README.md | 28 ++++++ .../SampleDestination}/Program.cs | 15 +-- .../SampleDestination.xproj | 0 samples/SampleDestination/Startup.cs | 29 ++++++ .../SampleDestination}/project.json | 5 +- .../SampleDestination}/web.config | 0 .../SampleOrigin}/Program.cs | 15 +-- .../SampleOrigin}/SampleOrigin.xproj | 0 samples/SampleOrigin/Startup.cs | 36 +++++++ .../SampleOrigin}/project.json | 6 +- .../SampleOrigin}/web.config | 0 .../SampleOrigin}/wwwroot/Index.html | 2 +- .../Infrastructure/CorsService.cs | 6 +- .../Internal/CORSLoggerExtensions.cs | 17 +++- .../CorsServiceTests.cs | 94 +++++++++++++++---- 20 files changed, 199 insertions(+), 166 deletions(-) delete mode 100644 SampleDestination/Startup.cs delete mode 100644 SampleDestination/StatusMiddleware.cs delete mode 100644 SampleDestination/hosting.json delete mode 100644 SampleOrigin/Startup.cs delete mode 100644 SampleOrigin/hosting.json create mode 100644 samples/README.md rename {SampleDestination => samples/SampleDestination}/Program.cs (55%) rename {SampleDestination => samples/SampleDestination}/SampleDestination.xproj (100%) create mode 100644 samples/SampleDestination/Startup.cs rename {SampleOrigin => samples/SampleDestination}/project.json (80%) rename {SampleDestination => samples/SampleDestination}/web.config (100%) rename {SampleOrigin => samples/SampleOrigin}/Program.cs (55%) rename {SampleOrigin => samples/SampleOrigin}/SampleOrigin.xproj (100%) create mode 100644 samples/SampleOrigin/Startup.cs rename {SampleDestination => samples/SampleOrigin}/project.json (75%) rename {SampleOrigin => samples/SampleOrigin}/web.config (100%) rename {SampleOrigin => samples/SampleOrigin}/wwwroot/Index.html (95%) diff --git a/SampleDestination/Startup.cs b/SampleDestination/Startup.cs deleted file mode 100644 index 5ea6b6d284..0000000000 --- a/SampleDestination/Startup.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace SampleDestination -{ - public class Startup - { - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - services.AddCors(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) - { - loggerFactory.AddConsole(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseCors(policy => policy.WithOrigins("http://origin.sample.com:8080").WithMethods("GET")); - app.UseMiddleware(); - } -} -} diff --git a/SampleDestination/StatusMiddleware.cs b/SampleDestination/StatusMiddleware.cs deleted file mode 100644 index 1f47c634ad..0000000000 --- a/SampleDestination/StatusMiddleware.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.AspNetCore.Http; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace SampleDestination -{ - public class StatusMiddleware - { - /// - /// Instantiates a new . - /// - /// The next middleware in the pipeline. - public StatusMiddleware(RequestDelegate next) - { - } - - /// - /// Writes the status of the request sent in response. Does not invoke later middleware in the pipeline. - /// - /// The of the current request. - /// A that completes when writing to the response is done. - public Task Invoke(HttpContext context) - { - if (context == null) - { - throw new ArgumentNullException(nameof(context)); - } - - return context.Response.WriteAsync(context.Response.StatusCode.ToString()); - } - - } -} diff --git a/SampleDestination/hosting.json b/SampleDestination/hosting.json deleted file mode 100644 index 804f92d481..0000000000 --- a/SampleDestination/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server.urls": "http://destination.sample.com:80" -} \ No newline at end of file diff --git a/SampleOrigin/Startup.cs b/SampleOrigin/Startup.cs deleted file mode 100644 index 68a679aec2..0000000000 --- a/SampleOrigin/Startup.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System.IO; - -namespace SampleOrigin -{ - public class Startup - { - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) - { - loggerFactory.AddConsole(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseDefaultFiles(); - app.UseStaticFiles(); - } - } -} diff --git a/SampleOrigin/hosting.json b/SampleOrigin/hosting.json deleted file mode 100644 index 7d79e9d594..0000000000 --- a/SampleOrigin/hosting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "server.urls": "http://origin.sample.com:8080" -} \ No newline at end of file diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 0000000000..c0b4a4414e --- /dev/null +++ b/samples/README.md @@ -0,0 +1,28 @@ +CORS Sample +=== +This sample consists of a request origin (SampleOrigin) and a request destination (SampleDestination). +Both have different domain names, to simulate a CORS request. + +Modify Hosts File +Windows: +Run a text editor (e.g. Notepad) as an Administrator. Open the hosts file on the path: "C:\Windows\System32\drivers\etc\hosts". + +Linux: +On a Terminal window, type "sudo nano /etc/hosts" and enter your admin password when prompted. + +In the hosts file, add the following to the bottom of the file: +127.0.0.1 destination.example.com +127.0.0.1 origin.example.com + +Save the file and close it. Then clear your browser history. + +Run the sample +*In a command prompt window, open the directory where you cloned the repository, and open the SampleDestination directory. Run the command: dotnet run +*Repeat the above step in the SampleOrigin directory. +*Open a browser window and go to http://origin.example.com +*Click the button to see CORS in action. + +If using Visual Studio to launch the request origin: +Open Visual Studio and in the launchSettings.json file for the SampleOrigin project, change the launchUrl under SampleOrigin to +http://origin.example.com:8080. Using the dropdown near the Start button, choose SampleOrigin before pressing Start to ensure that it uses Kestrel +and not IIS Express. diff --git a/SampleDestination/Program.cs b/samples/SampleDestination/Program.cs similarity index 55% rename from SampleDestination/Program.cs rename to samples/SampleDestination/Program.cs index 972cde8b8b..d964f308f5 100644 --- a/SampleDestination/Program.cs +++ b/samples/SampleDestination/Program.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System.IO; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; namespace SampleDestination { @@ -12,14 +10,9 @@ namespace SampleDestination { public static void Main(string[] args) { - var config = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("hosting.json", optional: true) - .Build(); - var host = new WebHostBuilder() .UseKestrel() - .UseConfiguration(config) + .UseUrls("http://*:5000") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/SampleDestination/SampleDestination.xproj b/samples/SampleDestination/SampleDestination.xproj similarity index 100% rename from SampleDestination/SampleDestination.xproj rename to samples/SampleDestination/SampleDestination.xproj diff --git a/samples/SampleDestination/Startup.cs b/samples/SampleDestination/Startup.cs new file mode 100644 index 0000000000..1055b9f224 --- /dev/null +++ b/samples/SampleDestination/Startup.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace SampleDestination +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddCors(); + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + app.UseCors(policy => policy.WithOrigins("http://origin.example.com:8080")); + app.Run(async context => + { + await context.Response.WriteAsync("Status code of your request: " + context.Response.StatusCode.ToString()); + }); + } + } +} diff --git a/SampleOrigin/project.json b/samples/SampleDestination/project.json similarity index 80% rename from SampleOrigin/project.json rename to samples/SampleDestination/project.json index 130536ee70..4e96e2c773 100644 --- a/SampleOrigin/project.json +++ b/samples/SampleDestination/project.json @@ -4,13 +4,10 @@ "version": "1.1.0-*", "type": "platform" }, - "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.AspNetCore.StaticFiles": "1.2.0-*", - "Microsoft.Extensions.Configuration.FileExtensions": "1.2.0-*", - "Microsoft.Extensions.Configuration.Json": "1.2.0-*" + "Microsoft.AspNetCore.Cors": "1.2.0-*" }, "tools": { diff --git a/SampleDestination/web.config b/samples/SampleDestination/web.config similarity index 100% rename from SampleDestination/web.config rename to samples/SampleDestination/web.config diff --git a/SampleOrigin/Program.cs b/samples/SampleOrigin/Program.cs similarity index 55% rename from SampleOrigin/Program.cs rename to samples/SampleOrigin/Program.cs index 68ec70a0b2..3a51bfdf8b 100644 --- a/SampleOrigin/Program.cs +++ b/samples/SampleOrigin/Program.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System.IO; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; namespace SampleOrigin { @@ -12,14 +10,9 @@ namespace SampleOrigin { public static void Main(string[] args) { - var config = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("hosting.json", optional: true) - .Build(); - var host = new WebHostBuilder() .UseKestrel() - .UseConfiguration(config) + .UseUrls("http://*:8080") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/SampleOrigin/SampleOrigin.xproj b/samples/SampleOrigin/SampleOrigin.xproj similarity index 100% rename from SampleOrigin/SampleOrigin.xproj rename to samples/SampleOrigin/SampleOrigin.xproj diff --git a/samples/SampleOrigin/Startup.cs b/samples/SampleOrigin/Startup.cs new file mode 100644 index 0000000000..01e05c1b4d --- /dev/null +++ b/samples/SampleOrigin/Startup.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace SampleOrigin +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + app.Run( context => + { + var fileInfoProvider = env.WebRootFileProvider; + var fileInfo = fileInfoProvider.GetFileInfo("/Index.html"); + context.Response.Headers.Add("Content-Type", "text/html; charset=utf-8"); + return context.Response.SendFileAsync(fileInfo); + }); + + app.Run(async context => + { + await context.Response.WriteAsync("Status code of your request: " + context.Response.StatusCode.ToString()); + }); + + } + } +} diff --git a/SampleDestination/project.json b/samples/SampleOrigin/project.json similarity index 75% rename from SampleDestination/project.json rename to samples/SampleOrigin/project.json index 6cb1686ef0..b4165727fd 100644 --- a/SampleDestination/project.json +++ b/samples/SampleOrigin/project.json @@ -4,13 +4,9 @@ "version": "1.1.0-*", "type": "platform" }, - "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.AspNetCore.Cors": "1.2.0-*", - "Microsoft.Extensions.Configuration.FileExtensions": "1.2.0-*", - "Microsoft.Extensions.Configuration.Json": "1.2.0-preview1-*" + "Microsoft.Extensions.Logging.Console": "1.2.0-*" }, "tools": { diff --git a/SampleOrigin/web.config b/samples/SampleOrigin/web.config similarity index 100% rename from SampleOrigin/web.config rename to samples/SampleOrigin/web.config diff --git a/SampleOrigin/wwwroot/Index.html b/samples/SampleOrigin/wwwroot/Index.html similarity index 95% rename from SampleOrigin/wwwroot/Index.html rename to samples/SampleOrigin/wwwroot/Index.html index 3bc55efdbe..d9d8b74672 100644 --- a/SampleOrigin/wwwroot/Index.html +++ b/samples/SampleOrigin/wwwroot/Index.html @@ -14,7 +14,7 @@ function makeCORSRequest(method) { // Destination server with CORS enabled. - var url = 'http://destination.sample.com/api'; + var url = 'http://destination.example.com:5000/api'; var request = createCORSRequest(method , url); if (!request) { diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index 72e17d5365..c8a8e54d4e 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -99,13 +99,14 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var origin = context.Request.Headers[CorsConstants.Origin]; if (StringValues.IsNullOrEmpty(origin)) { + _logger?.RequestDoesNotHaveOriginHeader(); return; } if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) { _logger?.RequestHasOriginHeader(); - _logger.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); + _logger?.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); return; } @@ -121,13 +122,14 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var origin = context.Request.Headers[CorsConstants.Origin]; if (StringValues.IsNullOrEmpty(origin)) { + _logger?.RequestDoesNotHaveOriginHeader(); return; } if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) { _logger?.RequestHasOriginHeader(); - _logger.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); + _logger?.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); return; } diff --git a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs index dc63aaf2ae..e744e95565 100644 --- a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs @@ -10,6 +10,7 @@ namespace Microsoft.AspNetCore.Cors.Internal { private static readonly Action _isPreflightRequest; private static readonly Action _requestHasOriginHeader; + private static readonly Action _requestDoesNotHaveOriginHeader; private static readonly Action _policySuccess; private static readonly Action _policyFailure; @@ -18,21 +19,26 @@ namespace Microsoft.AspNetCore.Cors.Internal _isPreflightRequest = LoggerMessage.Define( LogLevel.Debug, 1, - "The request is preflight."); + "This is a preflight request."); _requestHasOriginHeader = LoggerMessage.Define( LogLevel.Debug, 2, "The request has an origin header."); + _requestDoesNotHaveOriginHeader = LoggerMessage.Define( + LogLevel.Debug, + 3, + "The request does not have an origin header."); + _policySuccess = LoggerMessage.Define( LogLevel.Information, - 3, + 4, "Policy execution successful."); _policyFailure = LoggerMessage.Define( LogLevel.Information, - 3, + 5, "Policy execution failed. {FailureReason}"); } @@ -46,6 +52,11 @@ namespace Microsoft.AspNetCore.Cors.Internal _requestHasOriginHeader(logger, null); } + public static void RequestDoesNotHaveOriginHeader(this ILogger logger) + { + _requestDoesNotHaveOriginHeader(logger, null); + } + public static void PolicySuccess(this ILogger logger) { _policySuccess(logger, null); diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index 617155ea43..d20adfaa4b 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -228,34 +228,38 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Contains("PUT", result.AllowedMethods); } - public static TheoryData LoggingData + public static TheoryData PreflightRequests_LoggingData { get { - return new TheoryData + return new TheoryData { { "http://example.com", "PUT", null, + "The request has an origin header.", "Policy execution failed. Request origin http://example.com does not have permission to access the resource." }, { - "http://allowedexample.com", + "http://allowed.example.com", "DELETE", null, + "The request has an origin header.", "Policy execution failed. Request method DELETE not allowed in CORS policy." }, { - "http://allowedexample.com", + "http://allowed.example.com", "PUT", new[] { "test" }, + "The request has an origin header.", "Policy execution failed. One or more request header(s) not allowed in CORS policy." }, { - "http://allowedexample.com", + "http://allowed.example.com", "PUT", null, + "The request has an origin header.", "Policy execution successful." }, }; @@ -263,8 +267,8 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure } [Theory] - [MemberData(nameof(LoggingData))] - public void EvaluatePolicy_LoggingForPreflightRequests(string origin, string method, string[] headers, string logMessage) + [MemberData(nameof(PreflightRequests_LoggingData))] + public void EvaluatePolicy_LoggingForPreflightRequests_HasOriginHeader(string origin, string method, string[] headers, string originLogMessage, string policyLogMessage) { var sink = new TestSink(); var loggerFactory = new TestLoggerFactory(sink, enabled: true); @@ -272,21 +276,59 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var corsService = new CorsService(new TestCorsOptions(), loggerFactory); var requestContext = GetHttpContext(method: "OPTIONS", origin: origin, accessControlRequestMethod: method, accessControlRequestHeaders: headers); var policy = new CorsPolicy(); - policy.Origins.Add("http://allowedexample.com"); + policy.Origins.Add("http://allowed.example.com"); policy.Methods.Add("PUT"); // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("The request is preflight.", sink.Writes[0].State.ToString()); - Assert.Equal("The request has an origin header.", sink.Writes[1].State.ToString()); - Assert.Equal(logMessage, sink.Writes[2].State.ToString()); + Assert.Equal("This is a preflight request.", sink.Writes[0].State.ToString()); + Assert.Equal(originLogMessage, sink.Writes[1].State.ToString()); + Assert.Equal(policyLogMessage, sink.Writes[2].State.ToString()); + } + + [Fact] + public void EvaluatePolicy_LoggingForPreflightRequests_DoesNotHaveOriginHeader() + { + var sink = new TestSink(); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); + + var corsService = new CorsService(new TestCorsOptions(), loggerFactory); + var requestContext = GetHttpContext(method: "OPTIONS", origin: null, accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy(); + policy.Origins.Add("http://allowed.example.com"); + policy.Methods.Add("PUT"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + Assert.Equal("This is a preflight request.", sink.Writes[0].State.ToString()); + Assert.Equal("The request does not have an origin header.", sink.Writes[1].State.ToString()); + } + + public static TheoryData NonPreflightRequests_LoggingData + { + get + { + return new TheoryData + { + { + "http://example.com", + "The request has an origin header.", + "Policy execution failed. Request origin http://example.com does not have permission to access the resource." + }, + { + "http://allowed.example.com", + "The request has an origin header.", + "Policy execution successful." + } + }; + } } [Theory] - [InlineData("http://allowedexample.com", "Policy execution successful.")] - [InlineData("http://example.com", "Policy execution failed. Request origin http://example.com does not have permission to access the resource.")] - public void EvaluatePolicy_LoggingForRequests(string origin, string logMessage) + [MemberData(nameof(NonPreflightRequests_LoggingData))] + public void EvaluatePolicy_LoggingForNonPreflightRequests_HasOriginHeader(string origin, string originlogMessage, string policyLogMessage) { var sink = new TestSink(); var loggerFactory = new TestLoggerFactory(sink, enabled: true); @@ -294,13 +336,31 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure var corsService = new CorsService(new TestCorsOptions(), loggerFactory); var requestContext = GetHttpContext(origin: origin); var policy = new CorsPolicy(); - policy.Origins.Add("http://allowedexample.com"); + policy.Origins.Add("http://allowed.example.com"); // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("The request has an origin header.", sink.Writes[0].State.ToString()); - Assert.Equal(logMessage, sink.Writes[1].State.ToString()); + Assert.Equal(originlogMessage, sink.Writes[0].State.ToString()); + Assert.Equal(policyLogMessage, sink.Writes[1].State.ToString()); + } + + [Fact] + public void EvaluatePolicy_LoggingForNonPreflightRequests_DoesNotHaveOriginHeader() + { + var sink = new TestSink(); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); + + var corsService = new CorsService(new TestCorsOptions(), loggerFactory); + var requestContext = GetHttpContext(origin: null); + var policy = new CorsPolicy(); + policy.Origins.Add("http://allowed.example.com"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + var logMessage = Assert.Single(sink.Writes); + Assert.Equal("The request does not have an origin header.", logMessage.State.ToString()); } [Theory] From 46b2d52d7419c9780326af730ea8cd52ccf26d59 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 18 Nov 2016 10:57:02 -0800 Subject: [PATCH 143/271] Clean tmp folder after unzipping KoreBuild --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index f4208100eb..4fd7ede788 100755 --- a/build.sh +++ b/build.sh @@ -38,7 +38,7 @@ if test ! -d $buildFolder; then chmod +x $buildFile # Cleanup - if test ! -d $tempFolder; then + if test -d $tempFolder; then rm -rf $tempFolder fi fi From b3bdba15591145856925a19a7f2d9c6c57891acf Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Mon, 21 Nov 2016 15:31:14 -0800 Subject: [PATCH 144/271] PR comments incorporated. Working on making SampleDestination dynamic- define the policy within the sample through a UI. --- CORS.sln | 4 +- samples/README.md | 8 +- samples/SampleDestination/Program.cs | 1 - samples/SampleDestination/Startup.cs | 16 +- samples/SampleDestination/project.json | 12 +- samples/SampleDestination/web.config | 14 -- samples/SampleOrigin/Program.cs | 3 +- samples/SampleOrigin/project.json | 12 +- samples/SampleOrigin/web.config | 11 +- samples/SampleOrigin/wwwroot/Index.html | 94 +++++++++--- .../Infrastructure/CorsService.cs | 35 +++-- .../Internal/CORSLoggerExtensions.cs | 55 +++++-- .../CorsServiceTests.cs | 143 +++++++++++------- 13 files changed, 253 insertions(+), 155 deletions(-) delete mode 100644 samples/SampleDestination/web.config diff --git a/CORS.sln b/CORS.sln index 87e766660f..c471720431 100644 --- a/CORS.sln +++ b/CORS.sln @@ -21,9 +21,9 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CorsMiddlewareWebSite", "te EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{960E0703-A8A5-44DF-AA87-B7C614683B3C}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleDestination", "SampleDestination\SampleDestination.xproj", "{F6675DC1-AA21-453B-89B6-DA425FB9C3A5}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleDestination", "samples\SampleDestination\SampleDestination.xproj", "{F6675DC1-AA21-453B-89B6-DA425FB9C3A5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleOrigin", "SampleOrigin\SampleOrigin.xproj", "{99460370-AE5D-4DC9-8DBF-04DF66D6B21D}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleOrigin", "samples\SampleOrigin\SampleOrigin.xproj", "{99460370-AE5D-4DC9-8DBF-04DF66D6B21D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/samples/README.md b/samples/README.md index c0b4a4414e..ce871c4940 100644 --- a/samples/README.md +++ b/samples/README.md @@ -19,9 +19,15 @@ Save the file and close it. Then clear your browser history. Run the sample *In a command prompt window, open the directory where you cloned the repository, and open the SampleDestination directory. Run the command: dotnet run *Repeat the above step in the SampleOrigin directory. -*Open a browser window and go to http://origin.example.com +*Open a browser window and go to http://origin.example.com:5001 *Click the button to see CORS in action. +The SampleOrigin application will use port 5001, and SampleDestination will use 5000. Please ensure there are no other processes using those ports before running the CORS sample. + +As an example, apart from GET, HEAD and POST requests, PUT requests are allowed in the CORS policy on SampleDestination. Any others, like DELETE, OPTIONS etc. are not allowed and throw an error. +Content-Length has been added as an allowed header to the sample. Any other headers are not allowed and throw an error. +To edit the policy, please see app.UseCors() method in the Startup.cs file of SampleDestination. + If using Visual Studio to launch the request origin: Open Visual Studio and in the launchSettings.json file for the SampleOrigin project, change the launchUrl under SampleOrigin to http://origin.example.com:8080. Using the dropdown near the Start button, choose SampleOrigin before pressing Start to ensure that it uses Kestrel diff --git a/samples/SampleDestination/Program.cs b/samples/SampleDestination/Program.cs index d964f308f5..c196d5b838 100644 --- a/samples/SampleDestination/Program.cs +++ b/samples/SampleDestination/Program.cs @@ -14,7 +14,6 @@ namespace SampleDestination .UseKestrel() .UseUrls("http://*:5000") .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/SampleDestination/Startup.cs b/samples/SampleDestination/Startup.cs index 1055b9f224..199bb16795 100644 --- a/samples/SampleDestination/Startup.cs +++ b/samples/SampleDestination/Startup.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; @@ -19,10 +20,21 @@ namespace SampleDestination public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); - app.UseCors(policy => policy.WithOrigins("http://origin.example.com:8080")); + + app.UseCors(policy => policy + .WithOrigins("http://origin.example.com:5001") + .WithMethods("PUT") + .WithHeaders("Content-Length")); + app.Run(async context => { - await context.Response.WriteAsync("Status code of your request: " + context.Response.StatusCode.ToString()); + var responseHeaders = context.Response.Headers; + foreach (var responseHeader in responseHeaders) + { + await context.Response.WriteAsync("\n"+responseHeader.Key+": "+responseHeader.Value); + } + + await context.Response.WriteAsync("\nStatus code of your request: " + context.Response.StatusCode.ToString()); }); } } diff --git a/samples/SampleDestination/project.json b/samples/SampleDestination/project.json index 4e96e2c773..3c86825eb6 100644 --- a/samples/SampleDestination/project.json +++ b/samples/SampleDestination/project.json @@ -4,16 +4,11 @@ "version": "1.1.0-*", "type": "platform" }, - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.AspNetCore.Cors": "1.2.0-*" }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "frameworks": { "netcoreapp1.0": { "imports": [ @@ -36,12 +31,7 @@ "publishOptions": { "include": [ - "wwwroot", - "web.config" + "wwwroot" ] - }, - - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] } } diff --git a/samples/SampleDestination/web.config b/samples/SampleDestination/web.config deleted file mode 100644 index dc0514fca5..0000000000 --- a/samples/SampleDestination/web.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/samples/SampleOrigin/Program.cs b/samples/SampleOrigin/Program.cs index 3a51bfdf8b..1a6960a91f 100644 --- a/samples/SampleOrigin/Program.cs +++ b/samples/SampleOrigin/Program.cs @@ -12,9 +12,8 @@ namespace SampleOrigin { var host = new WebHostBuilder() .UseKestrel() - .UseUrls("http://*:8080") + .UseUrls("http://*:5001") .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() .UseStartup() .Build(); diff --git a/samples/SampleOrigin/project.json b/samples/SampleOrigin/project.json index b4165727fd..259fb617c3 100644 --- a/samples/SampleOrigin/project.json +++ b/samples/SampleOrigin/project.json @@ -4,15 +4,10 @@ "version": "1.1.0-*", "type": "platform" }, - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*" }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "frameworks": { "netcoreapp1.0": { "imports": [ @@ -35,12 +30,7 @@ "publishOptions": { "include": [ - "wwwroot", - "web.config" + "wwwroot" ] - }, - - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] } } diff --git a/samples/SampleOrigin/web.config b/samples/SampleOrigin/web.config index dc0514fca5..e04a0397bf 100644 --- a/samples/SampleOrigin/web.config +++ b/samples/SampleOrigin/web.config @@ -1,14 +1,9 @@  - - - - + - + - + \ No newline at end of file diff --git a/samples/SampleOrigin/wwwroot/Index.html b/samples/SampleOrigin/wwwroot/Index.html index d9d8b74672..dd2c4f0ae9 100644 --- a/samples/SampleOrigin/wwwroot/Index.html +++ b/samples/SampleOrigin/wwwroot/Index.html @@ -2,30 +2,56 @@ - - - - -
- -
-
- -
+

CORS Sample

+ Method:

+ Header Name: Header Value:

+ + +



+ + Method DELETE is not allowed: + Method PUT is allowed:

+ + Header 'Max-Forwards' not supported: + Header 'Content-Length' is supported:

\ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index c8a8e54d4e..32aea828c5 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure ///
/// The option model representing . public CorsService(IOptions options) - :this(options, loggerFactory: null) + : this(options, loggerFactory: null) { } @@ -103,14 +103,14 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure return; } + _logger?.RequestHasOriginHeader(origin); if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) { - _logger?.RequestHasOriginHeader(); - _logger?.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); + _logger?.PolicyFailure(); + _logger?.OriginNotAllowed(origin); return; } - _logger?.RequestHasOriginHeader(); AddOriginToResult(origin, policy, result); result.SupportsCredentials = policy.SupportsCredentials; AddHeaderValues(result.AllowedExposedHeaders, policy.ExposedHeaders); @@ -126,14 +126,14 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure return; } + _logger?.RequestHasOriginHeader(origin); if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) { - _logger?.RequestHasOriginHeader(); - _logger?.PolicyFailure($"Request origin {origin} does not have permission to access the resource."); + _logger?.PolicyFailure(); + _logger?.OriginNotAllowed(origin); return; } - _logger?.RequestHasOriginHeader(); var accessControlRequestMethod = context.Request.Headers[CorsConstants.AccessControlRequestMethod]; if (StringValues.IsNullOrEmpty(accessControlRequestMethod)) { @@ -158,18 +158,25 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure if (!found) { - _logger?.PolicyFailure($"Request method {accessControlRequestMethod} not allowed in CORS policy."); - return; + _logger?.PolicyFailure(); + _logger?.AccessControlMethodNotAllowed(accessControlRequestMethod); + return; } } if (!policy.AllowAnyHeader && - requestHeaders != null && - !requestHeaders.All(header => CorsConstants.SimpleRequestHeaders.Contains(header, StringComparer.OrdinalIgnoreCase) || - policy.Headers.Contains(header, StringComparer.OrdinalIgnoreCase))) + requestHeaders != null) { - _logger?.PolicyFailure($"One or more request header(s) not allowed in CORS policy."); - return; + foreach (var requestHeader in requestHeaders) + { + if (!CorsConstants.SimpleRequestHeaders.Contains(requestHeader, StringComparer.OrdinalIgnoreCase) && + !policy.Headers.Contains(requestHeader, StringComparer.OrdinalIgnoreCase)) + { + _logger?.PolicyFailure(); + _logger?.RequestHeaderNotAllowed(requestHeader); + return; + } + } } AddOriginToResult(origin, policy, result); diff --git a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs index e744e95565..727d19a4ea 100644 --- a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs @@ -9,22 +9,25 @@ namespace Microsoft.AspNetCore.Cors.Internal internal static class CORSLoggerExtensions { private static readonly Action _isPreflightRequest; - private static readonly Action _requestHasOriginHeader; + private static readonly Action _requestHasOriginHeader; private static readonly Action _requestDoesNotHaveOriginHeader; private static readonly Action _policySuccess; - private static readonly Action _policyFailure; + private static readonly Action _policyFailure; + private static readonly Action _originNotAllowed; + private static readonly Action _accessControlMethodNotAllowed; + private static readonly Action _requestHeaderNotAllowed; static CORSLoggerExtensions() { _isPreflightRequest = LoggerMessage.Define( LogLevel.Debug, 1, - "This is a preflight request."); + "The request is a preflight request."); - _requestHasOriginHeader = LoggerMessage.Define( + _requestHasOriginHeader = LoggerMessage.Define( LogLevel.Debug, 2, - "The request has an origin header."); + "The request has an origin header: '{origin}'."); _requestDoesNotHaveOriginHeader = LoggerMessage.Define( LogLevel.Debug, @@ -36,10 +39,25 @@ namespace Microsoft.AspNetCore.Cors.Internal 4, "Policy execution successful."); - _policyFailure = LoggerMessage.Define( + _policyFailure = LoggerMessage.Define( LogLevel.Information, 5, - "Policy execution failed. {FailureReason}"); + "Policy execution failed."); + + _originNotAllowed = LoggerMessage.Define( + LogLevel.Information, + 6, + "Request origin {origin} does not have permission to access the resource."); + + _accessControlMethodNotAllowed = LoggerMessage.Define( + LogLevel.Information, + 7, + "Request method {accessControlRequestMethod} not allowed in CORS policy."); + + _requestHeaderNotAllowed = LoggerMessage.Define( + LogLevel.Information, + 8, + "Request header '{requestHeader}' not allowed in CORS policy."); } public static void IsPreflightRequest(this ILogger logger) @@ -47,9 +65,9 @@ namespace Microsoft.AspNetCore.Cors.Internal _isPreflightRequest(logger, null); } - public static void RequestHasOriginHeader(this ILogger logger) + public static void RequestHasOriginHeader(this ILogger logger, string origin) { - _requestHasOriginHeader(logger, null); + _requestHasOriginHeader(logger, origin, null); } public static void RequestDoesNotHaveOriginHeader(this ILogger logger) @@ -62,9 +80,24 @@ namespace Microsoft.AspNetCore.Cors.Internal _policySuccess(logger, null); } - public static void PolicyFailure(this ILogger logger, string failureReason) + public static void PolicyFailure(this ILogger logger) { - _policyFailure(logger, failureReason, null); + _policyFailure(logger, null); + } + + public static void OriginNotAllowed(this ILogger logger, string origin) + { + _originNotAllowed(logger, origin, null); + } + + public static void AccessControlMethodNotAllowed(this ILogger logger, string accessControlMethod) + { + _accessControlMethodNotAllowed(logger, accessControlMethod, null); + } + + public static void RequestHeaderNotAllowed(this ILogger logger, string requestHeader) + { + _requestHeaderNotAllowed(logger, requestHeader, null); } } } diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index d20adfaa4b..b3ce5927d8 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -228,39 +228,41 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Contains("PUT", result.AllowedMethods); } - public static TheoryData PreflightRequests_LoggingData + public static TheoryData PreflightRequests_LoggingData { get { - return new TheoryData + return new TheoryData { { - "http://example.com", - "PUT", - null, - "The request has an origin header.", - "Policy execution failed. Request origin http://example.com does not have permission to access the resource." + new LogData { + origin = "http://example.com", + method = "PUT", + headers = null, + originLogMessage = "The request has an origin header: 'http://example.com'.", + policyLogMessage = "Policy execution failed.", + failureReason = "Request origin http://example.com does not have permission to access the resource." + } }, { - "http://allowed.example.com", - "DELETE", - null, - "The request has an origin header.", - "Policy execution failed. Request method DELETE not allowed in CORS policy." + new LogData { + origin = "http://allowed.example.com", + method = "DELETE", + headers = null, + originLogMessage = "The request has an origin header: 'http://allowed.example.com'.", + policyLogMessage = "Policy execution failed.", + failureReason = "Request method DELETE not allowed in CORS policy." + } }, { - "http://allowed.example.com", - "PUT", - new[] { "test" }, - "The request has an origin header.", - "Policy execution failed. One or more request header(s) not allowed in CORS policy." - }, - { - "http://allowed.example.com", - "PUT", - null, - "The request has an origin header.", - "Policy execution successful." + new LogData { + origin = "http://allowed.example.com", + method = "PUT", + headers = new[] { "test" }, + originLogMessage = "The request has an origin header: 'http://allowed.example.com'.", + policyLogMessage = "Policy execution failed.", + failureReason = "Request header 'test' not allowed in CORS policy." + } }, }; } @@ -268,13 +270,13 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure [Theory] [MemberData(nameof(PreflightRequests_LoggingData))] - public void EvaluatePolicy_LoggingForPreflightRequests_HasOriginHeader(string origin, string method, string[] headers, string originLogMessage, string policyLogMessage) + public void EvaluatePolicy_LoggingForPreflightRequests_HasOriginHeader_PolicyFailed(LogData logData) { var sink = new TestSink(); var loggerFactory = new TestLoggerFactory(sink, enabled: true); var corsService = new CorsService(new TestCorsOptions(), loggerFactory); - var requestContext = GetHttpContext(method: "OPTIONS", origin: origin, accessControlRequestMethod: method, accessControlRequestHeaders: headers); + var requestContext = GetHttpContext(method: "OPTIONS", origin: logData.origin, accessControlRequestMethod: logData.method, accessControlRequestHeaders: logData.headers); var policy = new CorsPolicy(); policy.Origins.Add("http://allowed.example.com"); policy.Methods.Add("PUT"); @@ -282,9 +284,30 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("This is a preflight request.", sink.Writes[0].State.ToString()); - Assert.Equal(originLogMessage, sink.Writes[1].State.ToString()); - Assert.Equal(policyLogMessage, sink.Writes[2].State.ToString()); + Assert.Equal("The request is a preflight request.", sink.Writes[0].State.ToString()); + Assert.Equal(logData.originLogMessage, sink.Writes[1].State.ToString()); + Assert.Equal(logData.policyLogMessage, sink.Writes[2].State.ToString()); + Assert.Equal(logData.failureReason, sink.Writes[3].State.ToString()); + } + + [Fact] + public void EvaluatePolicy_LoggingForPreflightRequests_HasOriginHeader_PolicySucceeded() + { + var sink = new TestSink(); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); + + var corsService = new CorsService(new TestCorsOptions(), loggerFactory); + var requestContext = GetHttpContext(method: "OPTIONS", origin: "http://allowed.example.com", accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy(); + policy.Origins.Add("http://allowed.example.com"); + policy.Methods.Add("PUT"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + Assert.Equal("The request is a preflight request.", sink.Writes[0].State.ToString()); + Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", sink.Writes[1].State.ToString()); + Assert.Equal("Policy execution successful.", sink.Writes[2].State.ToString()); } [Fact] @@ -302,47 +325,45 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("This is a preflight request.", sink.Writes[0].State.ToString()); + Assert.Equal("The request is a preflight request.", sink.Writes[0].State.ToString()); Assert.Equal("The request does not have an origin header.", sink.Writes[1].State.ToString()); } - public static TheoryData NonPreflightRequests_LoggingData - { - get - { - return new TheoryData - { - { - "http://example.com", - "The request has an origin header.", - "Policy execution failed. Request origin http://example.com does not have permission to access the resource." - }, - { - "http://allowed.example.com", - "The request has an origin header.", - "Policy execution successful." - } - }; - } - } - - [Theory] - [MemberData(nameof(NonPreflightRequests_LoggingData))] - public void EvaluatePolicy_LoggingForNonPreflightRequests_HasOriginHeader(string origin, string originlogMessage, string policyLogMessage) + [Fact] + public void EvaluatePolicy_LoggingForNonPreflightRequests_HasOriginHeader_PolicyFailed() { var sink = new TestSink(); var loggerFactory = new TestLoggerFactory(sink, enabled: true); var corsService = new CorsService(new TestCorsOptions(), loggerFactory); - var requestContext = GetHttpContext(origin: origin); + var requestContext = GetHttpContext(origin: "http://example.com"); var policy = new CorsPolicy(); policy.Origins.Add("http://allowed.example.com"); // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal(originlogMessage, sink.Writes[0].State.ToString()); - Assert.Equal(policyLogMessage, sink.Writes[1].State.ToString()); + Assert.Equal("The request has an origin header: 'http://example.com'.", sink.Writes[0].State.ToString()); + Assert.Equal("Policy execution failed.", sink.Writes[1].State.ToString()); + Assert.Equal("Request origin http://example.com does not have permission to access the resource.", sink.Writes[2].State.ToString()); + } + + [Fact] + public void EvaluatePolicy_LoggingForNonPreflightRequests_HasOriginHeader_PolicySucceeded() + { + var sink = new TestSink(); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); + + var corsService = new CorsService(new TestCorsOptions(), loggerFactory); + var requestContext = GetHttpContext(origin: "http://allowed.example.com"); + var policy = new CorsPolicy(); + policy.Origins.Add("http://allowed.example.com"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", sink.Writes[0].State.ToString()); + Assert.Equal("Policy execution successful.", sink.Writes[1].State.ToString()); } [Fact] @@ -1049,5 +1070,15 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure return context; } + + public struct LogData + { + public string origin { get; set; } + public string method { get; set; } + public string[] headers { get; set; } + public string originLogMessage { get; set; } + public string policyLogMessage { get; set; } + public string failureReason { get; set; } + } } } \ No newline at end of file From 34aa1c572216438f07e46e21568416a7c30a377b Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Mon, 21 Nov 2016 15:38:39 -0800 Subject: [PATCH 145/271] README fixed --- samples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/README.md b/samples/README.md index ce871c4940..a0cd02d8fa 100644 --- a/samples/README.md +++ b/samples/README.md @@ -30,5 +30,5 @@ To edit the policy, please see app.UseCors() method in the Startup.cs file of Sa If using Visual Studio to launch the request origin: Open Visual Studio and in the launchSettings.json file for the SampleOrigin project, change the launchUrl under SampleOrigin to -http://origin.example.com:8080. Using the dropdown near the Start button, choose SampleOrigin before pressing Start to ensure that it uses Kestrel +http://origin.example.com:5001. Using the dropdown near the Start button, choose SampleOrigin before pressing Start to ensure that it uses Kestrel and not IIS Express. From 7b190ccf0f4342140928988008e6fa3af2067b84 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Mon, 21 Nov 2016 16:13:30 -0800 Subject: [PATCH 146/271] Changed allowed header to Cache-control to illustrate Access-Control-Allow-Headers and Access-Control-Request-Headers --- samples/SampleDestination/Startup.cs | 2 +- samples/SampleOrigin/wwwroot/Index.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/SampleDestination/Startup.cs b/samples/SampleDestination/Startup.cs index 199bb16795..9859aa3abb 100644 --- a/samples/SampleDestination/Startup.cs +++ b/samples/SampleDestination/Startup.cs @@ -24,7 +24,7 @@ namespace SampleDestination app.UseCors(policy => policy .WithOrigins("http://origin.example.com:5001") .WithMethods("PUT") - .WithHeaders("Content-Length")); + .WithHeaders("Cache-Control")); app.Run(async context => { diff --git a/samples/SampleOrigin/wwwroot/Index.html b/samples/SampleOrigin/wwwroot/Index.html index dd2c4f0ae9..6529ddb6ea 100644 --- a/samples/SampleOrigin/wwwroot/Index.html +++ b/samples/SampleOrigin/wwwroot/Index.html @@ -63,7 +63,7 @@

CORS Sample

Method:

- Header Name: Header Value:

+ Header Name: Header Value:

+

CORS Sample

Method:

- Header Name: Header Value:

+ Header Name: Header Value:





From b351e033f512e25a597336b7422a059654571fe9 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Wed, 23 Nov 2016 14:17:09 -0800 Subject: [PATCH 153/271] README formatting fixed --- samples/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/README.md b/samples/README.md index e4cb93b915..0224188d71 100644 --- a/samples/README.md +++ b/samples/README.md @@ -3,7 +3,7 @@ This sample consists of a request origin (SampleOrigin) and a request destination (SampleDestination). Both have different domain names, to simulate a CORS request. ## Modify Hosts File -To run this CORS sample, modify the hosts file to register the hostnames `destination.example.com` and `origin.example.com.` +To run this CORS sample, modify the hosts file to register the hostnames `destination.example.com` and `origin.example.com`. ### Windows: Run a text editor (e.g. Notepad) as an Administrator. Open the hosts file on the path: "C:\Windows\System32\drivers\etc\hosts". @@ -23,9 +23,9 @@ Save the file and close it. Then clear your browser history. The SampleOrigin application will use port 5001, and SampleDestination will use 5000. Please ensure there are no other processes using those ports before running the CORS sample. * In a command prompt window, open the directory where you cloned the repository, and open the SampleDestination directory. Run the command: dotnet run -* Repeat the above step in the SampleOrigin directory. +* Repeat the above step in the SampleOrigin directory * Open a browser window and go to `http://origin.example.com:5001` -* Input a method and header to create a CORS request or use one of the example buttons to see CORS in action. +* Input a method and header to create a CORS request or use one of the example buttons to see CORS in action As an example, apart from `GET`, `HEAD` and `POST` requests, `PUT` requests are allowed in the CORS policy on SampleDestination. Any others, like `DELETE`, `OPTIONS` etc. are not allowed and throw an error. `Cache-Control` has been added as an allowed header to the sample. Any other headers are not allowed and throw an error. You may leave the header name and value blank. From 2d916a8b48b83dcab8938ae269941a66d5297007 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 23 Nov 2016 15:59:52 -0800 Subject: [PATCH 154/271] Pin global.json SDK to 1.0.0-preview2-1-003177. --- global.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 262a7f2b59..520f9ba815 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,9 @@ { - "projects": ["src", "test/WebSites"] -} + "projects": [ + "src", + "test/WebSites" + ], + "sdk": { + "version": "1.0.0-preview2-1-003177" + } +} \ No newline at end of file From 8214954d5b0dafe191890da9a3de86f5b607ea69 Mon Sep 17 00:00:00 2001 From: Choc Date: Tue, 1 Nov 2016 15:31:05 -0700 Subject: [PATCH 155/271] Add support for clients to configure a policy with custom logic about whether an origin should be allowed and provide a default implementation of the functionality to allow wildcard subdomains --- .gitignore | 1 + .../Infrastructure/CorsPolicy.cs | 19 ++++++ .../Infrastructure/CorsPolicyBuilder.cs | 46 +++++++++---- .../Infrastructure/CorsPolicyExtensions.cs | 31 +++++++++ .../Infrastructure/CorsService.cs | 42 ++++++------ .../Infrastructure/UriHelpers.cs | 19 ++++++ .../Properties/AssemblyInfo.cs | 2 + .../CorsPolicyBuilderTests.cs | 32 +++++++++ .../CorsPolicyExtensionsTests.cs | 65 ++++++++++++++++++ .../CorsPolicyTests.cs | 1 + .../CorsServiceTests.cs | 42 ++++++++++++ .../UriHelpersTests.cs | 66 +++++++++++++++++++ .../project.json | 3 + .../CorsMiddlewareWebSite/project.json | 3 +- 14 files changed, 339 insertions(+), 33 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs create mode 100644 src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs create mode 100644 test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs create mode 100644 test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs diff --git a/.gitignore b/.gitignore index 5daa6eed09..cecfac6cc7 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ node_modules *launchSettings.json .build/ .testPublish/ +.vscode diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs index b1fc25a939..f541863c69 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; namespace Microsoft.AspNetCore.Cors.Infrastructure @@ -14,6 +15,14 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure { private TimeSpan? _preflightMaxAge; + /// + /// Default constructor for a CorsPolicy. + /// + public CorsPolicy() + { + IsOriginAllowed = DefaultIsOriginAllowed; + } + /// /// Gets a value indicating if all headers are allowed. /// @@ -62,6 +71,11 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure } } + /// + /// Gets or sets a function which evaluates whether an origin is allowed. + /// + public Func IsOriginAllowed { get; set; } + /// /// Gets the headers that the resource might use and can be exposed. /// @@ -141,5 +155,10 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure builder.Append("}"); return builder.ToString(); } + + private bool DefaultIsOriginAllowed(string origin) + { + return Origins.Contains(origin, StringComparer.Ordinal); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs index ed20996e5e..88e16fa0fa 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// Adds the specified to the policy. ///
/// The origins that are allowed. - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder WithOrigins(params string[] origins) { foreach (var req in origins) @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// Adds the specified to the policy. ///
/// The headers which need to be allowed in the request. - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder WithHeaders(params string[] headers) { foreach (var req in headers) @@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// Adds the specified to the policy. ///
/// The headers which need to be exposed to the client. - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder WithExposedHeaders(params string[] exposedHeaders) { foreach (var req in exposedHeaders) @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// Adds the specified to the policy. ///
/// The methods which need to be added to the policy. - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder WithMethods(params string[] methods) { foreach (var req in methods) @@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// /// Sets the policy to allow credentials. /// - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder AllowCredentials() { _policy.SupportsCredentials = true; @@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// /// Sets the policy to not allow credentials. /// - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder DisallowCredentials() { _policy.SupportsCredentials = false; @@ -113,7 +113,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// /// Ensures that the policy allows any origin. /// - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder AllowAnyOrigin() { _policy.Origins.Clear(); @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// /// Ensures that the policy allows any method. /// - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder AllowAnyMethod() { _policy.Methods.Clear(); @@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// /// Ensures that the policy allows any header. /// - /// The current policy builder + /// The current policy builder. public CorsPolicyBuilder AllowAnyHeader() { _policy.Headers.Clear(); @@ -148,13 +148,36 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure ///
/// A positive indicating the time a preflight /// request can be cached. - /// + /// The current policy builder. public CorsPolicyBuilder SetPreflightMaxAge(TimeSpan preflightMaxAge) { _policy.PreflightMaxAge = preflightMaxAge; return this; } + /// + /// Sets the specified for the underlying policy. + /// + /// The function used by the policy to evaluate if an origin is allowed. + /// The current policy builder. + public CorsPolicyBuilder SetIsOriginAllowed(Func isOriginAllowed) + { + _policy.IsOriginAllowed = isOriginAllowed; + return this; + } + + /// + /// Sets the property of the policy to be a function + /// that allows origins to match a configured wildcarded domain when evaluating if the + /// origin is allowed. + /// + /// The current policy builder. + public CorsPolicyBuilder SetIsOriginAllowedToAllowWildcardSubdomains() + { + _policy.IsOriginAllowed = _policy.IsOriginAnAllowedSubdomain; + return this; + } + /// /// Builds a new using the entries added. /// @@ -168,7 +191,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// Combines the given to the existing properties in the builder. ///
/// The policy which needs to be combined. - /// The current policy builder + /// The current policy builder. private CorsPolicyBuilder Combine(CorsPolicy policy) { if (policy == null) @@ -180,6 +203,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure WithHeaders(policy.Headers.ToArray()); WithExposedHeaders(policy.ExposedHeaders.ToArray()); WithMethods(policy.Methods.ToArray()); + SetIsOriginAllowed(policy.IsOriginAllowed); if (policy.PreflightMaxAge.HasValue) { diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs new file mode 100644 index 0000000000..deae787231 --- /dev/null +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; + +namespace Microsoft.AspNetCore.Cors.Infrastructure +{ + internal static class CorsPolicyExtensions + { + private const string _WildcardSubdomain = "*."; + + public static bool IsOriginAnAllowedSubdomain(this CorsPolicy policy, string origin) + { + if (policy.Origins.Contains(origin)) + { + return true; + } + var originUri = new Uri(origin, UriKind.Absolute); + return policy.Origins + .Where(o => o.Contains($"://{_WildcardSubdomain}")) + .Select(CreateDomainUri) + .Any(domain => UriHelpers.IsSubdomainOf(originUri, domain)); + } + + private static Uri CreateDomainUri(string origin) + { + return new Uri(origin.Replace(_WildcardSubdomain, string.Empty), UriKind.Absolute); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index 483cb3e59a..bd978495fb 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -97,17 +97,8 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure public virtual void EvaluateRequest(HttpContext context, CorsPolicy policy, CorsResult result) { var origin = context.Request.Headers[CorsConstants.Origin]; - if (StringValues.IsNullOrEmpty(origin)) + if (!IsOriginAllowed(policy, origin)) { - _logger?.RequestDoesNotHaveOriginHeader(); - return; - } - - _logger?.RequestHasOriginHeader(origin); - if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) - { - _logger?.PolicyFailure(); - _logger?.OriginNotAllowed(origin); return; } @@ -120,17 +111,8 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure public virtual void EvaluatePreflightRequest(HttpContext context, CorsPolicy policy, CorsResult result) { var origin = context.Request.Headers[CorsConstants.Origin]; - if (StringValues.IsNullOrEmpty(origin)) + if (!IsOriginAllowed(policy, origin)) { - _logger?.RequestDoesNotHaveOriginHeader(); - return; - } - - _logger?.RequestHasOriginHeader(origin); - if (!policy.AllowAnyOrigin && !policy.Origins.Contains(origin)) - { - _logger?.PolicyFailure(); - _logger?.OriginNotAllowed(origin); return; } @@ -286,7 +268,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure result.AllowedOrigin = CorsConstants.AnyOrigin; } } - else if (policy.Origins.Contains(origin)) + else if (policy.IsOriginAllowed(origin)) { result.AllowedOrigin = origin; } @@ -304,5 +286,23 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure target.Add(current); } } + + private bool IsOriginAllowed(CorsPolicy policy, StringValues origin) + { + if (StringValues.IsNullOrEmpty(origin)) + { + _logger?.RequestDoesNotHaveOriginHeader(); + return false; + } + + _logger?.RequestHasOriginHeader(origin); + if (policy.AllowAnyOrigin || policy.IsOriginAllowed(origin)) + { + return true; + } + _logger?.PolicyFailure(); + _logger?.OriginNotAllowed(origin); + return false; + } } } diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs new file mode 100644 index 0000000000..6c420e9260 --- /dev/null +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs @@ -0,0 +1,19 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNetCore.Cors.Infrastructure +{ + internal static class UriHelpers + { + public static bool IsSubdomainOf(Uri subdomain, Uri domain) + { + return subdomain.IsAbsoluteUri + && domain.IsAbsoluteUri + && subdomain.Scheme == domain.Scheme + && subdomain.Port == domain.Port + && subdomain.Host.EndsWith($".{domain.Host}", StringComparison.Ordinal); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs index e3ae91c58b..f7279b13b1 100644 --- a/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs @@ -3,9 +3,11 @@ using System.Reflection; using System.Resources; +using System.Runtime.CompilerServices; [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyCompany("Microsoft Corporation.")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyProduct("Microsoft ASP.NET Core")] +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Cors.Test,PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs index 0ee3b7e524..8a223ad225 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs @@ -14,6 +14,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure public void Constructor_WithPolicy_AddsTheGivenPolicy() { // Arrange + Func isOriginAllowed = origin => true; var originalPolicy = new CorsPolicy(); originalPolicy.Origins.Add("http://existing.com"); originalPolicy.Headers.Add("Existing"); @@ -21,6 +22,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure originalPolicy.ExposedHeaders.Add("ExistingExposed"); originalPolicy.SupportsCredentials = true; originalPolicy.PreflightMaxAge = TimeSpan.FromSeconds(12); + originalPolicy.IsOriginAllowed = isOriginAllowed; // Act var builder = new CorsPolicyBuilder(originalPolicy); @@ -41,6 +43,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.NotSame(originalPolicy.ExposedHeaders, corsPolicy.ExposedHeaders); Assert.Equal(originalPolicy.ExposedHeaders, corsPolicy.ExposedHeaders); Assert.Equal(TimeSpan.FromSeconds(12), corsPolicy.PreflightMaxAge); + Assert.Same(originalPolicy.IsOriginAllowed, corsPolicy.IsOriginAllowed); } [Fact] @@ -140,6 +143,35 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Equal(new List() { "*" }, corsPolicy.Origins); } + [Fact] + public void SetIsOriginAllowed_AddsIsOriginAllowed() + { + // Arrange + var builder = new CorsPolicyBuilder(); + Func isOriginAllowed = origin => true; + + // Act + builder.SetIsOriginAllowed(isOriginAllowed); + + // Assert + var corsPolicy = builder.Build(); + Assert.Same(corsPolicy.IsOriginAllowed, isOriginAllowed); + } + + [Fact] + public void SetIsOriginAllowedToAllowWildcardSubdomains_AllowsWildcardSubdomains() + { + // Arrange + var builder = new CorsPolicyBuilder("http://*.example.com"); + + // Act + builder.SetIsOriginAllowedToAllowWildcardSubdomains(); + + // Assert + var corsPolicy = builder.Build(); + Assert.True(corsPolicy.IsOriginAllowed("http://test.example.com")); + } + [Fact] public void WithMethods_AddsMethods() { diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs new file mode 100644 index 0000000000..2c323162ca --- /dev/null +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs @@ -0,0 +1,65 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Xunit; + +namespace Microsoft.AspNetCore.Cors.Infrastructure +{ + public sealed class CorsPolicyExtensionsTest + { + [Fact] + public void IsOriginAnAllowedSubdomain_ReturnsTrueIfPolicyContainsOrigin() + { + // Arrange + const string origin = "http://sub.domain"; + var policy = new CorsPolicy(); + policy.Origins.Add(origin); + + // Act + var actual = policy.IsOriginAnAllowedSubdomain(origin); + + // Assert + Assert.True(actual); + } + + [Theory] + [InlineData("http://sub.domain", "http://*.domain")] + [InlineData("http://sub.sub.domain", "http://*.domain")] + [InlineData("http://sub.sub.domain", "http://*.sub.domain")] + [InlineData("http://sub.domain:4567", "http://*.domain:4567")] + public void IsOriginAnAllowedSubdomain_ReturnsTrue_WhenASubdomain(string origin, string allowedOrigin) + { + // Arrange + var policy = new CorsPolicy(); + policy.Origins.Add(allowedOrigin); + + // Act + var isAllowed = policy.IsOriginAnAllowedSubdomain(origin); + + // Assert + Assert.True(isAllowed); + } + + [Theory] + [InlineData("http://domain", "http://*.domain")] + [InlineData("http://sub.domain", "http://domain")] + [InlineData("http://sub.domain:1234", "http://*.domain:5678")] + [InlineData("http://sub.domain", "http://domain.*")] + [InlineData("http://sub.sub.domain", "http://sub.*.domain")] + [InlineData("http://sub.domain.hacker", "http://*.domain")] + [InlineData("https://sub.domain", "http://*.domain")] + public void IsOriginAnAllowedSubdomain_ReturnsFalse_WhenNotASubdomain(string origin, string allowedOrigin) + { + // Arrange + var policy = new CorsPolicy(); + policy.Origins.Add(allowedOrigin); + + // Act + var isAllowed = policy.IsOriginAnAllowedSubdomain(origin); + + // Assert + Assert.False(isAllowed); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs index 4264164ed0..f49e30fabc 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs @@ -24,6 +24,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Empty(corsPolicy.Methods); Assert.Empty(corsPolicy.Origins); Assert.Null(corsPolicy.PreflightMaxAge); + Assert.NotNull(corsPolicy.IsOriginAllowed); } [Fact] diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index 7edfc895fd..73b6e89653 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -58,6 +58,26 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.False(result.VaryByOrigin); } + [Fact] + public void EvaluatePolicy_IsOriginAllowedReturnsFalse_ReturnsInvalidResult() + { + // Arrange + var corsService = new CorsService(new TestCorsOptions()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy() + { + IsOriginAllowed = origin => false + }; + policy.Origins.Add("example.com"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Null(result.AllowedOrigin); + Assert.False(result.VaryByOrigin); + } + [Fact] public void EvaluatePolicy_AllowAnyOrigin_DoesNotSupportCredentials_EmitsWildcardForOrigin() { @@ -407,6 +427,28 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Equal("http://example.com", result.AllowedOrigin); } + [Fact] + public void EvaluatePolicy_PreflightRequest_IsOriginAllowedReturnsTrue_ReturnsOrigin() + { + // Arrange + var corsService = new CorsService(new TestCorsOptions()); + var requestContext = GetHttpContext( + method: "OPTIONS", + origin: "http://example.com", + accessControlRequestMethod: "PUT"); + var policy = new CorsPolicy + { + IsOriginAllowed = origin => true + }; + policy.Methods.Add("*"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Equal("http://example.com", result.AllowedOrigin); + } + [Fact] public void EvaluatePolicy_PreflightRequest_SupportsCredentials_AllowCredentialsReturnsTrue() { diff --git a/test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs b/test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs new file mode 100644 index 0000000000..ac04cfc3fd --- /dev/null +++ b/test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs @@ -0,0 +1,66 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Xunit; + +namespace Microsoft.AspNetCore.Cors.Infrastructure +{ + public sealed class UriHelpersTests + { + [Theory] + [MemberData(nameof(IsSubdomainOfTestData))] + public void TestIsSubdomainOf(Uri subdomain, Uri domain) + { + // Act + bool isSubdomain = UriHelpers.IsSubdomainOf(subdomain, domain); + + // Assert + Assert.True(isSubdomain); + } + + [Theory] + [MemberData(nameof(IsNotSubdomainOfTestData))] + public void TestIsSubdomainOf_ReturnsFalse_WhenNotSubdomain(Uri subdomain, Uri domain) + { + // Act + bool isSubdomain = UriHelpers.IsSubdomainOf(subdomain, domain); + + // Assert + Assert.False(isSubdomain); + } + + public static IEnumerable IsSubdomainOfTestData + { + get + { + return new[] + { + new object[] {new Uri("http://sub.domain"), new Uri("http://domain")}, + new object[] {new Uri("https://sub.domain"), new Uri("https://domain")}, + new object[] {new Uri("https://sub.domain:5678"), new Uri("https://domain:5678")}, + new object[] {new Uri("http://sub.sub.domain"), new Uri("http://domain")}, + new object[] {new Uri("http://sub.sub.domain"), new Uri("http://sub.domain")} + }; + } + } + + public static IEnumerable IsNotSubdomainOfTestData + { + get + { + return new[] + { + new object[] {new Uri("http://subdomain"), new Uri("http://domain")}, + new object[] {new Uri("https://sub.domain"), new Uri("http://domain")}, + new object[] {new Uri("https://sub.domain:1234"), new Uri("https://domain:5678")}, + new object[] {new Uri("http://domain.tld"), new Uri("http://domain")}, + new object[] {new Uri("http://sub.domain.tld"), new Uri("http://domain")}, + new object[] {new Uri("/relativeUri", UriKind.Relative), new Uri("http://domain")}, + new object[] {new Uri("http://sub.domain"), new Uri("/relative", UriKind.Relative)} + }; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 6ad6917f35..0145f53774 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -1,5 +1,8 @@ { "version": "1.1.0-*", + "buildOptions": { + "keyFile": "../../tools/Key.snk" + }, "dependencies": { "CorsMiddlewareWebSite": "1.0.0-*", "dotnet-test-xunit": "2.2.0-*", diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index f447a14c31..b5cfea5e07 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -1,6 +1,7 @@ { "buildOptions": { - "emitEntryPoint": true + "emitEntryPoint": true, + "keyFile": "../../../tools/Key.snk" }, "dependencies": { "Microsoft.AspNetCore.Cors": "1.2.0-*", From b34d459d20c3443fc5262e84425a4cb2c55dff32 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 8 Dec 2016 10:03:56 -0800 Subject: [PATCH 156/271] Update .travis.yml osx image to xcode7.3. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a84a024b7a..a2e59eb4d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ mono: os: - linux - osx -osx_image: xcode7.1 +osx_image: xcode7.3 branches: only: - master From 2a69f3688a6766d789d2175fa44a117393f0a3e8 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 12 Dec 2016 00:39:54 -0800 Subject: [PATCH 157/271] Removed packages list in NuGetPackageVerifier.json --- NuGetPackageVerifier.json | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index bf2544859f..b153ab1515 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,13 +1,5 @@ { - "adx": { // Packages written by the ADX team and that ship on NuGet.org - "rules": [ - "AdxVerificationCompositeRule" - ], - "packages": { - "Microsoft.AspNetCore.Cors": { } - } - }, - "Default": { // Rules to run for packages not listed in any other set. + "Default": { "rules": [ "DefaultCompositeRule" ] From 2dbfb8839b83ca31fb2f996a4d80e09deb60d904 Mon Sep 17 00:00:00 2001 From: Michiel Post Date: Thu, 22 Dec 2016 00:49:50 +0100 Subject: [PATCH 158/271] Include VaryByOrigin when there are multiple Origins configured (#84) Fixes #97 * Added negative test and updated origin to valid origin url * Fixed tabs and spaces --- .../Infrastructure/CorsService.cs | 5 +++ .../CorsServiceTests.cs | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs index bd978495fb..5060ddf205 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs @@ -271,6 +271,11 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure else if (policy.IsOriginAllowed(origin)) { result.AllowedOrigin = origin; + + if(policy.Origins.Count > 1) + { + result.VaryByOrigin = true; + } } } diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index 73b6e89653..40164da6d7 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -1080,6 +1080,41 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.Equal("30", httpContext.Response.Headers["Access-Control-Max-Age"]); } + [Fact] + public void EvaluatePolicy_MultiOriginsPolicy_ReturnsVaryByOriginHeader() + { + // Arrange + var corsService = new CorsService(new TestCorsOptions()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy(); + policy.Origins.Add("http://example.com"); + policy.Origins.Add("http://example-two.com"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.NotNull(result.AllowedOrigin); + Assert.True(result.VaryByOrigin); + } + + [Fact] + public void EvaluatePolicy_MultiOriginsPolicy_NoMatchingOrigin_ReturnsInvalidResult() + { + // Arrange + var corsService = new CorsService(new TestCorsOptions()); + var requestContext = GetHttpContext(origin: "http://example.com"); + var policy = new CorsPolicy(); + policy.Origins.Add("http://example-two.com"); + policy.Origins.Add("http://example-three.com"); + + // Act + var result = corsService.EvaluatePolicy(requestContext, policy); + + // Assert + Assert.Null(result.AllowedOrigin); + Assert.False(result.VaryByOrigin); + } private static HttpContext GetHttpContext( From bdf9d2a2e295f4e852624e5025cd64862484b613 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 5 Dec 2016 09:01:56 -0800 Subject: [PATCH 159/271] Updating to 4.4 CoreFx packages --- global.json | 2 +- samples/SampleDestination/project.json | 8 ++------ samples/SampleOrigin/project.json | 8 ++------ src/Microsoft.AspNetCore.Cors/project.json | 2 +- test/Microsoft.AspNetCore.Cors.Test/project.json | 4 ++-- test/WebSites/CorsMiddlewareWebSite/project.json | 2 +- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/global.json b/global.json index 520f9ba815..3a8a038991 100644 --- a/global.json +++ b/global.json @@ -4,6 +4,6 @@ "test/WebSites" ], "sdk": { - "version": "1.0.0-preview2-1-003177" + "version": "1.0.0-preview2-1-003180" } } \ No newline at end of file diff --git a/samples/SampleDestination/project.json b/samples/SampleDestination/project.json index 3c86825eb6..af84ae4d13 100644 --- a/samples/SampleDestination/project.json +++ b/samples/SampleDestination/project.json @@ -1,14 +1,13 @@ { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" }, "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.AspNetCore.Cors": "1.2.0-*" }, - "frameworks": { "netcoreapp1.0": { "imports": [ @@ -17,21 +16,18 @@ ] } }, - "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, - "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, - "publishOptions": { "include": [ "wwwroot" ] } -} +} \ No newline at end of file diff --git a/samples/SampleOrigin/project.json b/samples/SampleOrigin/project.json index 259fb617c3..720b715f6c 100644 --- a/samples/SampleOrigin/project.json +++ b/samples/SampleOrigin/project.json @@ -1,13 +1,12 @@ { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" }, "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*" }, - "frameworks": { "netcoreapp1.0": { "imports": [ @@ -16,21 +15,18 @@ ] } }, - "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, - "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, - "publishOptions": { "include": [ "wwwroot" ] } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json index c707dd94a2..054529d959 100644 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ b/src/Microsoft.AspNetCore.Cors/project.json @@ -25,7 +25,7 @@ "Microsoft.Extensions.DependencyInjection.Abstractions": "1.2.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", "Microsoft.Extensions.Options": "1.2.0-*", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "net451": {}, diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json index 0145f53774..bdd4da9c8f 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ b/test/Microsoft.AspNetCore.Cors.Test/project.json @@ -17,10 +17,10 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" }, - "System.Diagnostics.TraceSource": "4.3.0-*" + "System.Diagnostics.TraceSource": "4.4.0-*" } }, "net451": {} diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json index b5cfea5e07..f822290b80 100644 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ b/test/WebSites/CorsMiddlewareWebSite/project.json @@ -13,7 +13,7 @@ "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.1.0-*", + "version": "1.2.0-*", "type": "platform" } } From f34848b7603f4f8af839f918a45fe877bb7f56ef Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 30 Jan 2017 15:28:23 -0800 Subject: [PATCH 160/271] Upgrade to VS 2017 --- CORS.sln | 19 ++++------ NuGet.config | 3 +- appveyor.yml | 3 +- build.ps1 | 2 +- build.sh | 2 +- {tools => build}/Key.snk | Bin build/common.props | 24 +++++++++++++ global.json | 9 ----- .../SampleDestination.csproj | 16 +++++++++ .../SampleDestination/SampleDestination.xproj | 25 ------------- samples/SampleDestination/project.json | 33 ----------------- .../runtimeconfig.template.json | 5 +++ samples/SampleOrigin/SampleOrigin.csproj | 15 ++++++++ samples/SampleOrigin/SampleOrigin.xproj | 25 ------------- samples/SampleOrigin/project.json | 32 ----------------- .../SampleOrigin/runtimeconfig.template.json | 5 +++ .../Microsoft.AspNetCore.Cors.csproj | 24 +++++++++++++ .../Microsoft.AspNetCore.Cors.xproj | 17 --------- .../Properties/AssemblyInfo.cs | 7 ---- src/Microsoft.AspNetCore.Cors/project.json | 34 ------------------ .../Microsoft.AspNetCore.Cors.Test.csproj | 24 +++++++++++++ .../Microsoft.AspNetCore.Cors.Test.xproj | 20 ----------- .../project.json | 28 --------------- .../CorsMiddlewareWebSite.csproj | 17 +++++++++ .../CorsMiddlewareWebSite.xproj | 18 ---------- .../CorsMiddlewareWebSite/project.json | 33 ----------------- version.props | 7 ++++ 27 files changed, 150 insertions(+), 297 deletions(-) rename {tools => build}/Key.snk (100%) create mode 100644 build/common.props delete mode 100644 global.json create mode 100644 samples/SampleDestination/SampleDestination.csproj delete mode 100644 samples/SampleDestination/SampleDestination.xproj delete mode 100644 samples/SampleDestination/project.json create mode 100644 samples/SampleDestination/runtimeconfig.template.json create mode 100644 samples/SampleOrigin/SampleOrigin.csproj delete mode 100644 samples/SampleOrigin/SampleOrigin.xproj delete mode 100644 samples/SampleOrigin/project.json create mode 100644 samples/SampleOrigin/runtimeconfig.template.json create mode 100644 src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj delete mode 100644 src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj delete mode 100644 src/Microsoft.AspNetCore.Cors/project.json create mode 100644 test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj delete mode 100644 test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj delete mode 100644 test/Microsoft.AspNetCore.Cors.Test/project.json create mode 100644 test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj delete mode 100644 test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj delete mode 100644 test/WebSites/CorsMiddlewareWebSite/project.json create mode 100644 version.props diff --git a/CORS.sln b/CORS.sln index c471720431..23483cedb1 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,29 +1,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26127.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{280203D6-9DDE-4B80-BF93-4E7382CAD1A9}" - ProjectSection(SolutionItems) = preProject - global.json = global.json - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F32074C7-087C-46CC-A913-422BFD2D6E0A}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Cors", "src\Microsoft.AspNetCore.Cors\Microsoft.AspNetCore.Cors.xproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Cors", "src\Microsoft.AspNetCore.Cors\Microsoft.AspNetCore.Cors.csproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Cors.Test", "test\Microsoft.AspNetCore.Cors.Test\Microsoft.AspNetCore.Cors.Test.xproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Cors.Test", "test\Microsoft.AspNetCore.Cors.Test\Microsoft.AspNetCore.Cors.Test.csproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{538380BF-0D4C-4E30-8F41-E75C4B1C01FA}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CorsMiddlewareWebSite", "test\WebSites\CorsMiddlewareWebSite\CorsMiddlewareWebSite.xproj", "{B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CorsMiddlewareWebSite", "test\WebSites\CorsMiddlewareWebSite\CorsMiddlewareWebSite.csproj", "{B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{960E0703-A8A5-44DF-AA87-B7C614683B3C}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleDestination", "samples\SampleDestination\SampleDestination.xproj", "{F6675DC1-AA21-453B-89B6-DA425FB9C3A5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleDestination", "samples\SampleDestination\SampleDestination.csproj", "{F6675DC1-AA21-453B-89B6-DA425FB9C3A5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleOrigin", "samples\SampleOrigin\SampleOrigin.xproj", "{99460370-AE5D-4DC9-8DBF-04DF66D6B21D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleOrigin", "samples\SampleOrigin\SampleOrigin.csproj", "{99460370-AE5D-4DC9-8DBF-04DF66D6B21D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/NuGet.config b/NuGet.config index 0fd623ffdd..8e65695611 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,8 @@ - + + diff --git a/appveyor.yml b/appveyor.yml index b9a9bcd1e6..741873cbe5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,4 +10,5 @@ build_script: - build.cmd verify clone_depth: 1 test: off -deploy: off \ No newline at end of file +deploy: off +os: Visual Studio 2015 diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..0605b59c01 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index 4fd7ede788..07997d6c83 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/tools/Key.snk b/build/Key.snk similarity index 100% rename from tools/Key.snk rename to build/Key.snk diff --git a/build/common.props b/build/common.props new file mode 100644 index 0000000000..ec6c739994 --- /dev/null +++ b/build/common.props @@ -0,0 +1,24 @@ + + + + + Microsoft ASP.NET Core + https://github.com/aspnet/CORS + git + $(MSBuildThisFileDirectory)Key.snk + true + true + 1.2.0-* + 1.6.2-* + $(VersionSuffix)-$(BuildNumber) + + + + + + + + + + + diff --git a/global.json b/global.json deleted file mode 100644 index 3a8a038991..0000000000 --- a/global.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "projects": [ - "src", - "test/WebSites" - ], - "sdk": { - "version": "1.0.0-preview2-1-003180" - } -} \ No newline at end of file diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj new file mode 100644 index 0000000000..13f60f84c3 --- /dev/null +++ b/samples/SampleDestination/SampleDestination.csproj @@ -0,0 +1,16 @@ + + + + netcoreapp1.1 + true + Exe + 1.2.0-* + + + + + + + + + diff --git a/samples/SampleDestination/SampleDestination.xproj b/samples/SampleDestination/SampleDestination.xproj deleted file mode 100644 index ac33a6f88b..0000000000 --- a/samples/SampleDestination/SampleDestination.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - f6675dc1-aa21-453b-89b6-da425fb9c3a5 - SampleDestination - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - - - - - diff --git a/samples/SampleDestination/project.json b/samples/SampleDestination/project.json deleted file mode 100644 index af84ae4d13..0000000000 --- a/samples/SampleDestination/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - }, - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.AspNetCore.Cors": "1.2.0-*" - }, - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dotnet5.6", - "portable-net45+win8" - ] - } - }, - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - "runtimeOptions": { - "configProperties": { - "System.GC.Server": true - } - }, - "publishOptions": { - "include": [ - "wwwroot" - ] - } -} \ No newline at end of file diff --git a/samples/SampleDestination/runtimeconfig.template.json b/samples/SampleDestination/runtimeconfig.template.json new file mode 100644 index 0000000000..7305508a37 --- /dev/null +++ b/samples/SampleDestination/runtimeconfig.template.json @@ -0,0 +1,5 @@ +{ + "configProperties": { + "System.GC.Server": true + } +} \ No newline at end of file diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj new file mode 100644 index 0000000000..29b21c3e54 --- /dev/null +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp1.1 + true + Exe + 1.2.0-* + + + + + + + + diff --git a/samples/SampleOrigin/SampleOrigin.xproj b/samples/SampleOrigin/SampleOrigin.xproj deleted file mode 100644 index 2241431ad0..0000000000 --- a/samples/SampleOrigin/SampleOrigin.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 99460370-ae5d-4dc9-8dbf-04df66d6b21d - SampleOrigin - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - - - - - diff --git a/samples/SampleOrigin/project.json b/samples/SampleOrigin/project.json deleted file mode 100644 index 720b715f6c..0000000000 --- a/samples/SampleOrigin/project.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - }, - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*" - }, - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dotnet5.6", - "portable-net45+win8" - ] - } - }, - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - "runtimeOptions": { - "configProperties": { - "System.GC.Server": true - } - }, - "publishOptions": { - "include": [ - "wwwroot" - ] - } -} \ No newline at end of file diff --git a/samples/SampleOrigin/runtimeconfig.template.json b/samples/SampleOrigin/runtimeconfig.template.json new file mode 100644 index 0000000000..7305508a37 --- /dev/null +++ b/samples/SampleOrigin/runtimeconfig.template.json @@ -0,0 +1,5 @@ +{ + "configProperties": { + "System.GC.Server": true + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj new file mode 100644 index 0000000000..825be01e49 --- /dev/null +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -0,0 +1,24 @@ + + + + + + CORS middleware and policy for ASP.NET Core to enable cross-origin resource sharing. +Commonly used types: +Microsoft.AspNetCore.Cors.DisableCorsAttribute +Microsoft.AspNetCore.Cors.EnableCorsAttribute + net451;netstandard1.3 + $(NoWarn);CS1591 + true + aspnetcore;cors + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj deleted file mode 100644 index 6692475384..0000000000 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 41349fcd-d1c4-47a6-82d0-d16d00a8d59d - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs index f7279b13b1..b3d086e2e5 100644 --- a/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs +++ b/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs @@ -1,13 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Reflection; -using System.Resources; using System.Runtime.CompilerServices; -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-US")] -[assembly: AssemblyCompany("Microsoft Corporation.")] -[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft ASP.NET Core")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Cors.Test,PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/src/Microsoft.AspNetCore.Cors/project.json b/src/Microsoft.AspNetCore.Cors/project.json deleted file mode 100644 index 054529d959..0000000000 --- a/src/Microsoft.AspNetCore.Cors/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "version": "1.2.0-*", - "packOptions": { - "repository": { - "type": "git", - "url": "https://github.com/aspnet/cors" - }, - "tags": [ - "aspnetcore", - "cors" - ] - }, - "description": "CORS middleware and policy for ASP.NET Core to enable cross-origin resource sharing.\r\nCommonly used types:\r\nMicrosoft.AspNetCore.Cors.DisableCorsAttribute\r\nMicrosoft.AspNetCore.Cors.EnableCorsAttribute", - "buildOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk", - "nowarn": [ - "CS1591" - ], - "xmlDoc": true - }, - "dependencies": { - "Microsoft.AspNetCore.Http.Extensions": "1.2.0-*", - "Microsoft.Extensions.Configuration.Abstractions": "1.2.0-*", - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.2.0-*", - "Microsoft.Extensions.Logging.Abstractions": "1.2.0-*", - "Microsoft.Extensions.Options": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "net451": {}, - "netstandard1.3": {} - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj new file mode 100644 index 0000000000..2501d17aaa --- /dev/null +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -0,0 +1,24 @@ + + + + + + netcoreapp1.1;net451 + + + + + + + + + + + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj deleted file mode 100644 index f2351a724c..0000000000 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - f05be96f-f869-4408-a480-96935b4835ee - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Cors.Test/project.json b/test/Microsoft.AspNetCore.Cors.Test/project.json deleted file mode 100644 index bdd4da9c8f..0000000000 --- a/test/Microsoft.AspNetCore.Cors.Test/project.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "version": "1.1.0-*", - "buildOptions": { - "keyFile": "../../tools/Key.snk" - }, - "dependencies": { - "CorsMiddlewareWebSite": "1.0.0-*", - "dotnet-test-xunit": "2.2.0-*", - "Microsoft.AspNetCore.Cors": "1.2.0-*", - "Microsoft.AspNetCore.TestHost": "1.2.0-*", - "Microsoft.Extensions.Logging.Testing": "1.2.0-*", - "Moq": "4.6.36-*", - "xunit": "2.2.0-*" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - }, - "System.Diagnostics.TraceSource": "4.4.0-*" - } - }, - "net451": {} - } -} \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj new file mode 100644 index 0000000000..7d6c5ad6a6 --- /dev/null +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -0,0 +1,17 @@ + + + + + + net451;netcoreapp1.1 + win7-x64 + Exe + + + + + + + + + diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj deleted file mode 100644 index f4d5720f67..0000000000 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - b42d4844-fff8-4ec2-88d1-3ae95234d9eb - .\obj - .\bin\ - - - 2.0 - 41642 - - - \ No newline at end of file diff --git a/test/WebSites/CorsMiddlewareWebSite/project.json b/test/WebSites/CorsMiddlewareWebSite/project.json deleted file mode 100644 index f822290b80..0000000000 --- a/test/WebSites/CorsMiddlewareWebSite/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "buildOptions": { - "emitEntryPoint": true, - "keyFile": "../../../tools/Key.snk" - }, - "dependencies": { - "Microsoft.AspNetCore.Cors": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*" - }, - "frameworks": { - "net451": {}, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.2.0-*", - "type": "platform" - } - } - } - }, - "publishOptions": { - "include": [ - "web.config" - ] - }, - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*" - }, - "scripts": { - "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" - } -} \ No newline at end of file diff --git a/version.props b/version.props new file mode 100644 index 0000000000..17fd5ac36d --- /dev/null +++ b/version.props @@ -0,0 +1,7 @@ + + + + 1.2.0 + preview1 + + From 2f262ec0015489aefe2714650a7b23f5a681bc5d Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 14 Feb 2017 16:33:44 -0800 Subject: [PATCH 161/271] Bump test projects up to .NET 4.5.2 - aspnet/Testing#248 - xUnit no longer supports .NET 4.5.1 - build tests for desktop .NET only on Windows --- .../Microsoft.AspNetCore.Cors.Test.csproj | 3 ++- .../CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 2501d17aaa..46daf629db 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp1.1;net451 + netcoreapp1.1;net452 + netcoreapp1.1 diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index 7d6c5ad6a6..6cb158f487 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -3,7 +3,8 @@ - net451;netcoreapp1.1 + net452;netcoreapp1.1 + netcoreapp1.1 win7-x64 Exe From 395eeb125e68b7333b5f9a0bdcc0f357397cb696 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Feb 2017 16:03:54 -0800 Subject: [PATCH 162/271] Downgrade to stable packages --- build/common.props | 3 +-- build/dependencies.props | 6 ++++++ samples/SampleDestination/SampleDestination.csproj | 1 - samples/SampleOrigin/SampleOrigin.csproj | 1 - 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 build/dependencies.props diff --git a/build/common.props b/build/common.props index ec6c739994..a573fab65a 100644 --- a/build/common.props +++ b/build/common.props @@ -1,4 +1,5 @@ + @@ -8,8 +9,6 @@ $(MSBuildThisFileDirectory)Key.snk true true - 1.2.0-* - 1.6.2-* $(VersionSuffix)-$(BuildNumber) diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 0000000000..e704edaec0 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,6 @@ + + + 1.6.1 + 4.3.0 + + diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 13f60f84c3..4163aa41cb 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -4,7 +4,6 @@ netcoreapp1.1 true Exe - 1.2.0-* diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index 29b21c3e54..6873ae9cb6 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -4,7 +4,6 @@ netcoreapp1.1 true Exe - 1.2.0-* From 18026305d8cb3f1dfcfb043b620a96d2de88910a Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Mar 2017 18:14:13 -0800 Subject: [PATCH 163/271] Change korebuild branch and fix argument forwarding in bootstrapper --- build.ps1 | 16 ++++++++-------- build.sh | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build.ps1 b/build.ps1 index 0605b59c01..5bf0e2c113 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,6 @@ $ErrorActionPreference = "Stop" -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) { while($true) { @@ -19,7 +19,7 @@ function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $ret Start-Sleep -Seconds 10 } - else + else { $exception = $_.Exception throw $exception @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP @@ -43,18 +43,18 @@ $buildFolder = ".build" $buildFile="$buildFolder\KoreBuild.ps1" if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - + Write-Host "Downloading KoreBuild from $koreBuildZip" + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() New-Item -Path "$tempFolder" -Type directory | Out-Null $localZipFile="$tempFolder\korebuild.zip" - + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - + New-Item -Path "$buildFolder" -Type directory | Out-Null copy-item "$tempFolder\**\build\*" $buildFolder -Recurse @@ -64,4 +64,4 @@ if (!(Test-Path $buildFolder)) { } } -&"$buildFile" $args \ No newline at end of file +&"$buildFile" @args diff --git a/build.sh b/build.sh index 07997d6c83..b0bcadb579 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi @@ -12,12 +12,12 @@ buildFile="$buildFolder/KoreBuild.sh" if test ! -d $buildFolder; then echo "Downloading KoreBuild from $koreBuildZip" - - tempFolder="/tmp/KoreBuild-$(uuidgen)" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" mkdir $tempFolder - + localZipFile="$tempFolder/korebuild.zip" - + retries=6 until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) do @@ -29,18 +29,18 @@ if test ! -d $buildFolder; then echo "Waiting 10 seconds before retrying. Retries left: $retries" sleep 10s done - + unzip -q -d $tempFolder $localZipFile - + mkdir $buildFolder cp -r $tempFolder/**/build/** $buildFolder - + chmod +x $buildFile - + # Cleanup if test -d $tempFolder; then - rm -rf $tempFolder + rm -rf $tempFolder fi fi -$buildFile -r $repoFolder "$@" \ No newline at end of file +$buildFile -r $repoFolder "$@" From 2d03145dfe27fb0f87f5ba790729a9a401bd1860 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Mar 2017 18:25:39 -0800 Subject: [PATCH 164/271] Update AppVeyor and Travis settings --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2e59eb4d4..d83f36b8e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ branches: before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - - ./build.sh --quiet verify + - ./build.sh notifications: webhooks: secure: "V+ynhkZnRWn9VemSgBKI6KB5WxSE/SuoIKFnBQFb/1O0r15aac4/VyzuRdTK8V29OxdI1vK0J3UET2c2v2Q2IusFc4rCHGcRIobjHq+YW8944betuYfHkpVgniHofaGLgJH8gdlZv4elDdVHWKndYIGTaBU8+dO8ktp+9BFGYhs=" diff --git a/appveyor.yml b/appveyor.yml index 741873cbe5..4af9de6b8a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ branches: - dev - /^(.*\/)?ci-.*$/ build_script: - - build.cmd verify + - ps: .\build.ps1 clone_depth: 1 test: off deploy: off From 48b7a5bff94cc2cfa05fe8e472a9304fbab436a7 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 9 Mar 2017 11:25:39 -0800 Subject: [PATCH 165/271] Update .travis.yml (#104) --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d83f36b8e2..0ff79b4ca9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,7 @@ env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -mono: - - 4.0.5 +mono: none os: - linux - osx From 897318c7de880b5894f59adbd49f166679e88958 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Mar 2017 13:39:40 -0700 Subject: [PATCH 166/271] Update appveyor and travis settings --- .travis.yml | 1 - appveyor.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ff79b4ca9..5b210bfdcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ mono: none os: - linux - osx -osx_image: xcode7.3 branches: only: - master diff --git a/appveyor.yml b/appveyor.yml index 4af9de6b8a..1041615c68 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,4 +11,4 @@ build_script: clone_depth: 1 test: off deploy: off -os: Visual Studio 2015 +os: Visual Studio 2017 From fd3486df0f5f28ecd19d5a644a135e72797da3d4 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 15 Mar 2017 12:58:08 -0700 Subject: [PATCH 167/271] Unify dependency versions to one file and remove workarounds --- build/dependencies.props | 6 +++++- .../SampleDestination/SampleDestination.csproj | 11 +++++++---- .../SampleDestination/runtimeconfig.template.json | 5 ----- samples/SampleOrigin/SampleOrigin.csproj | 8 ++++---- samples/SampleOrigin/runtimeconfig.template.json | 5 ----- .../Microsoft.AspNetCore.Cors.csproj | 10 +++++----- .../Microsoft.AspNetCore.Cors.Test.csproj | 15 +++++++++------ .../CorsMiddlewareWebSite.csproj | 9 +++++---- 8 files changed, 35 insertions(+), 34 deletions(-) delete mode 100644 samples/SampleDestination/runtimeconfig.template.json delete mode 100644 samples/SampleOrigin/runtimeconfig.template.json diff --git a/build/dependencies.props b/build/dependencies.props index e704edaec0..c153f0e3f9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,10 @@ - 1.6.1 + 1.2.0-* 4.3.0 + 4.7.1 + 1.6.1 + 15.0.0 + 2.2.0 diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 4163aa41cb..873b414bb0 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -1,15 +1,18 @@ + + netcoreapp1.1 - true - Exe - - + + + + + diff --git a/samples/SampleDestination/runtimeconfig.template.json b/samples/SampleDestination/runtimeconfig.template.json deleted file mode 100644 index 7305508a37..0000000000 --- a/samples/SampleDestination/runtimeconfig.template.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "configProperties": { - "System.GC.Server": true - } -} \ No newline at end of file diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index 6873ae9cb6..26e32c75de 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -1,14 +1,14 @@ + + netcoreapp1.1 - true - Exe - - + + diff --git a/samples/SampleOrigin/runtimeconfig.template.json b/samples/SampleOrigin/runtimeconfig.template.json deleted file mode 100644 index 7305508a37..0000000000 --- a/samples/SampleOrigin/runtimeconfig.template.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "configProperties": { - "System.GC.Server": true - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj index 825be01e49..458ef9776a 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -14,11 +14,11 @@ Microsoft.AspNetCore.Cors.EnableCorsAttribute - - - - - + + + + + diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 46daf629db..98a5f12099 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -10,12 +10,15 @@ - - - - - - + + + + + + + + + diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index 6cb158f487..90058afc19 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -5,14 +5,15 @@ net452;netcoreapp1.1 netcoreapp1.1 - win7-x64 - Exe - - + + + + + From 5c69ba88069049fcc2499a206dd36b059a6167b5 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 21 Mar 2017 12:03:35 -0700 Subject: [PATCH 168/271] Update Travis to macOS Sierra [skip appveyor] --- .travis.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b210bfdcb..2a46104677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,6 @@ language: csharp -sudo: required +sudo: false dist: trusty -addons: - apt: - packages: - - gettext - - libcurl4-openssl-dev - - libicu-dev - - libssl-dev - - libunwind8 - - zlib1g env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true @@ -18,6 +9,7 @@ mono: none os: - linux - osx +osx_image: xcode8.2 branches: only: - master @@ -28,9 +20,3 @@ before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: - ./build.sh -notifications: - webhooks: - secure: "V+ynhkZnRWn9VemSgBKI6KB5WxSE/SuoIKFnBQFb/1O0r15aac4/VyzuRdTK8V29OxdI1vK0J3UET2c2v2Q2IusFc4rCHGcRIobjHq+YW8944betuYfHkpVgniHofaGLgJH8gdlZv4elDdVHWKndYIGTaBU8+dO8ktp+9BFGYhs=" - on_success: always - on_failure: always - on_start: always From 275cd6b8d1d0079eec1965bf3ca3ba9b45f28e71 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 22 Mar 2017 18:28:19 -0700 Subject: [PATCH 169/271] Remove net451 as a cross-compile target --- .gitignore | 1 + .../Microsoft.AspNetCore.Cors.csproj | 2 +- .../Microsoft.AspNetCore.Cors.Test.csproj | 4 +++- .../CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index cecfac6cc7..a435689c0a 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ node_modules .build/ .testPublish/ .vscode +global.json diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj index 458ef9776a..6e75c61977 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Cors.DisableCorsAttribute Microsoft.AspNetCore.Cors.EnableCorsAttribute - net451;netstandard1.3 + netstandard1.3 $(NoWarn);CS1591 true aspnetcore;cors diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 98a5f12099..8ece9f0119 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -3,8 +3,10 @@ - netcoreapp1.1;net452 + netcoreapp1.1;net46 netcoreapp1.1 + true + true diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index 90058afc19..6306711422 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -3,7 +3,7 @@ - net452;netcoreapp1.1 + net46;netcoreapp1.1 netcoreapp1.1 From e79afcdb64fccc55d8f6e2731267355a107757b0 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 22 Mar 2017 22:42:14 -0700 Subject: [PATCH 170/271] Converted samples and test projects to run on netcoreapp2.0 --- build/dependencies.props | 1 + samples/SampleDestination/SampleDestination.csproj | 2 +- samples/SampleOrigin/SampleOrigin.csproj | 2 +- .../Microsoft.AspNetCore.Cors.Test.csproj | 4 ++-- .../CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c153f0e3f9..35c5cad19a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,6 +4,7 @@ 4.3.0 4.7.1 1.6.1 + 2.0.0-* 15.0.0 2.2.0 diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 873b414bb0..1105f99d4c 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -3,7 +3,7 @@ - netcoreapp1.1 + netcoreapp2.0 diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index 26e32c75de..a23841a2fb 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -3,7 +3,7 @@ - netcoreapp1.1 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 8ece9f0119..b45add831d 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -3,8 +3,8 @@ - netcoreapp1.1;net46 - netcoreapp1.1 + netcoreapp2.0;net46 + netcoreapp2.0 true true diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index 6306711422..8876346a2a 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -3,8 +3,8 @@ - net46;netcoreapp1.1 - netcoreapp1.1 + net46;netcoreapp2.0 + netcoreapp2.0 From 68647d1733279d1f20d146a827b63d64023e70fd Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Mar 2017 11:30:32 -0700 Subject: [PATCH 171/271] Updating to 2.0.0 Internal.AspNetCore.Sdk --- build/common.props | 2 +- build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/common.props b/build/common.props index a573fab65a..435b09b293 100644 --- a/build/common.props +++ b/build/common.props @@ -13,7 +13,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index 35c5cad19a..cf4424fae5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,10 +2,11 @@ 1.2.0-* 4.3.0 + 2.0.0-* 4.7.1 1.6.1 2.0.0-* 15.0.0 2.2.0 - + \ No newline at end of file From a9601ff6957d327a7f3d65b776932dc2e4dd9962 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Apr 2017 21:41:09 -0700 Subject: [PATCH 172/271] Updating versions to 2.0.0-preview1 --- build/dependencies.props | 2 +- version.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cf4424fae5..afc72a267b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 1.2.0-* + 2.0.0-* 4.3.0 2.0.0-* 4.7.1 diff --git a/version.props b/version.props index 17fd5ac36d..c7150e64f4 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 1.2.0 + 2.0.0 preview1 From ee3fc37413eca0c245ab628cd36dcd3dcd416f57 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 11:04:07 -0700 Subject: [PATCH 173/271] Use Bundled NETStandard.Library \ NETCoreApp versions instead of explicitly specifying one --- build/common.props | 2 +- build/dependencies.props | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build/common.props b/build/common.props index 435b09b293..ac9d44019f 100644 --- a/build/common.props +++ b/build/common.props @@ -17,7 +17,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index afc72a267b..8587abb455 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,9 +4,7 @@ 4.3.0 2.0.0-* 4.7.1 - 1.6.1 - 2.0.0-* 15.0.0 2.2.0 - \ No newline at end of file + From 1f83d810769662d4b521e1c3b64cbf2f9fc7e642 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 22:01:21 -0700 Subject: [PATCH 174/271] Branching for 2.0.0-preview1 --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- build/dependencies.props | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8e65695611..fa4304af9c 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..225b1fe450 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..702b25c636 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/build/dependencies.props b/build/dependencies.props index 8587abb455..61dccd8321 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview1-* 4.3.0 2.0.0-* 4.7.1 From e66b8e3879566db196fb4593a05dabfa96965fe2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 26 Apr 2017 07:12:41 -0700 Subject: [PATCH 175/271] Updating package version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index c7150e64f4..6af4f81de2 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview1 + preview2 From cbde9c0c8a5800553c19cb69a061bc5f56782e96 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 1 May 2017 12:39:05 -0700 Subject: [PATCH 176/271] Use the bundled NETStandard.Library package in netstandard targeting libraries --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index 61dccd8321..50283ae2ae 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,6 +4,7 @@ 4.3.0 2.0.0-* 4.7.1 + $(BundledNETStandardPackageVersion) 15.0.0 2.2.0 From 905114e960cd5970bb86c931230dc3af62ab494f Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 4 May 2017 16:15:59 -0700 Subject: [PATCH 177/271] Migration --- build/dependencies.props | 2 +- samples/SampleDestination/Program.cs | 2 + samples/SampleDestination/Startup.cs | 4 +- samples/SampleOrigin/Program.cs | 2 + samples/SampleOrigin/Startup.cs | 3 +- .../Microsoft.AspNetCore.Cors.csproj | 2 +- .../baseline.net45.json | 1124 ----------------- .../Microsoft.AspNetCore.Cors.Test.csproj | 3 +- .../CorsMiddlewareWebSite.csproj | 3 +- 9 files changed, 10 insertions(+), 1135 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Cors/baseline.net45.json diff --git a/build/dependencies.props b/build/dependencies.props index 50283ae2ae..a353b25211 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,7 +2,7 @@ 2.0.0-preview1-* 4.3.0 - 2.0.0-* + 2.1.0-* 4.7.1 $(BundledNETStandardPackageVersion) 15.0.0 diff --git a/samples/SampleDestination/Program.cs b/samples/SampleDestination/Program.cs index c196d5b838..0c2bf0968f 100644 --- a/samples/SampleDestination/Program.cs +++ b/samples/SampleDestination/Program.cs @@ -3,6 +3,7 @@ using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace SampleDestination { @@ -14,6 +15,7 @@ namespace SampleDestination .UseKestrel() .UseUrls("http://*:5000") .UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureLogging(factory => factory.AddConsole()) .UseStartup() .Build(); diff --git a/samples/SampleDestination/Startup.cs b/samples/SampleDestination/Startup.cs index e874697e18..0664d84572 100644 --- a/samples/SampleDestination/Startup.cs +++ b/samples/SampleDestination/Startup.cs @@ -16,10 +16,8 @@ namespace SampleDestination services.AddCors(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - loggerFactory.AddConsole(); - app.UseCors(policy => policy .WithOrigins("http://origin.example.com:5001") .WithMethods("PUT") diff --git a/samples/SampleOrigin/Program.cs b/samples/SampleOrigin/Program.cs index 34a19eccb5..278c09f48a 100644 --- a/samples/SampleOrigin/Program.cs +++ b/samples/SampleOrigin/Program.cs @@ -3,6 +3,7 @@ using System.IO; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace SampleOrigin { @@ -14,6 +15,7 @@ namespace SampleOrigin .UseKestrel() .UseUrls("http://*:5001") .UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureLogging(factory => factory.AddConsole()) .UseStartup() .Build(); diff --git a/samples/SampleOrigin/Startup.cs b/samples/SampleOrigin/Startup.cs index d8a54d74d5..a442b98d68 100644 --- a/samples/SampleOrigin/Startup.cs +++ b/samples/SampleOrigin/Startup.cs @@ -15,9 +15,8 @@ namespace SampleOrigin { } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - loggerFactory.AddConsole(); app.Run(context => { var fileInfoProvider = env.WebRootFileProvider; diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj index 6e75c61977..6ebc1832a8 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Cors.DisableCorsAttribute Microsoft.AspNetCore.Cors.EnableCorsAttribute - netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true aspnetcore;cors diff --git a/src/Microsoft.AspNetCore.Cors/baseline.net45.json b/src/Microsoft.AspNetCore.Cors/baseline.net45.json deleted file mode 100644 index b9e31fcb82..0000000000 --- a/src/Microsoft.AspNetCore.Cors/baseline.net45.json +++ /dev/null @@ -1,1124 +0,0 @@ -{ - "AssemblyIdentity": "Microsoft.AspNetCore.Cors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", - "Types": [ - { - "Name": "Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "UseCors", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "UseCors", - "Parameters": [ - { - "Name": "app", - "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" - }, - { - "Name": "configurePolicy", - "Type": "System.Action" - } - ], - "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.DisableCorsAttribute", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "System.Attribute", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Cors.Infrastructure.IDisableCorsAttribute" - ], - "Members": [ - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.EnableCorsAttribute", - "Visibility": "Public", - "Kind": "Class", - "BaseType": "System.Attribute", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute" - ], - "Members": [ - { - "Kind": "Method", - "Name": "get_PolicyName", - "Parameters": [], - "ReturnType": "System.String", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PolicyName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policyName", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsConstants", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Field", - "Name": "PreflightHttpMethod", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "Origin", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AnyOrigin", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlRequestMethod", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlRequestHeaders", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlAllowOrigin", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlAllowHeaders", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlExposeHeaders", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlAllowMethods", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlAllowCredentials", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Field", - "Name": "AccessControlMaxAge", - "Parameters": [], - "ReturnType": "System.String", - "Static": true, - "ReadOnly": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "Invoke", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "corsService", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" - }, - { - "Name": "policyProvider", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "next", - "Type": "Microsoft.AspNetCore.Http.RequestDelegate" - }, - { - "Name": "corsService", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsOptions", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_DefaultPolicyName", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_DefaultPolicyName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - }, - { - "Name": "configurePolicy", - "Type": "System.Action" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "GetPolicy", - "Parameters": [ - { - "Name": "name", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AllowAnyHeader", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AllowAnyMethod", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AllowAnyOrigin", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_ExposedHeaders", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Headers", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Methods", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_Origins", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PreflightMaxAge", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PreflightMaxAge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Nullable" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SupportsCredentials", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SupportsCredentials", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ToString", - "Parameters": [], - "ReturnType": "System.String", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "WithOrigins", - "Parameters": [ - { - "Name": "origins", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WithHeaders", - "Parameters": [ - { - "Name": "headers", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WithExposedHeaders", - "Parameters": [ - { - "Name": "exposedHeaders", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "WithMethods", - "Parameters": [ - { - "Name": "methods", - "Type": "System.String[]", - "IsParams": true - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AllowCredentials", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "DisallowCredentials", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AllowAnyOrigin", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AllowAnyMethod", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AllowAnyHeader", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "SetPreflightMaxAge", - "Parameters": [ - { - "Name": "preflightMaxAge", - "Type": "System.TimeSpan" - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "Build", - "Parameters": [], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "origins", - "Type": "System.String[]", - "IsParams": true - } - ], - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_AllowedOrigin", - "Parameters": [], - "ReturnType": "System.String", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_AllowedOrigin", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_SupportsCredentials", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_SupportsCredentials", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AllowedMethods", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AllowedHeaders", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_AllowedExposedHeaders", - "Parameters": [], - "ReturnType": "System.Collections.Generic.IList", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_VaryByOrigin", - "Parameters": [], - "ReturnType": "System.Boolean", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_VaryByOrigin", - "Parameters": [ - { - "Name": "value", - "Type": "System.Boolean" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "get_PreflightMaxAge", - "Parameters": [], - "ReturnType": "System.Nullable", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PreflightMaxAge", - "Parameters": [ - { - "Name": "value", - "Type": "System.Nullable" - } - ], - "ReturnType": "System.Void", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ToString", - "Parameters": [], - "ReturnType": "System.String", - "Virtual": true, - "Override": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.CorsService", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" - ], - "Members": [ - { - "Kind": "Method", - "Name": "EvaluatePolicy", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "EvaluatePolicy", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "EvaluateRequest", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" - }, - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "EvaluatePreflightRequest", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" - }, - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ApplyResult", - "Parameters": [ - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" - }, - { - "Name": "response", - "Type": "Microsoft.AspNetCore.Http.HttpResponse" - } - ], - "ReturnType": "System.Void", - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.DefaultCorsPolicyProvider", - "Visibility": "Public", - "Kind": "Class", - "ImplementedInterfaces": [ - "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider" - ], - "Members": [ - { - "Kind": "Method", - "Name": "GetPolicyAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "Sealed": true, - "Virtual": true, - "ImplementedInterface": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider", - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Constructor", - "Name": ".ctor", - "Parameters": [ - { - "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" - } - ], - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "GetPolicyAsync", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "policyName", - "Type": "System.String" - } - ], - "ReturnType": "System.Threading.Tasks.Task", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "EvaluatePolicy", - "Parameters": [ - { - "Name": "context", - "Type": "Microsoft.AspNetCore.Http.HttpContext" - }, - { - "Name": "policy", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" - } - ], - "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "ApplyResult", - "Parameters": [ - { - "Name": "result", - "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsResult" - }, - { - "Name": "response", - "Type": "Microsoft.AspNetCore.Http.HttpResponse" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.IDisableCorsAttribute", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [], - "GenericParameters": [] - }, - { - "Name": "Microsoft.AspNetCore.Cors.Infrastructure.IEnableCorsAttribute", - "Visibility": "Public", - "Kind": "Interface", - "Abstract": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "get_PolicyName", - "Parameters": [], - "ReturnType": "System.String", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "set_PolicyName", - "Parameters": [ - { - "Name": "value", - "Type": "System.String" - } - ], - "ReturnType": "System.Void", - "GenericParameter": [] - } - ], - "GenericParameters": [] - }, - { - "Name": "Microsoft.Extensions.DependencyInjection.CorsServiceCollectionExtensions", - "Visibility": "Public", - "Kind": "Class", - "Abstract": true, - "Static": true, - "Sealed": true, - "ImplementedInterfaces": [], - "Members": [ - { - "Kind": "Method", - "Name": "AddCors", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - }, - { - "Kind": "Method", - "Name": "AddCors", - "Parameters": [ - { - "Name": "services", - "Type": "Microsoft.Extensions.DependencyInjection.IServiceCollection" - }, - { - "Name": "setupAction", - "Type": "System.Action" - } - ], - "ReturnType": "Microsoft.Extensions.DependencyInjection.IServiceCollection", - "Static": true, - "Extension": true, - "Visibility": "Public", - "GenericParameter": [] - } - ], - "GenericParameters": [] - } - ] -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index b45add831d..ef15c8fcd3 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -3,8 +3,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 true true diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index 8876346a2a..b5a8811f44 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -3,8 +3,7 @@ - net46;netcoreapp2.0 - netcoreapp2.0 + netcoreapp2.0 From 0365f3a97fb304597efd0862d02d679104272569 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 10 May 2017 12:07:52 -0700 Subject: [PATCH 178/271] Remove unnecessary package references (#110) --- build/dependencies.props | 1 - 1 file changed, 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8738a88691..0a6c8d6eb5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,6 @@ 2.0.0-* - 4.3.0 2.1.0-* 4.7.1 $(BundledNETStandardPackageVersion) From 1e148819af302dd38d9a7e5baaeecc8ca514cd6d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 12 May 2017 16:38:04 -0700 Subject: [PATCH 179/271] Upgrade test framework versions --- build/dependencies.props | 4 ++-- .../Microsoft.AspNetCore.Cors.Test.csproj | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0a6c8d6eb5..226b77c333 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 2.1.0-* 4.7.1 $(BundledNETStandardPackageVersion) - 15.0.0 - 2.2.0 + 15.3.0-* + 2.3.0-beta2-* diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index ef15c8fcd3..e70812f043 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -22,8 +22,4 @@ - - - - From 6a701fcdb493ba255e49be778bb414eff8932cde Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 15 May 2017 12:38:12 -0700 Subject: [PATCH 180/271] Remove workaround from test project --- .../Microsoft.AspNetCore.Cors.Test.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index e70812f043..6d1845aaac 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -4,8 +4,6 @@ netcoreapp2.0 - true - true From c2262b72346cd1847c5c4ac7eb3f62b9f9f96058 Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Mon, 22 May 2017 16:42:46 -0700 Subject: [PATCH 181/271] Update TFM to netstandard2.0 (#112) --- build/common.props | 4 ++-- build/dependencies.props | 2 +- samples/SampleDestination/SampleDestination.csproj | 6 +++++- samples/SampleOrigin/SampleOrigin.csproj | 6 +++++- .../Microsoft.AspNetCore.Cors.csproj | 2 +- .../Microsoft.AspNetCore.Cors.Test.csproj | 3 ++- .../CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj | 3 ++- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/build/common.props b/build/common.props index ac9d44019f..5f0644002e 100644 --- a/build/common.props +++ b/build/common.props @@ -16,8 +16,8 @@ - - + + diff --git a/build/dependencies.props b/build/dependencies.props index 226b77c333..1a75c90b26 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,7 +3,7 @@ 2.0.0-* 2.1.0-* 4.7.1 - $(BundledNETStandardPackageVersion) + 2.0.0-* 15.3.0-* 2.3.0-beta2-* diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 1105f99d4c..f42b88288b 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 @@ -15,4 +15,8 @@ + + + + diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index a23841a2fb..1466629773 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + net461;netcoreapp2.0 @@ -11,4 +11,8 @@ + + + + diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj index 6ebc1832a8..95ed1db7ae 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -7,7 +7,7 @@ Commonly used types: Microsoft.AspNetCore.Cors.DisableCorsAttribute Microsoft.AspNetCore.Cors.EnableCorsAttribute - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true aspnetcore;cors diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 6d1845aaac..35e1359d43 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index b5a8811f44..a388ffe72c 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 From 6d3ce16da9f4b22488fb6ecc226c50a56a09cde0 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Fri, 26 May 2017 12:38:52 -0700 Subject: [PATCH 182/271] Updated to use the latest shared runtime --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index 1a75c90b26..a5d8ef58f7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,6 +4,7 @@ 2.1.0-* 4.7.1 2.0.0-* + 2.0.0-* 15.3.0-* 2.3.0-beta2-* From 95a978ee24f9914c53217c25f5caacf71752caf3 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:36:15 -0700 Subject: [PATCH 183/271] Branching for rel/2.0.0-preview2 --- NuGet.config | 7 ++++--- build/dependencies.props | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8e65695611..c4bc056c4d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,8 +1,9 @@ - + - + + - + \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index a5d8ef58f7..eb851f4ef6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview2-* 2.1.0-* 4.7.1 2.0.0-* From b8d41d01574517d602b6fdd45b082f8a67548823 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:53:13 -0700 Subject: [PATCH 184/271] Updating build scripts to point to 2.0.0-preview2 KoreBuild --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..3a2476b2b4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..a40bdb87b1 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 2956e1c0e857b2b186d1b05393d430ef608e8c6e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 1 Jun 2017 10:46:40 -0700 Subject: [PATCH 185/271] Updating versions to preview3 --- NuGet.config | 3 ++- version.props | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8e65695611..4e8a1f6de1 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,6 +1,7 @@ - + + diff --git a/version.props b/version.props index 6af4f81de2..193a5999d8 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview2 + preview3 From 96382a3214abd3f346c76ae142b7750fca0cf515 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 26 Jun 2017 09:35:28 -0700 Subject: [PATCH 186/271] Adding libunwind8 to .travis.yml [skip appveyor] --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2a46104677..b10be14215 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ os: - linux - osx osx_image: xcode8.2 +addons: + apt: + packages: + - libunwind8 branches: only: - master From 41def1548f0829679ca477814730d8ef6f7b4226 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 29 Jun 2017 07:47:30 -0700 Subject: [PATCH 187/271] Update dependencies.props * Update Moq to 4.7.49. * Add NETStandardImplicitPackageVersion --- build/dependencies.props | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a5d8ef58f7..787a051c3a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,8 +1,9 @@ - + 2.0.0-* 2.1.0-* - 4.7.1 + 4.7.49 + 2.0.0-* 2.0.0-* 2.0.0-* 15.3.0-* From 25351a6f161930e0d99a29c098a82b806f5d3c5d Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 28 Jun 2017 16:41:31 -0700 Subject: [PATCH 188/271] Remove NETStandard.Library.NETFramework and update Moq --- build/common.props | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build/common.props b/build/common.props index 5f0644002e..8dbbd9e645 100644 --- a/build/common.props +++ b/build/common.props @@ -16,8 +16,4 @@ - - - - From f9cb07b028dd35638544080887f6059a1271820f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Jul 2017 14:05:03 -0700 Subject: [PATCH 189/271] Update LICENSE.txt text --- LICENSE.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 0bdc1962b6..7b2956ecee 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,10 +1,12 @@ -Copyright (c) .NET Foundation. All rights reserved. +Copyright (c) .NET Foundation and Contributors + +All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the +this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR From 8608131b4e383ee9bb3278770a50ced07b79143c Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 3 Jul 2017 17:39:59 -0700 Subject: [PATCH 190/271] Set "TreatWarningsAsErrors" before NuGet restore (#115) * Ensures our build stays clean of NuGet warnings --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index 8dbbd9e645..ba1707b8d8 100644 --- a/build/common.props +++ b/build/common.props @@ -10,6 +10,7 @@ true true $(VersionSuffix)-$(BuildNumber) + true From 8cacc94046dfeb9fcd0d5c83e8d9db7b588e4ed8 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 6 Jul 2017 10:36:45 -0700 Subject: [PATCH 191/271] React to aspnet/BuildTools#293 [ci skip] --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 787a051c3a..20d47945e9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,7 @@  2.0.0-* - 2.1.0-* + 2.0.1-* 4.7.49 2.0.0-* 2.0.0-* From e37a88ae2cfc81c093123313b4a3bface68d0ba8 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 6 Jul 2017 15:08:01 -0700 Subject: [PATCH 192/271] Update version suffix for 2.0.0 RTM release --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 193a5999d8..eba6b16756 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview3 + rtm From febafdc8b2ddc195dcaf8ed764f019fe36cacdf1 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 15:19:22 -0700 Subject: [PATCH 193/271] Remove NETStandard.Library.NETFramework --- samples/SampleDestination/SampleDestination.csproj | 4 ---- samples/SampleOrigin/SampleOrigin.csproj | 4 ---- 2 files changed, 8 deletions(-) diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index f42b88288b..62270d1a17 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -15,8 +15,4 @@ - - - - diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index 1466629773..c8ed56f50b 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -10,9 +10,5 @@ - - - - From 058f0503bbd0873697390c227dabd2529b08202b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:41:28 -0700 Subject: [PATCH 194/271] Branching for 2.0.0 rtm --- NuGet.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..37f0d27ea0 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,7 +2,7 @@ - + From e6d73c4fafa73e78db0234d32e2bb0e197791e13 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:57:55 -0700 Subject: [PATCH 195/271] Updating KoreBuild branch --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..1785334385 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..5e27ed8efb 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 9f1560aafbb7437877f3cc294adf9614b4997ed8 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 7 Jul 2017 14:54:40 -0700 Subject: [PATCH 196/271] Skip first time experience on Appveyor --- appveyor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1041615c68..31efd8196f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -9,6 +9,10 @@ branches: build_script: - ps: .\build.ps1 clone_depth: 1 +environment: + global: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 test: off deploy: off os: Visual Studio 2017 From 7adc92dcefd1ea210d0f09afbace6e85eda2c860 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 21 Jul 2017 12:57:43 -0700 Subject: [PATCH 197/271] 2.0.0-rtm to 2.1.0-preview1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index eba6b16756..1ea46af42a 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.0.0 - rtm + 2.1.0 + preview1 From f332cdb55862700aba06abf731101afca9a9f984 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 24 Jul 2017 17:55:00 -0700 Subject: [PATCH 198/271] Set AspNetCoreVersion --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 20d47945e9..686753a6b7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - + - 2.0.0-* + 2.1.0-* 2.0.1-* 4.7.49 2.0.0-* From dc1bad995fa724180980bb92ce2c24a66a2031a2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Jul 2017 15:12:37 -0700 Subject: [PATCH 199/271] Updating to InternalAspNetCoreSdkVersion 2.1.1-* --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 686753a6b7..3945007fb2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,7 @@ 2.1.0-* - 2.0.1-* + 2.1.1-* 4.7.49 2.0.0-* 2.0.0-* From 17e4efa104e377fc957e1d26fff9bfec0c2725c6 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 25 Jul 2017 16:31:02 -0700 Subject: [PATCH 200/271] Update bootstrappers to use the compiled version of KoreBuild [ci skip] --- .gitignore | 1 + build.cmd | 2 +- build.ps1 | 218 +++++++++++++++++++++++++--------- build.sh | 224 +++++++++++++++++++++++++++++------ build/common.props | 2 +- version.props => version.xml | 3 +- 6 files changed, 356 insertions(+), 94 deletions(-) rename version.props => version.xml (55%) diff --git a/.gitignore b/.gitignore index a435689c0a..b8625ac961 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ node_modules .testPublish/ .vscode global.json +korebuild-lock.txt diff --git a/build.cmd b/build.cmd index 7d4894cb4a..b6c8d24864 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..d5eb4d5cf2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,67 +1,177 @@ -$ErrorActionPreference = "Stop" +#!/usr/bin/env powershell +#requires -version 4 -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) -{ - while($true) - { - try - { - Invoke-WebRequest $url -OutFile $downloadLocation - break - } - catch - { - $exceptionMessage = $_.Exception.Message - Write-Host "Failed to download '$url': $exceptionMessage" - if ($retries -gt 0) { - $retries-- - Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" - Start-Sleep -Seconds 10 +<# +.SYNOPSIS +Build this repository +.DESCRIPTION +Downloads korebuild if required. Then builds the repository. + +.PARAMETER Path +The folder to build. Defaults to the folder containing this script. + +.PARAMETER Channel +The channel of KoreBuild to download. Overrides the value from the config file. + +.PARAMETER DotNetHome +The directory where .NET Core tools will be stored. + +.PARAMETER ToolsSource +The base url where build tools can be downloaded. Overrides the value from the config file. + +.PARAMETER Update +Updates KoreBuild to the latest version even if a lock file is present. + +.PARAMETER ConfigFile +The path to the configuration file that stores values. Defaults to version.xml. + +.PARAMETER MSBuildArgs +Arguments to be passed to MSBuild + +.NOTES +This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. +When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. + +The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. + +.EXAMPLE +Example config file: +```xml + + + + dev + https://aspnetcore.blob.core.windows.net/buildtools + + +``` +#> +[CmdletBinding(PositionalBinding = $false)] +param( + [string]$Path = $PSScriptRoot, + [Alias('c')] + [string]$Channel, + [Alias('d')] + [string]$DotNetHome, + [Alias('s')] + [string]$ToolsSource, + [Alias('u')] + [switch]$Update, + [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$MSBuildArgs +) + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +# +# Functions +# + +function Get-KoreBuild { + + $lockFile = Join-Path $Path 'korebuild-lock.txt' + + if (!(Test-Path $lockFile) -or $Update) { + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + } + + $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 + if (!$version) { + Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" + } + $version = $version.TrimStart('version:').Trim() + $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + + if (!(Test-Path $korebuildPath)) { + Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" + New-Item -ItemType Directory -Path $korebuildPath | Out-Null + $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" + + try { + $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" + Get-RemoteFile $remotePath $tmpfile + if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + # Use built-in commands where possible as they are cross-plat compatible + Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } - else - { - $exception = $_.Exception - throw $exception + else { + # Fallback to old approach for old installations of PowerShell + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) } } + catch { + Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore + throw + } + finally { + Remove-Item $tmpfile -ErrorAction Ignore + } } + + return $korebuildPath } -cd $PSScriptRoot - -$repoFolder = $PSScriptRoot -$env:REPO_FOLDER = $repoFolder - -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if ($env:KOREBUILD_ZIP) -{ - $koreBuildZip=$env:KOREBUILD_ZIP +function Join-Paths([string]$path, [string[]]$childPaths) { + $childPaths | ForEach-Object { $path = Join-Path $path $_ } + return $path } -$buildFolder = ".build" -$buildFile="$buildFolder\KoreBuild.ps1" - -if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - - $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() - New-Item -Path "$tempFolder" -Type directory | Out-Null - - $localZipFile="$tempFolder\korebuild.zip" - - DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 - - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - - New-Item -Path "$buildFolder" -Type directory | Out-Null - copy-item "$tempFolder\**\build\*" $buildFolder -Recurse - - # Cleanup - if (Test-Path $tempFolder) { - Remove-Item -Recurse -Force $tempFolder +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { + if ($RemotePath -notlike 'http*') { + Copy-Item $RemotePath $LocalPath + return } + + $retries = 10 + while ($retries -gt 0) { + $retries -= 1 + try { + Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + return + } + catch { + Write-Verbose "Request failed. $retries retries remaining" + } + } + + Write-Error "Download failed: '$RemotePath'." } -&"$buildFile" @args +# +# Main +# + +# Load configuration or set defaults + +if (Test-Path $ConfigFile) { + [xml] $config = Get-Content $ConfigFile + if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } + if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } +} + +if (!$DotNetHome) { + $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` + elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` + elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` + else { Join-Path $PSScriptRoot '.dotnet'} +} + +if (!$Channel) { $Channel = 'dev' } +if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } + +# Execute + +$korebuildPath = Get-KoreBuild +Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') + +try { + Install-Tools $ToolsSource $DotNetHome + Invoke-RepositoryBuild $Path @MSBuildArgs +} +finally { + Remove-Module 'KoreBuild' -ErrorAction Ignore +} diff --git a/build.sh b/build.sh index b0bcadb579..ab590e62f1 100755 --- a/build.sh +++ b/build.sh @@ -1,46 +1,196 @@ #!/usr/bin/env bash -repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if [ ! -z $KOREBUILD_ZIP ]; then - koreBuildZip=$KOREBUILD_ZIP -fi +set -euo pipefail -buildFolder=".build" -buildFile="$buildFolder/KoreBuild.sh" +# +# variables +# -if test ! -d $buildFolder; then - echo "Downloading KoreBuild from $koreBuildZip" +RESET="\033[0m" +RED="\033[0;31m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +config_file="$DIR/version.xml" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' - tempFolder="/tmp/KoreBuild-$(uuidgen)" - mkdir $tempFolder +# +# Functions +# +__usage() { + echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - localZipFile="$tempFolder/korebuild.zip" - - retries=6 - until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) - do - echo "Failed to download '$koreBuildZip'" - if [ "$retries" -le 0 ]; then - exit 1 - fi - retries=$((retries - 1)) - echo "Waiting 10 seconds before retrying. Retries left: $retries" - sleep 10s - done - - unzip -q -d $tempFolder $localZipFile - - mkdir $buildFolder - cp -r $tempFolder/**/build/** $buildFolder - - chmod +x $buildFile - - # Cleanup - if test -d $tempFolder; then - rm -rf $tempFolder + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 fi +} + +get_korebuild() { + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f $lock_file ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + fi + local version="$(grep 'version:*' -m 1 $lock_file)" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file $remote_path $tmpfile; then + unzip -q -d "$korebuild_path" $tmpfile + fi + rm $tmpfile || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}$@${RESET}" 1>&2 +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp $remote_path $local_path + return 0 + fi + + failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} + +# +# main +# + +while [[ $# > 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel=${1:-} + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME=${1:-} + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 fi -$buildFile -r $repoFolder "$@" +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +if [ -f $config_file ]; then + comment=false + while __read_dom; do + if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi + if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi + if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi + if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi + done < $config_file +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +install_tools "$tools_source" "$DOTNET_HOME" +invoke_repository_build "$repo_path" $@ diff --git a/build/common.props b/build/common.props index ba1707b8d8..6773d64c9f 100644 --- a/build/common.props +++ b/build/common.props @@ -1,6 +1,6 @@ - + Microsoft ASP.NET Core diff --git a/version.props b/version.xml similarity index 55% rename from version.props rename to version.xml index 1ea46af42a..3c05022b7d 100644 --- a/version.props +++ b/version.xml @@ -1,6 +1,7 @@ - + + dev 2.1.0 preview1 From d00b87314093b11b6d627cef02938a970b9f5250 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Jul 2017 10:26:39 -0700 Subject: [PATCH 201/271] Fix syntax warning when running build.sh on older versions of bash [ci skip] --- build.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index ab590e62f1..5568c6182a 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ RESET="\033[0m" RED="\033[0;31m" MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" config_file="$DIR/version.xml" verbose=false update=false @@ -22,7 +22,7 @@ tools_source='' # Functions # __usage() { - echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" echo "" echo "Arguments:" echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." @@ -46,16 +46,17 @@ __usage() { } get_korebuild() { + local version local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f $lock_file ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" fi - local version="$(grep 'version:*' -m 1 $lock_file)" + version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" return 1 fi - version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" { @@ -64,10 +65,10 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file $remote_path $tmpfile; then - unzip -q -d "$korebuild_path" $tmpfile + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" fi - rm $tmpfile || true + rm "$tmpfile" || true fi source "$korebuild_path/KoreBuild.sh" @@ -81,7 +82,7 @@ get_korebuild() { } __error() { - echo -e "${RED}$@${RESET}" 1>&2 + echo -e "${RED}$*${RESET}" 1>&2 } __machine_has() { @@ -94,18 +95,18 @@ __get_remote_file() { local local_path=$2 if [[ "$remote_path" != 'http'* ]]; then - cp $remote_path $local_path + cp "$remote_path" "$local_path" return 0 fi failed=false if __machine_has wget; then - wget --tries 10 --quiet -O $local_path $remote_path || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ]; then @@ -114,13 +115,13 @@ __get_remote_file() { fi } -__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} +__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} # # main # -while [[ $# > 0 ]]; do +while [[ $# -gt 0 ]]; do case $1 in -\?|-h|--help) __usage --no-exit @@ -128,7 +129,7 @@ while [[ $# > 0 ]]; do ;; -c|--channel|-Channel) shift - channel=${1:-} + channel="${1:-}" [ -z "$channel" ] && __usage ;; --config-file|-ConfigFile) @@ -138,7 +139,7 @@ while [[ $# > 0 ]]; do ;; -d|--dotnet-home|-DotNetHome) shift - DOTNET_HOME=${1:-} + DOTNET_HOME="${1:-}" [ -z "$DOTNET_HOME" ] && __usage ;; --path|-Path) @@ -178,14 +179,14 @@ if ! __machine_has curl && ! __machine_has wget; then exit 1 fi -if [ -f $config_file ]; then +if [ -f "$config_file" ]; then comment=false while __read_dom; do if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < $config_file + done < "$config_file" fi [ -z "$channel" ] && channel='dev' @@ -193,4 +194,4 @@ fi get_korebuild install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" $@ +invoke_repository_build "$repo_path" "$@" From c11fce1765e47e8ac19da69c38b19e8522de4606 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 12:44:43 -0700 Subject: [PATCH 202/271] Update __get_remote_file logic --- build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 5568c6182a..8eace4c20d 100755 --- a/build.sh +++ b/build.sh @@ -99,17 +99,16 @@ __get_remote_file() { return 0 fi - failed=false + local succeeded=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + if [ "$succeeded" = false ] && __machine_has curl; then + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true fi - if [ "$failed" = true ]; then + if [ "$succeeded" = false ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From facd1349dad82942e2b0a36ecac216eee32a04b8 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 14:31:01 -0700 Subject: [PATCH 203/271] Ensure fallback to curl after failed wget --- build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 8eace4c20d..11cdbe5504 100755 --- a/build.sh +++ b/build.sh @@ -99,16 +99,19 @@ __get_remote_file() { return 0 fi - local succeeded=false + local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true fi - if [ "$succeeded" = false ] && __machine_has curl; then - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi - if [ "$succeeded" = false ]; then + if [ "$failed" = true ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From 1c093cbbad0e77576c7f79dcc741f69d0fc9f63d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 22 Aug 2017 12:32:02 -0700 Subject: [PATCH 204/271] Upgrade to xunit 2.3.0-beta4 --- build/dependencies.props | 5 +++-- test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3945007fb2..c8494d9360 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,7 +6,8 @@ 2.0.0-* 2.0.0-* 2.0.0-* - 15.3.0-* - 2.3.0-beta2-* + 15.3.0 + 0.6.1 + 2.3.0-beta4-build3742 diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs index d884293e81..01a2c2d8e3 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Assert response.EnsureSuccessStatusCode(); - Assert.Equal(1, response.Headers.Count()); + Assert.Single(response.Headers); Assert.Equal("Cross origin response", await response.Content.ReadAsStringAsync()); Assert.Equal("http://localhost:5001", response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault()); } @@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Assert response.EnsureSuccessStatusCode(); - Assert.Equal(1, response.Headers.Count()); + Assert.Single(response.Headers); Assert.Equal("http://localhost:5001", response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault()); } } From 51aecc2c180e4232dfd9fdd5a11e6ca6688cb996 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 22 Aug 2017 12:32:16 -0700 Subject: [PATCH 205/271] Use Directory.Build.props/targets --- appveyor.yml => .appveyor.yml | 0 CORS.sln | 40 ++++++++++++++++--- build/common.props => Directory.Build.props | 10 ++--- Directory.Build.targets | 2 + .../SampleDestination.csproj | 2 - samples/SampleOrigin/SampleOrigin.csproj | 4 +- src/Directory.Build.props | 8 ++++ .../Microsoft.AspNetCore.Cors.csproj | 2 - test/Directory.Build.props | 8 ++++ .../Microsoft.AspNetCore.Cors.Test.csproj | 3 +- .../CorsMiddlewareWebSite.csproj | 2 - 11 files changed, 57 insertions(+), 24 deletions(-) rename appveyor.yml => .appveyor.yml (100%) rename build/common.props => Directory.Build.props (60%) create mode 100644 Directory.Build.targets create mode 100644 src/Directory.Build.props create mode 100644 test/Directory.Build.props diff --git a/appveyor.yml b/.appveyor.yml similarity index 100% rename from appveyor.yml rename to .appveyor.yml diff --git a/CORS.sln b/CORS.sln index 23483cedb1..04e9060a32 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,24 +1,49 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26127.0 +VisualStudioVersion = 15.0.26817.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F32074C7-087C-46CC-A913-422BFD2D6E0A}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Cors", "src\Microsoft.AspNetCore.Cors\Microsoft.AspNetCore.Cors.csproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Cors", "src\Microsoft.AspNetCore.Cors\Microsoft.AspNetCore.Cors.csproj", "{41349FCD-D1C4-47A6-82D0-D16D00A8D59D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Cors.Test", "test\Microsoft.AspNetCore.Cors.Test\Microsoft.AspNetCore.Cors.Test.csproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Cors.Test", "test\Microsoft.AspNetCore.Cors.Test\Microsoft.AspNetCore.Cors.Test.csproj", "{F05BE96F-F869-4408-A480-96935B4835EE}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{538380BF-0D4C-4E30-8F41-E75C4B1C01FA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CorsMiddlewareWebSite", "test\WebSites\CorsMiddlewareWebSite\CorsMiddlewareWebSite.csproj", "{B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CorsMiddlewareWebSite", "test\WebSites\CorsMiddlewareWebSite\CorsMiddlewareWebSite.csproj", "{B42D4844-FFF8-4EC2-88D1-3AE95234D9EB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{960E0703-A8A5-44DF-AA87-B7C614683B3C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleDestination", "samples\SampleDestination\SampleDestination.csproj", "{F6675DC1-AA21-453B-89B6-DA425FB9C3A5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleDestination", "samples\SampleDestination\SampleDestination.csproj", "{F6675DC1-AA21-453B-89B6-DA425FB9C3A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleOrigin", "samples\SampleOrigin\SampleOrigin.csproj", "{99460370-AE5D-4DC9-8DBF-04DF66D6B21D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleOrigin", "samples\SampleOrigin\SampleOrigin.csproj", "{99460370-AE5D-4DC9-8DBF-04DF66D6B21D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0CCC5C1B-F548-4A17-96F8-14C700093FA0}" + ProjectSection(SolutionItems) = preProject + .appveyor.yml = .appveyor.yml + .gitattributes = .gitattributes + .gitignore = .gitignore + .travis.yml = .travis.yml + build.cmd = build.cmd + build.ps1 = build.ps1 + build.sh = build.sh + CONTRIBUTING.md = CONTRIBUTING.md + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + LICENSE.txt = LICENSE.txt + NuGet.config = NuGet.config + NuGetPackageVerifier.json = NuGetPackageVerifier.json + README.md = README.md + version.xml = version.xml + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -58,4 +83,7 @@ Global {F6675DC1-AA21-453B-89B6-DA425FB9C3A5} = {960E0703-A8A5-44DF-AA87-B7C614683B3C} {99460370-AE5D-4DC9-8DBF-04DF66D6B21D} = {960E0703-A8A5-44DF-AA87-B7C614683B3C} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F9ED9C53-44CD-4853-9621-D028B7B6A431} + EndGlobalSection EndGlobal diff --git a/build/common.props b/Directory.Build.props similarity index 60% rename from build/common.props rename to Directory.Build.props index 6773d64c9f..4d7730ec88 100644 --- a/build/common.props +++ b/Directory.Build.props @@ -1,20 +1,16 @@ - - + + Microsoft ASP.NET Core https://github.com/aspnet/CORS git - $(MSBuildThisFileDirectory)Key.snk + $(MSBuildThisFileDirectory)build\Key.snk true true $(VersionSuffix)-$(BuildNumber) true - - - - diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000000..8c119d5413 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 62270d1a17..7dd3cd9052 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -1,7 +1,5 @@ - - net461;netcoreapp2.0 diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index c8ed56f50b..71330796fc 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -1,7 +1,5 @@ - - net461;netcoreapp2.0 @@ -10,5 +8,5 @@ - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000000..8d481fc111 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj index 95ed1db7ae..89f306e1fd 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -1,7 +1,5 @@  - - CORS middleware and policy for ASP.NET Core to enable cross-origin resource sharing. Commonly used types: diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 0000000000..8d481fc111 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 35e1359d43..17e9d4be5c 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 @@ -17,6 +15,7 @@ + diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index a388ffe72c..141bad506d 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -1,7 +1,5 @@ - - netcoreapp2.0;net461 netcoreapp2.0 From 370bc7d7c5c50b3d47e5a41b8cc8889fe39cbc5f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 30 Aug 2017 17:22:09 -0700 Subject: [PATCH 206/271] Use PackageLineup to manage PackageReference versions --- Directory.Build.props | 3 +-- Directory.Build.targets | 14 +++++++++++++- NuGet.config | 1 - build/dependencies.props | 13 ------------- build/repo.props | 6 ++++++ samples/SampleDestination/SampleDestination.csproj | 6 +++--- samples/SampleOrigin/SampleOrigin.csproj | 6 +++--- src/Directory.Build.props | 4 ++-- .../Microsoft.AspNetCore.Cors.csproj | 10 +++++----- test/Directory.Build.props | 4 ++-- .../Microsoft.AspNetCore.Cors.Test.csproj | 14 +++++++------- .../CorsMiddlewareWebSite.csproj | 6 +++--- 12 files changed, 45 insertions(+), 42 deletions(-) delete mode 100644 build/dependencies.props create mode 100644 build/repo.props diff --git a/Directory.Build.props b/Directory.Build.props index 4d7730ec88..51a66ab496 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@ - - + diff --git a/Directory.Build.targets b/Directory.Build.targets index 8c119d5413..bc118fd907 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,2 +1,14 @@ - + + + + <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh + <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd + <_BootstrapperError> + Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. + Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. + + + + + diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..20060c934e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,7 +3,6 @@ - diff --git a/build/dependencies.props b/build/dependencies.props deleted file mode 100644 index c8494d9360..0000000000 --- a/build/dependencies.props +++ /dev/null @@ -1,13 +0,0 @@ - - - 2.1.0-* - 2.1.1-* - 4.7.49 - 2.0.0-* - 2.0.0-* - 2.0.0-* - 15.3.0 - 0.6.1 - 2.3.0-beta4-build3742 - - diff --git a/build/repo.props b/build/repo.props new file mode 100644 index 0000000000..13fe1c296a --- /dev/null +++ b/build/repo.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 7dd3cd9052..2befa967d3 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -1,4 +1,4 @@ - + net461;netcoreapp2.0 @@ -9,8 +9,8 @@ - - + + diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index 71330796fc..4266cea6fd 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -1,12 +1,12 @@ - + net461;netcoreapp2.0 - - + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 8d481fc111..890bcb3a63 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,8 +1,8 @@ - + - + diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj index 89f306e1fd..b4db871daa 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -12,11 +12,11 @@ Microsoft.AspNetCore.Cors.EnableCorsAttribute - - - - - + + + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 8d481fc111..890bcb3a63 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,8 +1,8 @@ - + - + diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 17e9d4be5c..ccb7618e72 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -11,13 +11,13 @@ - - - - - - - + + + + + + + diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index 141bad506d..3b42f7c410 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.0;net461 @@ -10,8 +10,8 @@ - - + + From 5eae687ddd2f1a297b39a4099fa52e9280517a33 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Sat, 9 Sep 2017 11:47:20 -0700 Subject: [PATCH 207/271] Updated EnableCorsAttribute and UseCors extension to not have to supply a policy name. --- .../EnableCorsAttribute.cs | 11 ++- .../Infrastructure/CorsMiddleware.cs | 14 ++++ .../CorsMiddlewareExtensions.cs | 15 +++++ .../Infrastructure/CorsOptions.cs | 28 ++++++++ .../CorsMiddlewareTests.cs | 52 ++++++++++++++ .../CorsOptionsTest.cs | 67 +++++++++++++++++++ 6 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs diff --git a/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs b/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs index 34bd269d96..b19851e39a 100644 --- a/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs +++ b/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs @@ -11,7 +11,16 @@ namespace Microsoft.AspNetCore.Cors public class EnableCorsAttribute : Attribute, IEnableCorsAttribute { /// - /// Creates a new instance of the . + /// Creates a new instance of the with the default policy + /// name defined by . + /// + public EnableCorsAttribute() + : this(policyName: null) + { + } + + /// + /// Creates a new instance of the with the supplied policy name. /// /// The name of the policy to be applied. public EnableCorsAttribute(string policyName) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs index a5dd632d38..eb773f5abf 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs @@ -19,6 +19,20 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure private readonly CorsPolicy _policy; private readonly string _corsPolicyName; + /// + /// Instantiates a new . + /// + /// The next middleware in the pipeline. + /// An instance of . + /// A policy provider which can get an . + public CorsMiddleware( + RequestDelegate next, + ICorsService corsService, + ICorsPolicyProvider policyProvider) + : this(next, corsService, policyProvider, policyName: null) + { + } + /// /// Instantiates a new . /// diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs index aae7ca4602..dea1ad01d9 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs @@ -11,6 +11,21 @@ namespace Microsoft.AspNetCore.Builder ///
public static class CorsMiddlewareExtensions { + /// + /// Adds a CORS middleware to your web application pipeline to allow cross domain requests. + /// + /// The IApplicationBuilder passed to your Configure method + /// The original app parameter + public static IApplicationBuilder UseCors(this IApplicationBuilder app) + { + if (app == null) + { + throw new ArgumentNullException(nameof(app)); + } + + return app.UseMiddleware(); + } + /// /// Adds a CORS middleware to your web application pipeline to allow cross domain requests. /// diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs index 10b046000d..92e1f775ba 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs @@ -31,6 +31,34 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure } } + /// + /// Adds a new policy and sets it as the default. + /// + /// The policy to be added. + public void AddDefaultPolicy(CorsPolicy policy) + { + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } + + AddPolicy(DefaultPolicyName, policy); + } + + /// + /// Adds a new policy and sets it as the default. + /// + /// A delegate which can use a policy builder to build a policy. + public void AddDefaultPolicy(Action configurePolicy) + { + if (configurePolicy == null) + { + throw new ArgumentNullException(nameof(configurePolicy)); + } + + AddPolicy(DefaultPolicyName, configurePolicy); + } + /// /// Adds a new policy. /// diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs index 01a2c2d8e3..d74c020eae 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs @@ -297,5 +297,57 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure o => o.GetPolicyAsync(It.IsAny(), It.IsAny()), Times.Once); } + + [Fact] + public async Task PreFlight_MatchesDefaultPolicy_SetsResponseHeaders() + { + // Arrange + var hostBuilder = new WebHostBuilder() + .Configure(app => + { + app.UseCors(); + app.Run(async context => + { + await context.Response.WriteAsync("Cross origin response"); + }); + }) + .ConfigureServices(services => + { + services.AddCors(options => + { + options.AddDefaultPolicy(policyBuilder => + { + policyBuilder + .WithOrigins("http://localhost:5001") + .WithMethods("PUT") + .WithHeaders("Header1") + .WithExposedHeaders("AllowedHeader") + .Build(); + }); + options.AddPolicy("policy2", policyBuilder => + { + policyBuilder + .WithOrigins("http://localhost:5002") + .Build(); + }); + }); + }); + + using (var server = new TestServer(hostBuilder)) + { + // Act + // Preflight request. + var response = await server.CreateRequest("/") + .AddHeader(CorsConstants.Origin, "http://localhost:5001") + .AddHeader(CorsConstants.AccessControlRequestMethod, "PUT") + .SendAsync(CorsConstants.PreflightHttpMethod); + + // Assert + response.EnsureSuccessStatusCode(); + Assert.Equal(2, response.Headers.Count()); + Assert.Equal("http://localhost:5001", response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault()); + Assert.Equal("PUT", response.Headers.GetValues(CorsConstants.AccessControlAllowMethods).FirstOrDefault()); + } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs new file mode 100644 index 0000000000..360231d38b --- /dev/null +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Xunit; + +namespace Microsoft.AspNetCore.Cors.Infrastructure +{ + public class CorsOptionsTest + { + [Fact] + public void AddDefaultPolicy_SetsDefaultPolicyName() + { + // Arrange + var corsOptions = new CorsOptions(); + var expectedPolicy = new CorsPolicy(); + + // Act + corsOptions.AddPolicy("policy1", new CorsPolicy()); + corsOptions.AddDefaultPolicy(expectedPolicy); + corsOptions.AddPolicy("policy3", new CorsPolicy()); + + // Assert + var actualPolicy = corsOptions.GetPolicy(corsOptions.DefaultPolicyName); + Assert.Same(expectedPolicy, actualPolicy); + } + + [Fact] + public void AddDefaultPolicy_OverridesDefaultPolicyName() + { + // Arrange + var corsOptions = new CorsOptions(); + var expectedPolicy = new CorsPolicy(); + + // Act + corsOptions.AddDefaultPolicy(new CorsPolicy()); + corsOptions.AddDefaultPolicy(expectedPolicy); + + // Assert + var actualPolicy = corsOptions.GetPolicy(corsOptions.DefaultPolicyName); + Assert.Same(expectedPolicy, actualPolicy); + } + + [Fact] + public void AddDefaultPolicy_UsingPolicyBuilder_SetsDefaultPolicyName() + { + // Arrange + var corsOptions = new CorsOptions(); + CorsPolicy expectedPolicy = null; + + // Act + corsOptions.AddPolicy("policy1", policyBuilder => + { + policyBuilder.AllowAnyOrigin().Build(); + }); + corsOptions.AddDefaultPolicy(policyBuilder => + { + expectedPolicy = policyBuilder.AllowAnyOrigin().Build(); + }); + corsOptions.AddPolicy("policy3", new CorsPolicy()); + + // Assert + var actualPolicy = corsOptions.GetPolicy(corsOptions.DefaultPolicyName); + Assert.Same(expectedPolicy, actualPolicy); + } + } +} \ No newline at end of file From df571655acafb39703935a71a977feec023977d0 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Thu, 21 Sep 2017 17:45:34 -0700 Subject: [PATCH 208/271] Increase Minimum Version of Visual Studio to 15.3.0 --- CORS.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CORS.sln b/CORS.sln index 04e9060a32..afdbf1fdc0 100644 --- a/CORS.sln +++ b/CORS.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26817.0 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{84FE6872-A610-4CEC-855F-A84CBF1F40FC}" ProjectSection(SolutionItems) = preProject src\Directory.Build.props = src\Directory.Build.props From 604efdf994a08906ad4b37e84666f925de08ac20 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 20 Sep 2017 13:18:59 -0700 Subject: [PATCH 209/271] Update bootstrappers --- .appveyor.yml | 4 +- build.cmd | 2 +- build.sh | 197 +------------------------------------- run.cmd | 2 + build.ps1 => run.ps1 | 56 +++++++---- run.sh | 223 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 266 insertions(+), 218 deletions(-) create mode 100644 run.cmd rename build.ps1 => run.ps1 (73%) create mode 100755 run.sh diff --git a/.appveyor.yml b/.appveyor.yml index 31efd8196f..46038786c9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -7,7 +7,7 @@ branches: - dev - /^(.*\/)?ci-.*$/ build_script: - - ps: .\build.ps1 + - ps: .\run.ps1 default-build clone_depth: 1 environment: global: diff --git a/build.cmd b/build.cmd index b6c8d24864..c0050bda12 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh index 11cdbe5504..98a4b22765 100755 --- a/build.sh +++ b/build.sh @@ -1,199 +1,8 @@ #!/usr/bin/env bash set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -config_file="$DIR/version.xml" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}$*${RESET}" 1>&2 -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} - -# -# main -# - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -if [ -f "$config_file" ]; then - comment=false - while __read_dom; do - if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi - if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi - if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi - if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < "$config_file" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" "$@" +# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) +chmod +x "$DIR/run.sh"; sync +"$DIR/run.sh" default-build "$@" diff --git a/run.cmd b/run.cmd new file mode 100644 index 0000000000..d52d5c7e68 --- /dev/null +++ b/run.cmd @@ -0,0 +1,2 @@ +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/run.ps1 similarity index 73% rename from build.ps1 rename to run.ps1 index d5eb4d5cf2..49c2899856 100644 --- a/build.ps1 +++ b/run.ps1 @@ -3,10 +3,13 @@ <# .SYNOPSIS -Build this repository +Executes KoreBuild commands. .DESCRIPTION -Downloads korebuild if required. Then builds the repository. +Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. + +.PARAMETER Command +The KoreBuild command to run. .PARAMETER Path The folder to build. Defaults to the folder containing this script. @@ -24,31 +27,32 @@ The base url where build tools can be downloaded. Overrides the value from the c Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to version.xml. +The path to the configuration file that stores values. Defaults to korebuild.json. -.PARAMETER MSBuildArgs -Arguments to be passed to MSBuild +.PARAMETER Arguments +Arguments to be passed to the command .NOTES This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. -The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. +The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set +in the file are overridden by command line parameters. .EXAMPLE Example config file: -```xml - - - - dev - https://aspnetcore.blob.core.windows.net/buildtools - - +```json +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev", + "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" +} ``` #> [CmdletBinding(PositionalBinding = $false)] param( + [Parameter(Mandatory=$true, Position = 0)] + [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] [string]$Channel, @@ -58,9 +62,9 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [string]$ConfigFile, [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$MSBuildArgs + [string[]]$Arguments ) Set-StrictMode -Version 2 @@ -147,10 +151,20 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { # Load configuration or set defaults +$Path = Resolve-Path $Path +if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } + if (Test-Path $ConfigFile) { - [xml] $config = Get-Content $ConfigFile - if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } - if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } + try { + $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json + if ($config) { + if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } + if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} + } + } catch { + Write-Warning "$ConfigFile could not be read. Its settings will be ignored." + Write-Warning $Error[0] + } } if (!$DotNetHome) { @@ -169,8 +183,8 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Install-Tools $ToolsSource $DotNetHome - Invoke-RepositoryBuild $Path @MSBuildArgs + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Invoke-KoreBuildCommand $Command @Arguments } finally { Remove-Module 'KoreBuild' -ErrorAction Ignore diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000..c278423acc --- /dev/null +++ b/run.sh @@ -0,0 +1,223 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# +# variables +# + +RESET="\033[0m" +RED="\033[0;31m" +YELLOW="\033[0;33m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' + +# +# Functions +# +__usage() { + echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " command The command to be run." + echo " ... Arguments passed to the command. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." + + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 + fi +} + +get_korebuild() { + local version + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + fi + version="$(grep 'version:*' -m 1 "$lock_file")" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" + fi + rm "$tmpfile" || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}error: $*${RESET}" 1>&2 +} + +__warn() { + echo -e "${YELLOW}warning: $*${RESET}" +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp "$remote_path" "$local_path" + return 0 + fi + + local failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +# +# main +# + +command="${1:-}" +shift + +while [[ $# -gt 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel="${1:-}" + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + if [ ! -f "$config_file" ]; then + __error "Invalid value for --config-file. $config_file does not exist." + exit 1 + fi + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME="${1:-}" + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 +fi + +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" +if [ -f "$config_file" ]; then + if __machine_has jq ; then + if jq '.' "$config_file" >/dev/null ; then + config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" + config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + elif __machine_has python ; then + if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" + config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + else + __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + fi + + [ ! -z "${config_channel:-}" ] && channel="$config_channel" + [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +invoke_korebuild_command "$command" "$@" From c2c24c0dd5e3e3f972dbe32e049da3f91503ff8a Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Oct 2017 12:48:23 -0700 Subject: [PATCH 210/271] Add RepositoryRoot --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 51a66ab496..2822644019 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,11 @@ - + Microsoft ASP.NET Core https://github.com/aspnet/CORS git + $(MSBuildThisFileDirectory) $(MSBuildThisFileDirectory)build\Key.snk true true From 8fd36866f9427b8a09cecdd6520ba54b064424c6 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 31 Oct 2017 18:04:49 -0700 Subject: [PATCH 211/271] Pin tool and package versions to make builds more repeatable --- .gitignore | 1 - Directory.Build.props | 6 ++--- Directory.Build.targets | 17 +++---------- NuGet.config | 1 + build/dependencies.props | 25 +++++++++++++++++++ build/repo.props | 9 ++++--- korebuild-lock.txt | 2 ++ korebuild.json | 4 +++ .../SampleDestination.csproj | 4 +-- samples/SampleOrigin/SampleOrigin.csproj | 4 +-- src/Directory.Build.props | 4 +-- .../Microsoft.AspNetCore.Cors.csproj | 10 ++++---- test/Directory.Build.props | 4 +-- .../Microsoft.AspNetCore.Cors.Test.csproj | 14 +++++------ .../CorsMiddlewareWebSite.csproj | 4 +-- version.props | 10 ++++++++ version.xml | 8 ------ 17 files changed, 76 insertions(+), 51 deletions(-) create mode 100644 build/dependencies.props create mode 100644 korebuild-lock.txt create mode 100644 korebuild.json create mode 100644 version.props delete mode 100644 version.xml diff --git a/.gitignore b/.gitignore index b8625ac961..a435689c0a 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,3 @@ node_modules .testPublish/ .vscode global.json -korebuild-lock.txt diff --git a/Directory.Build.props b/Directory.Build.props index 2822644019..d9c69c2289 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,6 @@ - - + + + Microsoft ASP.NET Core @@ -9,7 +10,6 @@ $(MSBuildThisFileDirectory)build\Key.snk true true - $(VersionSuffix)-$(BuildNumber) true diff --git a/Directory.Build.targets b/Directory.Build.targets index bc118fd907..e83ff95e39 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,14 +1,5 @@ - - - - <_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh - <_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd - <_BootstrapperError> - Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'. - Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'. - - - - - + + + $(MicrosoftNETCoreApp20PackageVersion) + diff --git a/NuGet.config b/NuGet.config index 20060c934e..4e8a1f6de1 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,6 +3,7 @@ + diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 0000000000..559c56ac29 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,25 @@ + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + + 2.1.0-preview1-15549 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.1.0-preview1-27480 + 2.0.0 + 15.3.0 + 4.7.49 + 0.7.0 + 2.3.0 + 2.3.0 + + + diff --git a/build/repo.props b/build/repo.props index 13fe1c296a..b55e651b87 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,6 +1,7 @@  - - - - + + + Internal.AspNetCore.Universe.Lineup + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + diff --git a/korebuild-lock.txt b/korebuild-lock.txt new file mode 100644 index 0000000000..45463cc71e --- /dev/null +++ b/korebuild-lock.txt @@ -0,0 +1,2 @@ +version:2.1.0-preview1-15549 +commithash:f570e08585fec510dd60cd4bfe8795388b757a95 diff --git a/korebuild.json b/korebuild.json new file mode 100644 index 0000000000..bd5d51a51b --- /dev/null +++ b/korebuild.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev" +} diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 2befa967d3..04f291ebc3 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index 4266cea6fd..df002ec46b 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 890bcb3a63..4f07cbc45d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,8 +1,8 @@ - + - + diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj index b4db871daa..10d8530a2e 100644 --- a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj +++ b/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj @@ -12,11 +12,11 @@ Microsoft.AspNetCore.Cors.EnableCorsAttribute - - - - - + + + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 890bcb3a63..4f07cbc45d 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,8 +1,8 @@ - + - + diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index ccb7618e72..94fd991fc6 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -11,13 +11,13 @@ - - - - - - - + + + + + + + diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index 3b42f7c410..b5f207f78d 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/version.props b/version.props new file mode 100644 index 0000000000..5c4a7c32d1 --- /dev/null +++ b/version.props @@ -0,0 +1,10 @@ + + + 2.1.0 + preview1 + $(VersionPrefix) + $(VersionPrefix)-$(VersionSuffix)-final + t000 + $(VersionSuffix)-$(BuildNumber) + + diff --git a/version.xml b/version.xml deleted file mode 100644 index 3c05022b7d..0000000000 --- a/version.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - dev - 2.1.0 - preview1 - - From cec4d3799afa208b3d5949fb83618df93ef2192f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 14 Nov 2017 09:57:46 -0800 Subject: [PATCH 212/271] Update samples and tests to target netcoreapp2.1 --- Directory.Build.props | 4 ++++ korebuild-lock.txt | 4 ++-- samples/SampleDestination/SampleDestination.csproj | 2 +- samples/SampleOrigin/SampleOrigin.csproj | 2 +- test/Directory.Build.props | 7 +++++++ .../Microsoft.AspNetCore.Cors.Test.csproj | 3 +-- .../CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj | 3 +-- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index d9c69c2289..ba813d12b1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@  + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 45463cc71e..95f4613014 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15549 -commithash:f570e08585fec510dd60cd4bfe8795388b757a95 +version:2.1.0-preview1-15567 +commithash:903e3104807b1bb8cddd28bdef205b1e2dc021d1 diff --git a/samples/SampleDestination/SampleDestination.csproj b/samples/SampleDestination/SampleDestination.csproj index 04f291ebc3..b8e59ede3a 100644 --- a/samples/SampleDestination/SampleDestination.csproj +++ b/samples/SampleDestination/SampleDestination.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + netcoreapp2.1;net461 diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/samples/SampleOrigin/SampleOrigin.csproj index df002ec46b..b43f880f9c 100644 --- a/samples/SampleOrigin/SampleOrigin.csproj +++ b/samples/SampleOrigin/SampleOrigin.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp2.0 + netcoreapp2.1;net461 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 4f07cbc45d..4244624987 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,6 +1,13 @@ + + netcoreapp2.1 + $(DeveloperBuildTestTfms) + $(StandardTestTfms);netcoreapp2.0 + $(StandardTestTfms);net461 + + diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj index 94fd991fc6..ff45928446 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj +++ b/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj index b5f207f78d..bd2ea479be 100644 --- a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj +++ b/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj @@ -1,8 +1,7 @@  - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) From c9487faa0605ef0b1f340b51edf004ec85b873cd Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 17 Nov 2017 13:00:24 -0800 Subject: [PATCH 213/271] Use MicrosoftNETCoreApp21PackageVersion to determine the runtime framework in netcoreapp2.1 --- Directory.Build.targets | 1 + build/dependencies.props | 1 + 2 files changed, 2 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index e83ff95e39..894b1d0cf8 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,6 @@  $(MicrosoftNETCoreApp20PackageVersion) + $(MicrosoftNETCoreApp21PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 559c56ac29..e4d7f0d6fa 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -15,6 +15,7 @@ 2.1.0-preview1-27480 2.1.0-preview1-27480 2.0.0 + 2.1.0-preview1-25907-02 15.3.0 4.7.49 0.7.0 From 6a4161762ca363b9cad26c40ed6f7cb152d676cd Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 20 Nov 2017 12:15:43 -0800 Subject: [PATCH 214/271] Use MSBuild to set NuGet feeds instead of NuGet.config --- Directory.Build.props | 1 + NuGet.config | 4 +--- build/sources.props | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 build/sources.props diff --git a/Directory.Build.props b/Directory.Build.props index ba813d12b1..c81115d310 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,6 +5,7 @@ + Microsoft ASP.NET Core diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..e32bddfd51 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,8 +2,6 @@ - - - + diff --git a/build/sources.props b/build/sources.props new file mode 100644 index 0000000000..c03f3ddb60 --- /dev/null +++ b/build/sources.props @@ -0,0 +1,16 @@ + + + + + $(DotNetRestoreSources) + + $(RestoreSources); + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; + + + $(RestoreSources); + https://api.nuget.org/v3/index.json; + + + From b8d2b3619168a332b5eb7c050c50cfefa44109a4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Nov 2017 16:27:02 -0800 Subject: [PATCH 215/271] Replace aspnetcore-ci-dev feed with aspnetcore-dev --- build/dependencies.props | 24 ++++++++++++------------ build/repo.props | 2 +- build/sources.props | 2 +- korebuild-lock.txt | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index e4d7f0d6fa..5f44058007 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,19 +1,19 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15549 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 - 2.1.0-preview1-27480 + 2.1.0-preview1-15576 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 2.0.0 2.1.0-preview1-25907-02 15.3.0 diff --git a/build/repo.props b/build/repo.props index b55e651b87..07c5f08325 100644 --- a/build/repo.props +++ b/build/repo.props @@ -2,6 +2,6 @@ Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index c03f3ddb60..9feff29d09 100644 --- a/build/sources.props +++ b/build/sources.props @@ -5,7 +5,7 @@ $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 95f4613014..1a99066b7c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15567 -commithash:903e3104807b1bb8cddd28bdef205b1e2dc021d1 +version:2.1.0-preview1-15576 +commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 From e5c95690dbd61f28bcda67fdc5b3d7e50ce68cf5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Nov 2017 14:09:25 -0800 Subject: [PATCH 216/271] Specify runtime versions to install --- build/repo.props | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/repo.props b/build/repo.props index 07c5f08325..78b0ce5879 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,7 +1,14 @@  + + Internal.AspNetCore.Universe.Lineup https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + + + + + From 42099ddf6e1241102b18d3326ae59929d2b87fda Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 1 Dec 2017 10:22:19 -0800 Subject: [PATCH 217/271] Update bootstrappers --- run.ps1 | 17 +++++++++++------ run.sh | 30 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/run.ps1 b/run.ps1 index 49c2899856..27dcf848f8 100644 --- a/run.ps1 +++ b/run.ps1 @@ -29,6 +29,9 @@ Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. +.PARAMETER ToolsSourceSuffix +The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. + .PARAMETER Arguments Arguments to be passed to the command @@ -51,7 +54,7 @@ Example config file: #> [CmdletBinding(PositionalBinding = $false)] param( - [Parameter(Mandatory=$true, Position = 0)] + [Parameter(Mandatory = $true, Position = 0)] [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] @@ -63,6 +66,7 @@ param( [Alias('u')] [switch]$Update, [string]$ConfigFile, + [string]$ToolsSourceSuffix, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -79,7 +83,7 @@ function Get-KoreBuild { $lockFile = Join-Path $Path 'korebuild-lock.txt' if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix } $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 @@ -96,7 +100,7 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile + Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath @@ -124,7 +128,7 @@ function Join-Paths([string]$path, [string[]]$childPaths) { return $path } -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { if ($RemotePath -notlike 'http*') { Copy-Item $RemotePath $LocalPath return @@ -134,7 +138,7 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { while ($retries -gt 0) { $retries -= 1 try { - Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath return } catch { @@ -161,7 +165,8 @@ if (Test-Path $ConfigFile) { if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} } - } catch { + } + catch { Write-Warning "$ConfigFile could not be read. Its settings will be ignored." Write-Warning $Error[0] } diff --git a/run.sh b/run.sh index c278423acc..834961fc3a 100755 --- a/run.sh +++ b/run.sh @@ -17,6 +17,7 @@ update=false repo_path="$DIR" channel='' tools_source='' +tools_source_suffix='' # # Functions @@ -29,13 +30,14 @@ __usage() { echo " ... Arguments passed to the command. Variable number of arguments allowed." echo "" echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." echo "" echo "Description:" echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." @@ -50,7 +52,7 @@ get_korebuild() { local version local lock_file="$repo_path/korebuild-lock.txt" if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" fi version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then @@ -66,7 +68,7 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then + if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then unzip -q -d "$korebuild_path" "$tmpfile" fi rm "$tmpfile" || true @@ -98,6 +100,7 @@ __machine_has() { __get_remote_file() { local remote_path=$1 local local_path=$2 + local remote_path_suffix=$3 if [[ "$remote_path" != 'http'* ]]; then cp "$remote_path" "$local_path" @@ -106,14 +109,14 @@ __get_remote_file() { local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true else failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true fi if [ "$failed" = true ]; then @@ -164,6 +167,11 @@ while [[ $# -gt 0 ]]; do tools_source="${1:-}" [ -z "$tools_source" ] && __usage ;; + --tools-source-suffix|-ToolsSourceSuffix) + shift + tools_source_suffix="${1:-}" + [ -z "$tools_source_suffix" ] && __usage + ;; -u|--update|-Update) update=true ;; From 5dddd72b60d84a654614ea2c54e59c05043f799e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 10 Dec 2017 12:17:45 -0800 Subject: [PATCH 218/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 30 +++++++++++++++--------------- korebuild-lock.txt | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5f44058007..00bac8845f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,24 +3,24 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15576 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 + 2.1.0-preview1-15618 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 2.0.0 - 2.1.0-preview1-25907-02 + 2.1.0-preview1-25915-01 15.3.0 4.7.49 - 0.7.0 - 2.3.0 - 2.3.0 + 0.8.0 + 2.3.1 + 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1a99066b7c..e7cce93009 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15576 -commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 +version:2.1.0-preview1-15618 +commithash:00ce1383114015fe89b221146036e59e6bc11219 From 13568ba8cf2d6c5c1cce39f036d4273aeca0a479 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 13 Dec 2017 20:23:40 +0000 Subject: [PATCH 219/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 00bac8845f..bcd3ecde15 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15618 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 + 2.1.0-preview1-15626 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 2.0.0 - 2.1.0-preview1-25915-01 + 2.1.0-preview1-26008-01 15.3.0 4.7.49 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e7cce93009..8d52a6128c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15618 -commithash:00ce1383114015fe89b221146036e59e6bc11219 +version:2.1.0-preview1-15626 +commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 From 07fbc8e795c7a634741551af52fa4b062790a3b8 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 18 Dec 2017 16:36:39 -0800 Subject: [PATCH 220/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index bcd3ecde15..1c7dfd5a92 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,18 +4,18 @@ 2.1.0-preview1-15626 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 2.0.0 - 2.1.0-preview1-26008-01 + 2.1.0-preview1-26016-05 15.3.0 4.7.49 0.8.0 From 823bbc2809c8ee8ce083e9eb49e50b6bb6f3e576 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 31 Dec 2017 20:37:53 +0000 Subject: [PATCH 221/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- korebuild-lock.txt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 1c7dfd5a92..47eab4bfe3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,17 +3,17 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15626 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 + 2.1.0-preview1-15651 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 2.0.0 2.1.0-preview1-26016-05 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8d52a6128c..7c2e97aa79 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15626 -commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 +version:2.1.0-preview1-15651 +commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 From a5be7e4cb4335fe4b2ef94c1d0f443b25ec3ce34 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 2 Jan 2018 14:30:14 -0800 Subject: [PATCH 222/271] Create ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..101a084f0a --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,3 @@ +THIS ISSUE TRACKER IS CLOSED - please log new issues here: https://github.com/aspnet/Home/issues + +For information about this change, see https://github.com/aspnet/Announcements/issues/283 From c873fc55f9fe8ff5d0de2e54cd763cd4a776c42b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 4 Jan 2018 00:43:22 +0000 Subject: [PATCH 223/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 47eab4bfe3..3f36dee2a0 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,16 +4,16 @@ 2.1.0-preview1-15651 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 2.0.0 2.1.0-preview1-26016-05 15.3.0 From 177f528b93968cb932179a34789ec3c404ea065c Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 6 Jan 2018 14:14:56 -0800 Subject: [PATCH 224/271] Update dependencies.props [auto-updated: dependencies] --- korebuild-lock.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7c2e97aa79..2146d006d7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15651 -commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 +version:2.1.0-preview1-15661 +commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 From 95c663a289c0914b2a2e4bfa4a5250009a0ba95e Mon Sep 17 00:00:00 2001 From: Jass Bagga Date: Mon, 8 Jan 2018 11:04:57 -0800 Subject: [PATCH 225/271] Handle malformed origin Uri (#139) Addresses aspnet/Home#2318 --- .../Infrastructure/CorsPolicyExtensions.cs | 15 +++++++++----- .../CorsPolicyExtensionsTests.cs | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs index deae787231..312f772994 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs @@ -16,11 +16,16 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure { return true; } - var originUri = new Uri(origin, UriKind.Absolute); - return policy.Origins - .Where(o => o.Contains($"://{_WildcardSubdomain}")) - .Select(CreateDomainUri) - .Any(domain => UriHelpers.IsSubdomainOf(originUri, domain)); + + if (Uri.TryCreate(origin, UriKind.Absolute, out var originUri)) + { + return policy.Origins + .Where(o => o.Contains($"://{_WildcardSubdomain}")) + .Select(CreateDomainUri) + .Any(domain => UriHelpers.IsSubdomainOf(originUri, domain)); + } + + return false; } private static Uri CreateDomainUri(string origin) diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs index 2c323162ca..74dd67db0b 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs @@ -23,6 +23,26 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure Assert.True(actual); } + [Theory] + [InlineData(null)] + [InlineData("null")] + [InlineData("http://")] + [InlineData("http://*")] + [InlineData("http://.domain")] + [InlineData("http://.domain/hello")] + public void IsOriginAnAllowedSubdomain_ReturnsFalseIfOriginIsMalformedUri(string malformedOrigin) + { + // Arrange + var policy = new CorsPolicy(); + policy.Origins.Add("http://*.domain"); + + // Act + var actual = policy.IsOriginAnAllowedSubdomain(malformedOrigin); + + // Assert + Assert.False(actual); + } + [Theory] [InlineData("http://sub.domain", "http://*.domain")] [InlineData("http://sub.sub.domain", "http://*.domain")] From 7e27e805c468f396ff5a87187be900f41e0cdad7 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 23 Jan 2018 15:30:26 -0800 Subject: [PATCH 226/271] Branching for 2.1.0-preview1 --- build/dependencies.props | 24 ++++++++++++------------ build/repo.props | 4 ++-- build/sources.props | 4 ++-- korebuild-lock.txt | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3f36dee2a0..7eb56cf814 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview1-15679 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview1-26115-03 15.3.0 4.7.49 0.8.0 diff --git a/build/repo.props b/build/repo.props index 78b0ce5879..d94ff7d00d 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,10 +1,10 @@ - + Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9feff29d09..5d66393335 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,11 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2146d006d7..a474bc0e35 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15661 -commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 +version:2.1.0-preview1-15679 +commithash:5347461137cb45a77ddcc0b55b2478092de43338 From b908f6ba475a42d472f438df12b1c2145bd01f26 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 24 Jan 2018 15:00:26 -0800 Subject: [PATCH 227/271] Updating version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 5c4a7c32d1..370d5ababd 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 302f687487f0793af01596e6604ab9f5e9053987 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 31 Jan 2018 15:01:10 -0800 Subject: [PATCH 228/271] Update dependencies.props to 2.1.0-preview-28193, build tools to 2.1.0-preview1-1010 [ci skip] Scripted changes: - updated travis and appveyor.yml files to only build dev, ci, and release branches - updated dependencies.props - updated korebuild-lock.txt - updated korebuild.json to release/2.1 channel --- .appveyor.yml | 15 +++++++-------- .travis.yml | 23 ++++++++++++----------- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- korebuild.json | 4 ++-- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 46038786c9..4eea96ab69 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,18 +1,17 @@ init: - - git config --global core.autocrlf true +- git config --global core.autocrlf true branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ build_script: - - ps: .\run.ps1 default-build +- ps: .\run.ps1 default-build clone_depth: 1 environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: off -deploy: off +test: 'off' +deploy: 'off' os: Visual Studio 2017 diff --git a/.travis.yml b/.travis.yml index b10be14215..64bdbb4441 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,24 +3,25 @@ sudo: false dist: trusty env: global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: none os: - - linux - - osx +- linux +- osx osx_image: xcode8.2 addons: apt: packages: - - libunwind8 + - libunwind8 branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi +- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s + /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib + /usr/local/lib/; fi script: - - ./build.sh +- ./build.sh diff --git a/build/dependencies.props b/build/dependencies.props index 7eb56cf814..b318e43ea3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15679 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 + 2.1.0-preview1-1010 + 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.0.0 - 2.1.0-preview1-26115-03 + 2.1.0-preview1-26122-01 15.3.0 4.7.49 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a474bc0e35..851bfbf203 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15679 -commithash:5347461137cb45a77ddcc0b55b2478092de43338 +version:2.1.0-preview1-1010 +commithash:75ca924dfbd673c38841025b04c4dcd93b84f56d diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From 13e2b6d8e703b87725391e13bddedc6ee85002ec Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 1 Feb 2018 03:00:24 +0000 Subject: [PATCH 229/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3f36dee2a0..cf13050255 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview2-15692 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview2-26130-04 15.3.0 4.7.49 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2146d006d7..232cb858c2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15661 -commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 +version:2.1.0-preview2-15692 +commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 From 58411b4cc4badb5ade2c4960c90e6ebf3e1daf2c Mon Sep 17 00:00:00 2001 From: Priyanshu Agrawal Date: Sat, 3 Feb 2018 01:24:56 +0530 Subject: [PATCH 230/271] Use header names from HttpAbstractions Closes aspnet/Home#2319 This will use constants defined in HeaderNames class instead of hard coded strings. --- .../Infrastructure/CorsConstants.cs | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs index 602f381ae5..bc8a994387 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.Net.Http.Headers; + namespace Microsoft.AspNetCore.Cors.Infrastructure { /// @@ -10,13 +12,13 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// The HTTP method for the CORS preflight request. - /// + /// public static readonly string PreflightHttpMethod = "OPTIONS"; /// /// The Origin request header. /// - public static readonly string Origin = "Origin"; + public static readonly string Origin = HeaderNames.Origin; /// /// The value for the Access-Control-Allow-Origin response header to allow all origins. @@ -26,59 +28,60 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// /// The Access-Control-Request-Method request header. /// - public static readonly string AccessControlRequestMethod = "Access-Control-Request-Method"; + public static readonly string AccessControlRequestMethod = HeaderNames.AccessControlRequestMethod; /// /// The Access-Control-Request-Headers request header. /// - public static readonly string AccessControlRequestHeaders = "Access-Control-Request-Headers"; + public static readonly string AccessControlRequestHeaders = HeaderNames.AccessControlRequestHeaders; /// /// The Access-Control-Allow-Origin response header. /// - public static readonly string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; + public static readonly string AccessControlAllowOrigin = HeaderNames.AccessControlAllowOrigin; /// /// The Access-Control-Allow-Headers response header. /// - public static readonly string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; + public static readonly string AccessControlAllowHeaders = HeaderNames.AccessControlAllowHeaders; /// /// The Access-Control-Expose-Headers response header. /// - public static readonly string AccessControlExposeHeaders = "Access-Control-Expose-Headers"; + public static readonly string AccessControlExposeHeaders = HeaderNames.AccessControlExposeHeaders; /// /// The Access-Control-Allow-Methods response header. /// - public static readonly string AccessControlAllowMethods = "Access-Control-Allow-Methods"; + public static readonly string AccessControlAllowMethods = HeaderNames.AccessControlAllowMethods; /// /// The Access-Control-Allow-Credentials response header. /// - public static readonly string AccessControlAllowCredentials = "Access-Control-Allow-Credentials"; + public static readonly string AccessControlAllowCredentials = HeaderNames.AccessControlAllowCredentials; /// /// The Access-Control-Max-Age response header. /// - public static readonly string AccessControlMaxAge = "Access-Control-Max-Age"; + public static readonly string AccessControlMaxAge = HeaderNames.AccessControlMaxAge; + internal static readonly string[] SimpleRequestHeaders = { - "Origin", - "Accept", - "Accept-Language", - "Content-Language", + HeaderNames.Origin, + HeaderNames.Accept, + HeaderNames.AcceptLanguage, + HeaderNames.ContentLanguage, }; internal static readonly string[] SimpleResponseHeaders = { - "Cache-Control", - "Content-Language", - "Content-Type", - "Expires", - "Last-Modified", - "Pragma" + HeaderNames.CacheControl, + HeaderNames.ContentLanguage, + HeaderNames.ContentType, + HeaderNames.Expires, + HeaderNames.LastModified, + HeaderNames.Pragma }; internal static readonly string[] SimpleMethods = From e0e4b007ec1a73468a12e4dbb2333ef5348dfaad Mon Sep 17 00:00:00 2001 From: Priyanshu Agrawal Date: Sat, 3 Feb 2018 01:36:28 +0530 Subject: [PATCH 231/271] Use http method names from HttpAbstractions This uses http method names from strings defined HttpMethods class instead of hard coded strings. --- .../Infrastructure/CorsConstants.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs index bc8a994387..8028f9eb63 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.AspNetCore.Http; using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Cors.Infrastructure @@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure /// /// The HTTP method for the CORS preflight request. /// - public static readonly string PreflightHttpMethod = "OPTIONS"; + public static readonly string PreflightHttpMethod = HttpMethods.Options; /// /// The Origin request header. @@ -86,9 +87,9 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure internal static readonly string[] SimpleMethods = { - "GET", - "HEAD", - "POST" + HttpMethods.Get, + HttpMethods.Head, + HttpMethods.Post }; } } \ No newline at end of file From fd4b2d62c93acd60e603c4422a2a9cffe597b48a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 3 Feb 2018 02:39:20 +0000 Subject: [PATCH 232/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- korebuild-lock.txt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cf13050255..a9fc74942a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,17 +3,17 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15692 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 + 2.1.0-preview2-15694 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 232cb858c2..6f294ef0e6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15692 -commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 +version:2.1.0-preview2-15694 +commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b From ce82951c56b48395171b2a3e28911c6011c02217 Mon Sep 17 00:00:00 2001 From: Priyanshu Agrawal Date: Mon, 5 Feb 2018 23:52:53 +0530 Subject: [PATCH 233/271] Remove extra white-spaces --- src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs index 8028f9eb63..22110b2e41 100644 --- a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs +++ b/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure { /// /// The HTTP method for the CORS preflight request. - /// + /// public static readonly string PreflightHttpMethod = HttpMethods.Options; /// From 936588acf62c8dca2e9268c9a411306661c63a28 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 9 Feb 2018 11:36:35 -0800 Subject: [PATCH 234/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- korebuild-lock.txt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a9fc74942a..68c7392ff7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,17 +3,17 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15694 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 + 2.1.0-preview2-15698 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6f294ef0e6..3e2b56b91b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15694 -commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b +version:2.1.0-preview2-15698 +commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 From 308994481ad28b86e1249f80c824b1fc78bbbdf0 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 11 Feb 2018 12:17:56 -0800 Subject: [PATCH 235/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 68c7392ff7..f5de3dfb0e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,23 +4,23 @@ 2.1.0-preview2-15698 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 2.0.0 2.1.0-preview2-26130-04 15.3.0 4.7.49 0.8.0 2.3.1 - 2.3.1 + 2.4.0-beta.1.build3945 From 4fae13ce9bc1f144041ee8ec019c2d8ed01f2075 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 18 Feb 2018 12:12:57 -0800 Subject: [PATCH 236/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 22 +++++++++++----------- korebuild-lock.txt | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index f5de3dfb0e..0b29a3a851 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,17 +3,17 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15698 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 + 2.1.0-preview2-15707 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3e2b56b91b..89d0ad3d15 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15698 -commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 +version:2.1.0-preview2-15707 +commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 From bf7017bf99b318214e4985e8bc1c76c64769a050 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 18:26:51 -0800 Subject: [PATCH 237/271] Use FeatureBranchVersionSuffix when generating VersionSuffix --- version.props | 1 + 1 file changed, 1 insertion(+) diff --git a/version.props b/version.props index 370d5ababd..65c8a07e37 100644 --- a/version.props +++ b/version.props @@ -5,6 +5,7 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 + $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From 5ccfd3c568aeb756cc29f403b264148e7536e93d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 26 Feb 2018 10:56:36 -0800 Subject: [PATCH 238/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0b29a3a851..781795b583 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,20 +3,20 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15707 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 + 2.1.0-preview2-15721 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 2.0.0 2.1.0-preview2-26130-04 - 15.3.0 + 15.6.0 4.7.49 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89d0ad3d15..e6c7fddffa 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15707 -commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 +version:2.1.0-preview2-15721 +commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 From a174f575a7cde06e4fc97b0b4792cfeec0692f5e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:02:58 -0800 Subject: [PATCH 239/271] Use dotnet-core feed in repos --- build/sources.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/sources.props b/build/sources.props index 9feff29d09..9215df9751 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,10 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; From 3a0abce0048763f5a793fa51adbb895a18def847 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:02:58 -0800 Subject: [PATCH 240/271] Prepend FeatureBranchVersionPrefix if FeatureBranchVersionSuffix is specified --- version.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.props b/version.props index 65c8a07e37..a11ea1ed52 100644 --- a/version.props +++ b/version.props @@ -5,7 +5,8 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 - $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) + a- + $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From fd64d416d21c0ed61bc90eda71bcb8bd6567c60b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Mar 2018 10:28:58 -0800 Subject: [PATCH 241/271] Add pipeline files for dotnet-ci (#143) --- build/buildpipeline/linux.groovy | 10 ++++++++++ build/buildpipeline/osx.groovy | 10 ++++++++++ build/buildpipeline/pipeline.groovy | 15 +++++++++++++++ build/buildpipeline/windows.groovy | 12 ++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 build/buildpipeline/linux.groovy create mode 100644 build/buildpipeline/osx.groovy create mode 100644 build/buildpipeline/pipeline.groovy create mode 100644 build/buildpipeline/windows.groovy diff --git a/build/buildpipeline/linux.groovy b/build/buildpipeline/linux.groovy new file mode 100644 index 0000000000..db675fd883 --- /dev/null +++ b/build/buildpipeline/linux.groovy @@ -0,0 +1,10 @@ +@Library('dotnet-ci') _ + +simpleNode('Ubuntu14.04','latest') { + stage ('Checking out source') { + checkout scm + } + stage ('Build') { + sh './build.sh' + } +} diff --git a/build/buildpipeline/osx.groovy b/build/buildpipeline/osx.groovy new file mode 100644 index 0000000000..4ba37e4af1 --- /dev/null +++ b/build/buildpipeline/osx.groovy @@ -0,0 +1,10 @@ +@Library('dotnet-ci') _ + +simpleNode('OSX10.12','latest') { + stage ('Checking out source') { + checkout scm + } + stage ('Build') { + sh './build.sh' + } +} diff --git a/build/buildpipeline/pipeline.groovy b/build/buildpipeline/pipeline.groovy new file mode 100644 index 0000000000..027a2f71e2 --- /dev/null +++ b/build/buildpipeline/pipeline.groovy @@ -0,0 +1,15 @@ +import org.dotnet.ci.pipelines.Pipeline + +def windowsPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/windows.groovy') +def linuxPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/linux.groovy') +def osxPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/osx.groovy') +String configuration = 'Release' + +windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", ['Configuration':configuration]) +windowsPipeline.triggerPipelineOnGithubPush(['Configuration':configuration]) + +linuxPipeline.triggerPipelineOnEveryGithubPR("Ubuntu14.04 ${configuration} Build", ['Configuration':configuration]) +linuxPipeline.triggerPipelineOnGithubPush(['Configuration':configuration]) + +osxPipeline.triggerPipelineOnEveryGithubPR("OSX10.12 ${configuration} Build", ['Configuration':configuration]) +osxPipeline.triggerPipelineOnGithubPush(['Configuration':configuration]) diff --git a/build/buildpipeline/windows.groovy b/build/buildpipeline/windows.groovy new file mode 100644 index 0000000000..c650b781a6 --- /dev/null +++ b/build/buildpipeline/windows.groovy @@ -0,0 +1,12 @@ +@Library('dotnet-ci') _ + +// 'node' indicates to Jenkins that the enclosed block runs on a node that matches +// the label 'windows-with-vs' +simpleNode('Windows_NT','latest') { + stage ('Checking out source') { + checkout scm + } + stage ('Build') { + bat '.\\run.cmd default-build' + } +} From 4288ae2117e2936cfe6b482b184ffcd4398cdcc9 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Mar 2018 10:43:50 -0800 Subject: [PATCH 242/271] Update to Ubuntu 16.04 --- build/buildpipeline/linux.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/buildpipeline/linux.groovy b/build/buildpipeline/linux.groovy index db675fd883..89b84f5bd3 100644 --- a/build/buildpipeline/linux.groovy +++ b/build/buildpipeline/linux.groovy @@ -1,6 +1,6 @@ @Library('dotnet-ci') _ -simpleNode('Ubuntu14.04','latest') { +simpleNode('Ubuntu16.04','latest') { stage ('Checking out source') { checkout scm } From 0ede153272a4ff854dd8b8824faf77e0b509c875 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Mar 2018 10:50:45 -0800 Subject: [PATCH 243/271] WIP --- build/buildpipeline/linux.groovy | 2 +- build/buildpipeline/pipeline.groovy | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build/buildpipeline/linux.groovy b/build/buildpipeline/linux.groovy index 89b84f5bd3..ea5428f9af 100644 --- a/build/buildpipeline/linux.groovy +++ b/build/buildpipeline/linux.groovy @@ -1,6 +1,6 @@ @Library('dotnet-ci') _ -simpleNode('Ubuntu16.04','latest') { +simpleNode('Ubuntu16.04', 'latest-or-auto-docker') { stage ('Checking out source') { checkout scm } diff --git a/build/buildpipeline/pipeline.groovy b/build/buildpipeline/pipeline.groovy index 027a2f71e2..5c207bebbd 100644 --- a/build/buildpipeline/pipeline.groovy +++ b/build/buildpipeline/pipeline.groovy @@ -4,12 +4,17 @@ def windowsPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/windows def linuxPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/linux.groovy') def osxPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/osx.groovy') String configuration = 'Release' +def parameters = [ + 'Configuration': configuration, + 'DOTNET_CLI_TELEMETRY_OPTOUT': 'true', + 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE': 'true' +] -windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", ['Configuration':configuration]) -windowsPipeline.triggerPipelineOnGithubPush(['Configuration':configuration]) +windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", parameters) +windowsPipeline.triggerPipelineOnGithubPush(parameters) -linuxPipeline.triggerPipelineOnEveryGithubPR("Ubuntu14.04 ${configuration} Build", ['Configuration':configuration]) -linuxPipeline.triggerPipelineOnGithubPush(['Configuration':configuration]) +linuxPipeline.triggerPipelineOnEveryGithubPR("Ubuntu 16.04 ${configuration} Build", parameters) +linuxPipeline.triggerPipelineOnGithubPush(parameters) -osxPipeline.triggerPipelineOnEveryGithubPR("OSX10.12 ${configuration} Build", ['Configuration':configuration]) -osxPipeline.triggerPipelineOnGithubPush(['Configuration':configuration]) +osxPipeline.triggerPipelineOnEveryGithubPR("OSX 10.12 ${configuration} Build", parameters) +osxPipeline.triggerPipelineOnGithubPush(parameters) From 9dd75411cf1958bf27050a6ea17bc14694a03282 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Mar 2018 11:22:49 -0800 Subject: [PATCH 244/271] Specify a JobName so build logs are prettier --- build/buildpipeline/pipeline.groovy | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build/buildpipeline/pipeline.groovy b/build/buildpipeline/pipeline.groovy index 5c207bebbd..104d560246 100644 --- a/build/buildpipeline/pipeline.groovy +++ b/build/buildpipeline/pipeline.groovy @@ -10,11 +10,13 @@ def parameters = [ 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE': 'true' ] -windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", parameters) -windowsPipeline.triggerPipelineOnGithubPush(parameters) +def jobName = "${RepoName} ${BrancName}" -linuxPipeline.triggerPipelineOnEveryGithubPR("Ubuntu 16.04 ${configuration} Build", parameters) -linuxPipeline.triggerPipelineOnGithubPush(parameters) +windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", parameters, jobName) +windowsPipeline.triggerPipelineOnGithubPush(parameters, jobName) -osxPipeline.triggerPipelineOnEveryGithubPR("OSX 10.12 ${configuration} Build", parameters) -osxPipeline.triggerPipelineOnGithubPush(parameters) +linuxPipeline.triggerPipelineOnEveryGithubPR("Ubuntu 16.04 ${configuration} Build", parameters, jobName) +linuxPipeline.triggerPipelineOnGithubPush(parameters, jobName) + +osxPipeline.triggerPipelineOnEveryGithubPR("OSX 10.12 ${configuration} Build", parameters, jobName) +osxPipeline.triggerPipelineOnGithubPush(parameters, jobName) From c9c1b20c61fca0dc2edf04fa7b2d2b21b106b070 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Mar 2018 11:25:29 -0800 Subject: [PATCH 245/271] Fix typo --- build/buildpipeline/pipeline.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/buildpipeline/pipeline.groovy b/build/buildpipeline/pipeline.groovy index 104d560246..ef41be50a6 100644 --- a/build/buildpipeline/pipeline.groovy +++ b/build/buildpipeline/pipeline.groovy @@ -10,7 +10,7 @@ def parameters = [ 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE': 'true' ] -def jobName = "${RepoName} ${BrancName}" +def jobName = "${RepoName} ${BranchName}" windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", parameters, jobName) windowsPipeline.triggerPipelineOnGithubPush(parameters, jobName) From fcecc0d69100d2c9f72343a6e7512bd6f162bd2c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Mar 2018 12:03:10 -0800 Subject: [PATCH 246/271] Move setting up environment variables in to build stage --- build/buildpipeline/linux.groovy | 5 +++++ build/buildpipeline/osx.groovy | 5 +++++ build/buildpipeline/pipeline.groovy | 18 +++++++----------- build/buildpipeline/windows.groovy | 5 +++++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/build/buildpipeline/linux.groovy b/build/buildpipeline/linux.groovy index ea5428f9af..bf5cb24b84 100644 --- a/build/buildpipeline/linux.groovy +++ b/build/buildpipeline/linux.groovy @@ -5,6 +5,11 @@ simpleNode('Ubuntu16.04', 'latest-or-auto-docker') { checkout scm } stage ('Build') { + environment { + DOTNET_CLI_TELEMETRY_OPTOUT = 'true' + DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true' + } + sh './build.sh' } } diff --git a/build/buildpipeline/osx.groovy b/build/buildpipeline/osx.groovy index 4ba37e4af1..1edc741f69 100644 --- a/build/buildpipeline/osx.groovy +++ b/build/buildpipeline/osx.groovy @@ -5,6 +5,11 @@ simpleNode('OSX10.12','latest') { checkout scm } stage ('Build') { + environment { + DOTNET_CLI_TELEMETRY_OPTOUT = 'true' + DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true' + } + sh './build.sh' } } diff --git a/build/buildpipeline/pipeline.groovy b/build/buildpipeline/pipeline.groovy index ef41be50a6..e915cadae1 100644 --- a/build/buildpipeline/pipeline.groovy +++ b/build/buildpipeline/pipeline.groovy @@ -5,18 +5,14 @@ def linuxPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/linux.gro def osxPipeline = Pipeline.createPipeline(this, 'build/buildpipeline/osx.groovy') String configuration = 'Release' def parameters = [ - 'Configuration': configuration, - 'DOTNET_CLI_TELEMETRY_OPTOUT': 'true', - 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE': 'true' + 'Configuration': configuration ] -def jobName = "${RepoName} ${BranchName}" +windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", parameters) +windowsPipeline.triggerPipelineOnGithubPush(parameters) -windowsPipeline.triggerPipelineOnEveryGithubPR("Windows ${configuration} x64 Build", parameters, jobName) -windowsPipeline.triggerPipelineOnGithubPush(parameters, jobName) +linuxPipeline.triggerPipelineOnEveryGithubPR("Ubuntu 16.04 ${configuration} Build", parameters) +linuxPipeline.triggerPipelineOnGithubPush(parameters) -linuxPipeline.triggerPipelineOnEveryGithubPR("Ubuntu 16.04 ${configuration} Build", parameters, jobName) -linuxPipeline.triggerPipelineOnGithubPush(parameters, jobName) - -osxPipeline.triggerPipelineOnEveryGithubPR("OSX 10.12 ${configuration} Build", parameters, jobName) -osxPipeline.triggerPipelineOnGithubPush(parameters, jobName) +osxPipeline.triggerPipelineOnEveryGithubPR("OSX 10.12 ${configuration} Build", parameters) +osxPipeline.triggerPipelineOnGithubPush(parameters) diff --git a/build/buildpipeline/windows.groovy b/build/buildpipeline/windows.groovy index c650b781a6..0a48753500 100644 --- a/build/buildpipeline/windows.groovy +++ b/build/buildpipeline/windows.groovy @@ -7,6 +7,11 @@ simpleNode('Windows_NT','latest') { checkout scm } stage ('Build') { + environment { + DOTNET_CLI_TELEMETRY_OPTOUT = 'true' + DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true' + } + bat '.\\run.cmd default-build' } } From e78144fea73a6aedcd1dccea7a9a0d9e9d4de4ae Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 8 Mar 2018 12:55:13 -0800 Subject: [PATCH 247/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 781795b583..0bf26439b1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15721 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 + 2.1.0-preview2-15728 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 2.0.0 - 2.1.0-preview2-26130-04 + 2.1.0-preview2-26225-03 15.6.0 4.7.49 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e6c7fddffa..138d848db1 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15721 -commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 +version:2.1.0-preview2-15728 +commithash:393377068ddcf51dfee0536536d455f57a828b06 From 7addc9d681c373b8edda6d5cfd0fb52e346bbe3b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 7 Mar 2018 15:01:04 -0800 Subject: [PATCH 248/271] Use --ci when running CI scripts --- .appveyor.yml | 6 +----- .travis.yml | 6 +----- build/buildpipeline/linux.groovy | 7 +------ build/buildpipeline/osx.groovy | 7 +------ build/buildpipeline/windows.groovy | 7 +------ korebuild-lock.txt | 4 ++-- run.ps1 | 16 ++++++++++++++-- run.sh | 16 +++++++++++++++- 8 files changed, 36 insertions(+), 33 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4eea96ab69..d9c226b09f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -6,12 +6,8 @@ branches: - /^release\/.*$/ - /^(.*\/)?ci-.*$/ build_script: -- ps: .\run.ps1 default-build +- ps: .\run.ps1 -CI default-build clone_depth: 1 -environment: - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 test: 'off' deploy: 'off' os: Visual Studio 2017 diff --git a/.travis.yml b/.travis.yml index 64bdbb4441..1ad255d7b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,6 @@ language: csharp sudo: false dist: trusty -env: - global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: none os: - linux @@ -24,4 +20,4 @@ before_install: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi script: -- ./build.sh +- ./build.sh --ci diff --git a/build/buildpipeline/linux.groovy b/build/buildpipeline/linux.groovy index bf5cb24b84..903f218bb8 100644 --- a/build/buildpipeline/linux.groovy +++ b/build/buildpipeline/linux.groovy @@ -5,11 +5,6 @@ simpleNode('Ubuntu16.04', 'latest-or-auto-docker') { checkout scm } stage ('Build') { - environment { - DOTNET_CLI_TELEMETRY_OPTOUT = 'true' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true' - } - - sh './build.sh' + sh './build.sh --ci' } } diff --git a/build/buildpipeline/osx.groovy b/build/buildpipeline/osx.groovy index 1edc741f69..aaac63686b 100644 --- a/build/buildpipeline/osx.groovy +++ b/build/buildpipeline/osx.groovy @@ -5,11 +5,6 @@ simpleNode('OSX10.12','latest') { checkout scm } stage ('Build') { - environment { - DOTNET_CLI_TELEMETRY_OPTOUT = 'true' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true' - } - - sh './build.sh' + sh './build.sh --ci' } } diff --git a/build/buildpipeline/windows.groovy b/build/buildpipeline/windows.groovy index 0a48753500..8d26f313d4 100644 --- a/build/buildpipeline/windows.groovy +++ b/build/buildpipeline/windows.groovy @@ -7,11 +7,6 @@ simpleNode('Windows_NT','latest') { checkout scm } stage ('Build') { - environment { - DOTNET_CLI_TELEMETRY_OPTOUT = 'true' - DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 'true' - } - - bat '.\\run.cmd default-build' + bat '.\\run.cmd -CI default-build' } } diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db1..c82244cb12 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview2-15740 +commithash:bd6837684b57e50ffabfb564645013199585bd6d diff --git a/run.ps1 b/run.ps1 index 27dcf848f8..96c6c54c69 100644 --- a/run.ps1 +++ b/run.ps1 @@ -26,12 +26,18 @@ The base url where build tools can be downloaded. Overrides the value from the c .PARAMETER Update Updates KoreBuild to the latest version even if a lock file is present. +.PARAMETER Reinstall +Re-installs KoreBuild + .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. .PARAMETER ToolsSourceSuffix The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. +.PARAMETER CI +Sets up CI specific settings and variables. + .PARAMETER Arguments Arguments to be passed to the command @@ -65,8 +71,10 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile, + [switch]$Reinstall, [string]$ToolsSourceSuffix, + [string]$ConfigFile = $null, + [switch]$CI, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -93,6 +101,10 @@ function Get-KoreBuild { $version = $version.TrimStart('version:').Trim() $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + if ($Reinstall -and (Test-Path $korebuildPath)) { + Remove-Item -Force -Recurse $korebuildPath + } + if (!(Test-Path $korebuildPath)) { Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" New-Item -ItemType Directory -Path $korebuildPath | Out-Null @@ -188,7 +200,7 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI Invoke-KoreBuildCommand $Command @Arguments } finally { diff --git a/run.sh b/run.sh index 834961fc3a..4606a42e78 100755 --- a/run.sh +++ b/run.sh @@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" [ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" verbose=false update=false +reinstall=false repo_path="$DIR" channel='' tools_source='' tools_source_suffix='' +ci=false # # Functions @@ -38,6 +40,8 @@ __usage() { echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --reinstall Reinstall KoreBuild." + echo " --ci Apply CI specific settings and environment variables." echo "" echo "Description:" echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." @@ -62,6 +66,10 @@ get_korebuild() { version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then + rm -rf "$korebuild_path" + fi + { if [ ! -d "$korebuild_path" ]; then mkdir -p "$korebuild_path" @@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do -u|--update|-Update) update=true ;; + --reinstall|-[Rr]einstall) + reinstall=true + ;; + --ci) + ci=true + ;; --verbose|-Verbose) verbose=true ;; @@ -227,5 +241,5 @@ fi [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" invoke_korebuild_command "$command" "$@" From ce32d84bd67c0b349712a539333011e6d042e820 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:13:41 -0700 Subject: [PATCH 249/271] Branching for 2.1.0-preview2 --- build/dependencies.props | 24 ++++++++++++------------ build/repo.props | 4 ++-- build/sources.props | 2 +- korebuild-lock.txt | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0bf26439b1..c8180fa6e9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview2-15742 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 2.0.0 - 2.1.0-preview2-26225-03 + 2.1.0-preview2-26314-02 15.6.0 4.7.49 0.8.0 diff --git a/build/repo.props b/build/repo.props index 78b0ce5879..d94ff7d00d 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,10 +1,10 @@ - + Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9215df9751..36045f12b5 100644 --- a/build/sources.props +++ b/build/sources.props @@ -6,7 +6,7 @@ $(RestoreSources); https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index c82244cb12..e40ef6651b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15740 -commithash:bd6837684b57e50ffabfb564645013199585bd6d +version:2.1.0-preview2-15742 +commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 From f3b06f52f467376aa4f1a775cefb425876a3dd45 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:25:35 -0700 Subject: [PATCH 250/271] Update version prefix to preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a11ea1ed52..24f2b00a0a 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 6855143c5003244715c32069e79ddf0709b0152f Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 12:28:19 -0700 Subject: [PATCH 251/271] Update KoreBuild channel --- korebuild.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From 3edca24004ea69af6d582064669cdd8aa709bf6e Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 14 Mar 2018 15:33:27 -0700 Subject: [PATCH 252/271] Set 2.0 baselines --- build/dependencies.props | 2 +- korebuild-lock.txt | 4 +- .../baseline.netcore.json | 60 ++++++++++++++++++- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c8180fa6e9..850df44f46 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,7 +3,7 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15742 + 2.1.0-preview2-15744 2.1.0-preview2-30355 2.1.0-preview2-30355 2.1.0-preview2-30355 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e40ef6651b..f531e7b0f7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15742 -commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 +version:2.1.0-preview2-15744 +commithash:9e15cb6062ab5b9790d3fa699e018543a6950713 diff --git a/src/Microsoft.AspNetCore.Cors/baseline.netcore.json b/src/Microsoft.AspNetCore.Cors/baseline.netcore.json index b9e31fcb82..31d8e0dd50 100644 --- a/src/Microsoft.AspNetCore.Cors/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Cors/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Cors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Cors, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions", @@ -423,6 +423,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "get_IsOriginAllowed", + "Parameters": [], + "ReturnType": "System.Func", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "set_IsOriginAllowed", + "Parameters": [ + { + "Name": "value", + "Type": "System.Func" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "get_ExposedHeaders", @@ -632,6 +653,27 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "SetIsOriginAllowed", + "Parameters": [ + { + "Name": "isOriginAllowed", + "Type": "System.Func" + } + ], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "SetIsOriginAllowedToAllowWildcardSubdomains", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "Build", @@ -921,6 +963,22 @@ ], "Visibility": "Public", "GenericParameter": [] + }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "options", + "Type": "Microsoft.Extensions.Options.IOptions" + }, + { + "Name": "loggerFactory", + "Type": "Microsoft.Extensions.Logging.ILoggerFactory" + } + ], + "Visibility": "Public", + "GenericParameter": [] } ], "GenericParameters": [] From 25a124c478d8256119afa5096ab849708f39e853 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 25 Mar 2018 15:33:15 -0700 Subject: [PATCH 253/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 26 +++++++++++++------------- korebuild-lock.txt | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0bf26439b1..51d1414a6a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,20 +3,20 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview3-17001 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 2.0.0 - 2.1.0-preview2-26225-03 - 15.6.0 + 2.1.0-preview2-26314-02 + 15.6.1 4.7.49 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index c82244cb12..3a326c7d58 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15740 -commithash:bd6837684b57e50ffabfb564645013199585bd6d +version:2.1.0-preview3-17001 +commithash:dda68c56abf0d3b911fe6a2315872c446b314585 From 195b378bcb2a7b6d424703169b34ff8a4198af6b Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Wed, 28 Mar 2018 10:38:19 -0700 Subject: [PATCH 254/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 26 +++++++++++++------------- korebuild-lock.txt | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 850df44f46..82aa2dc9a9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,20 +3,20 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15744 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 + 2.1.0-preview2-15749 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 2.0.0 - 2.1.0-preview2-26314-02 - 15.6.0 + 2.1.0-preview2-26326-03 + 15.6.1 4.7.49 0.8.0 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f531e7b0f7..b8e036fe2c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15744 -commithash:9e15cb6062ab5b9790d3fa699e018543a6950713 +version:2.1.0-preview2-15749 +commithash:5544c9ab20fa5e24b9e155d8958a3c3b6f5f9df9 From 737dfad13318e9d39664d761cc3eaff7ee4c83b8 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 3 Apr 2018 22:20:35 +0000 Subject: [PATCH 255/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 51d1414a6a..2ca2f1323e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17001 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 + 2.1.0-preview3-17002 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview3-26331-01 15.6.1 4.7.49 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3a326c7d58..b3af0b8bce 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17001 -commithash:dda68c56abf0d3b911fe6a2315872c446b314585 +version:2.1.0-preview3-17002 +commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f From c4b9e061ca8c5720c4dcdf8b68d2b071bccdb332 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 12 Apr 2018 17:29:31 -0700 Subject: [PATCH 256/271] Update usage of TestSink --- .../CorsServiceTests.cs | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs index 40164da6d7..8a71ce7b42 100644 --- a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs +++ b/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Linq; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging.Testing; using Xunit; @@ -304,10 +305,11 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("The request is a preflight request.", sink.Writes[0].State.ToString()); - Assert.Equal(logData.OriginLogMessage, sink.Writes[1].State.ToString()); - Assert.Equal(logData.PolicyLogMessage, sink.Writes[2].State.ToString()); - Assert.Equal(logData.FailureReason, sink.Writes[3].State.ToString()); + var writeList = sink.Writes.ToList(); + Assert.Equal("The request is a preflight request.", writeList[0].State.ToString()); + Assert.Equal(logData.OriginLogMessage, writeList[1].State.ToString()); + Assert.Equal(logData.PolicyLogMessage, writeList[2].State.ToString()); + Assert.Equal(logData.FailureReason, writeList[3].State.ToString()); } [Fact] @@ -325,9 +327,10 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("The request is a preflight request.", sink.Writes[0].State.ToString()); - Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", sink.Writes[1].State.ToString()); - Assert.Equal("Policy execution successful.", sink.Writes[2].State.ToString()); + var writeList = sink.Writes.ToList(); + Assert.Equal("The request is a preflight request.", writeList[0].State.ToString()); + Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", writeList[1].State.ToString()); + Assert.Equal("Policy execution successful.", writeList[2].State.ToString()); } [Fact] @@ -345,8 +348,9 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("The request is a preflight request.", sink.Writes[0].State.ToString()); - Assert.Equal("The request does not have an origin header.", sink.Writes[1].State.ToString()); + var writeList = sink.Writes.ToList(); + Assert.Equal("The request is a preflight request.", writeList[0].State.ToString()); + Assert.Equal("The request does not have an origin header.", writeList[1].State.ToString()); } [Fact] @@ -363,9 +367,10 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("The request has an origin header: 'http://example.com'.", sink.Writes[0].State.ToString()); - Assert.Equal("Policy execution failed.", sink.Writes[1].State.ToString()); - Assert.Equal("Request origin http://example.com does not have permission to access the resource.", sink.Writes[2].State.ToString()); + var writeList = sink.Writes.ToList(); + Assert.Equal("The request has an origin header: 'http://example.com'.", writeList[0].State.ToString()); + Assert.Equal("Policy execution failed.", writeList[1].State.ToString()); + Assert.Equal("Request origin http://example.com does not have permission to access the resource.", writeList[2].State.ToString()); } [Fact] @@ -382,8 +387,9 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure // Act var result = corsService.EvaluatePolicy(requestContext, policy); - Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", sink.Writes[0].State.ToString()); - Assert.Equal("Policy execution successful.", sink.Writes[1].State.ToString()); + var writeList = sink.Writes.ToList(); + Assert.Equal("The request has an origin header: 'http://allowed.example.com'.", writeList[0].State.ToString()); + Assert.Equal("Policy execution successful.", writeList[1].State.ToString()); } [Fact] From a7105cabd106f5485deb50f8a17bbd39b8d9e1af Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Apr 2018 14:03:41 -0700 Subject: [PATCH 257/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 2ca2f1323e..3ee34c7070 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17002 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 + 2.1.0-preview3-17018 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 2.0.0 - 2.1.0-preview3-26331-01 + 2.1.0-preview3-26413-05 15.6.1 4.7.49 0.8.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b3af0b8bce..b419d767b9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17002 -commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f +version:2.1.0-preview3-17018 +commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be From 8ee8c842880224492a9111585f8339f490d39595 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 16:55:22 -0700 Subject: [PATCH 258/271] Branching for 2.1.0-rc1 --- build/repo.props | 3 ++- korebuild.json | 4 ++-- version.props | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/repo.props b/build/repo.props index 78b0ce5879..dab1601c88 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,9 +1,10 @@ - + Internal.AspNetCore.Universe.Lineup + 2.1.0-rc1-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } diff --git a/version.props b/version.props index 24f2b00a0a..e27532787e 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview3 + rc1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From a743eb057cc3375d34e570bcb2fb4cb00d101e49 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Apr 2018 16:31:09 -0700 Subject: [PATCH 259/271] Set NETStandardImplicitPackageVersion via dependencies.props --- Directory.Build.targets | 1 + build/dependencies.props | 1 + 2 files changed, 2 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 894b1d0cf8..53b3f6e1da 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -2,5 +2,6 @@ $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(NETStandardLibrary20PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 3ee34c7070..9b595f424f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -17,6 +17,7 @@ 2.0.0 2.1.0-preview3-26413-05 15.6.1 + 2.0.1 4.7.49 0.8.0 2.3.1 From 767c3ddb85054822231d0810a93f68457c16e10e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 19 Apr 2018 22:16:42 -0700 Subject: [PATCH 260/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 26 +++++++++++++------------- korebuild-lock.txt | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9b595f424f..7c25bbe83f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17018 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 + 2.1.0-rc1-15774 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 2.0.0 - 2.1.0-preview3-26413-05 + 2.1.0-rc1-26419-02 15.6.1 - 2.0.1 4.7.49 + 2.0.1 0.8.0 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b419d767b9..9d4ef8c888 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.1.0-rc1-15774 +commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 From 483a69cd9a7fb21acbc90fbde7011faca2343545 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 30 Apr 2018 14:51:37 -0700 Subject: [PATCH 261/271] Bump version to 2.1.0-rtm --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index e27532787e..b9552451d8 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - rc1 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 054943b33e27c0685c491ef4f47eca423349368d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 4 May 2018 07:29:47 -0700 Subject: [PATCH 262/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 26 +++++++++++++------------- korebuild-lock.txt | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7c25bbe83f..5a614ad912 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,22 +3,22 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.1.0-rtm-15783 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-rtm-26502-02 15.6.1 4.7.49 - 2.0.1 + 2.0.3 0.8.0 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 9d4ef8c888..3673744db9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rc1-15774 -commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 +version:2.1.0-rtm-15783 +commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 From b7e4884b863bca074581cb88079bfbf3c9d9e277 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 29 May 2018 09:32:57 -0700 Subject: [PATCH 263/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5a614ad912..b89681e2eb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rtm-15783 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 + 2.1.1-rtm-15790 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 2.0.0 - 2.1.0-rtm-26502-02 + 2.1.0 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3673744db9..cd5b409a1e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rtm-15783 -commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 +version:2.1.1-rtm-15790 +commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 From 5fd4b0af55f5d486e2c40a5801f106662d797392 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 5 Jun 2018 09:11:29 -0700 Subject: [PATCH 264/271] Bumping version from 2.1.0 to 2.1.1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index b9552451d8..669c874829 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@ - + - 2.1.0 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From ccd4d50d6fb9d17466d582f31f7a8618914b9a68 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 12 Jun 2018 19:14:41 +0000 Subject: [PATCH 265/271] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 24 ++++++++++++------------ korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index b89681e2eb..4ae168a412 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,19 +3,19 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.1-rtm-15790 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1-rtm-15793 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 2.0.0 - 2.1.0 + 2.1.1 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index cd5b409a1e..bc84e0cd53 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15790 -commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 +version:2.1.1-rtm-15793 +commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a From 01477ecf619c7cb9fd66598104de9e80f98caf23 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 13 Jun 2018 10:53:25 -0700 Subject: [PATCH 266/271] Set 2.1 baselines --- .../baseline.netcore.json | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Cors/baseline.netcore.json b/src/Microsoft.AspNetCore.Cors/baseline.netcore.json index 31d8e0dd50..ef96cf2eed 100644 --- a/src/Microsoft.AspNetCore.Cors/baseline.netcore.json +++ b/src/Microsoft.AspNetCore.Cors/baseline.netcore.json @@ -1,5 +1,5 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.Cors, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.Cors, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { "Name": "Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions", @@ -10,6 +10,21 @@ "Sealed": true, "ImplementedInterfaces": [], "Members": [ + { + "Kind": "Method", + "Name": "UseCors", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Builder.IApplicationBuilder" + } + ], + "ReturnType": "Microsoft.AspNetCore.Builder.IApplicationBuilder", + "Static": true, + "Extension": true, + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "UseCors", @@ -106,6 +121,13 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [], + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -262,6 +284,26 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Constructor", + "Name": ".ctor", + "Parameters": [ + { + "Name": "next", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + }, + { + "Name": "corsService", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsService" + }, + { + "Name": "policyProvider", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.ICorsPolicyProvider" + } + ], + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Constructor", "Name": ".ctor", @@ -336,6 +378,32 @@ "Visibility": "Public", "GenericParameter": [] }, + { + "Kind": "Method", + "Name": "AddDefaultPolicy", + "Parameters": [ + { + "Name": "policy", + "Type": "Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "AddDefaultPolicy", + "Parameters": [ + { + "Name": "configurePolicy", + "Type": "System.Action" + } + ], + "ReturnType": "System.Void", + "Visibility": "Public", + "GenericParameter": [] + }, { "Kind": "Method", "Name": "AddPolicy", From d9f5f35b7a3a7c7512e8fecad43e5ff4ffd6b587 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 27 Jun 2018 13:39:44 -0700 Subject: [PATCH 267/271] Bumping version from 2.1.1 to 2.1.2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 669c874829..478dfd16ed 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.1 + 2.1.2 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 9a4374b5c5ede0ba9ae7d055bad8fed51f937494 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jul 2018 15:06:26 -0700 Subject: [PATCH 268/271] Reverting version from 2.1.2 back to 2.1.1 As a result of changing the way we apply servicing updates to aspnet core, this repo did not need the version bump because there are no planned product changes in this repo. --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 478dfd16ed..669c874829 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.2 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From c49b3a30d0440a18dee1e92ac498f10489d3407a Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jul 2018 18:47:48 -0700 Subject: [PATCH 269/271] Updating dependencies to 2.1.2 and adding a section for pinned variable versions --- build/dependencies.props | 15 +++++++++++---- korebuild-lock.txt | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4ae168a412..cdfd62477d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,11 +2,13 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - 2.1.1-rtm-15793 + + + + 2.1.3-rtm-15802 2.1.1 2.1.1 - 2.1.1 + 2.1.2 2.1.1 2.1.1 2.1.1 @@ -15,7 +17,7 @@ 2.1.1 2.1.1 2.0.0 - 2.1.1 + 2.1.2 15.6.1 4.7.49 2.0.3 @@ -23,5 +25,10 @@ 2.3.1 2.4.0-beta.1.build3945 + + + + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index bc84e0cd53..251c227c83 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15793 -commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a +version:2.1.3-rtm-15802 +commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a From ec429447bfd5f419b9f40676b03b85a954b40f74 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 12 Jul 2018 11:50:59 -0700 Subject: [PATCH 270/271] Pin version variables to the ASP.NET Core 2.1.2 baseline This reverts our previous policy of cascading versions on all servicing updates. This moves variables into the 'pinned' section, and points them to the latest stable release (versions that were used at the time of the 2.1.2 release). --- build/dependencies.props | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cdfd62477d..36fe73426a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,18 +4,8 @@ - + 2.1.3-rtm-15802 - 2.1.1 - 2.1.1 - 2.1.2 - 2.1.1 - 2.1.1 - 2.1.1 - 2.1.1 - 2.1.1 - 2.1.1 - 2.1.1 2.0.0 2.1.2 15.6.1 @@ -30,5 +20,16 @@ - - + + 2.1.1 + 2.1.1 + 2.1.2 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + + \ No newline at end of file From 2374a67d552623460f71b237b33baacd2c7778b0 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 21 Nov 2018 15:03:35 -0800 Subject: [PATCH 271/271] Reorganize source code in preparation to move into aspnet/AspNetCore Prior to reorganization, this source code was found in https://github.com/aspnet/CORS/tree/ec429447bfd5f419b9f40676b03b85a954b40f74 --- .appveyor.yml | 13 - .gitattributes | 51 ---- .github/ISSUE_TEMPLATE.md | 3 - .travis.yml | 23 -- CONTRIBUTING.md | 4 - LICENSE.txt | 14 - NuGet.config | 7 - build.cmd | 2 - build.sh | 8 - korebuild-lock.txt | 2 - korebuild.json | 4 - run.cmd | 2 - run.ps1 | 208 --------------- run.sh | 245 ------------------ .gitignore => src/CORS/.gitignore | 0 CORS.sln => src/CORS/CORS.sln | 0 .../CORS/Directory.Build.props | 0 .../CORS/Directory.Build.targets | 0 .../CORS/NuGetPackageVerifier.json | 0 README.md => src/CORS/README.md | 0 {build => src/CORS/build}/Key.snk | Bin .../CORS/build}/buildpipeline/linux.groovy | 0 .../CORS/build}/buildpipeline/osx.groovy | 0 .../CORS/build}/buildpipeline/pipeline.groovy | 0 .../CORS/build}/buildpipeline/windows.groovy | 0 {build => src/CORS/build}/dependencies.props | 0 {build => src/CORS/build}/repo.props | 0 {build => src/CORS/build}/sources.props | 0 {samples => src/CORS/samples}/README.md | 0 .../samples}/SampleDestination/Program.cs | 0 .../SampleDestination.csproj | 0 .../samples}/SampleDestination/Startup.cs | 0 .../CORS/samples}/SampleOrigin/Program.cs | 0 .../samples}/SampleOrigin/SampleOrigin.csproj | 0 .../CORS/samples}/SampleOrigin/Startup.cs | 0 .../samples}/SampleOrigin/wwwroot/Index.html | 0 src/{ => CORS/src}/Directory.Build.props | 0 .../CorsServiceCollectionExtensions.cs | 0 .../DisableCorsAttribute.cs | 0 .../EnableCorsAttribute.cs | 0 .../Infrastructure/CorsConstants.cs | 0 .../Infrastructure/CorsMiddleware.cs | 0 .../CorsMiddlewareExtensions.cs | 0 .../Infrastructure/CorsOptions.cs | 0 .../Infrastructure/CorsPolicy.cs | 0 .../Infrastructure/CorsPolicyBuilder.cs | 0 .../Infrastructure/CorsPolicyExtensions.cs | 0 .../Infrastructure/CorsResult.cs | 0 .../Infrastructure/CorsService.cs | 0 .../DefaultCorsPolicyProvider.cs | 0 .../Infrastructure/ICorsPolicyProvider.cs | 0 .../Infrastructure/ICorsService.cs | 0 .../Infrastructure/IDisableCorsAttribute.cs | 0 .../Infrastructure/IEnableCorsAttribute.cs | 0 .../Infrastructure/UriHelpers.cs | 0 .../Internal/CORSLoggerExtensions.cs | 0 .../Microsoft.AspNetCore.Cors.csproj | 0 .../Properties/AssemblyInfo.cs | 0 .../Resources.Designer.cs | 0 .../Microsoft.AspNetCore.Cors/Resources.resx | 0 .../baseline.netcore.json | 0 {test => src/CORS/test}/Directory.Build.props | 0 .../CorsMiddlewareFunctionalTest.cs | 0 .../CorsMiddlewareTests.cs | 0 .../CorsOptionsTest.cs | 0 .../CorsPolicyBuilderTests.cs | 0 .../CorsPolicyExtensionsTests.cs | 0 .../CorsPolicyTests.cs | 0 .../CorsResultTests.cs | 0 .../CorsServiceTests.cs | 0 .../CorsTestFixtureOfT.cs | 0 .../DefaultCorsPolicyProviderTests.cs | 0 .../Microsoft.AspNetCore.Cors.Test.csproj | 0 .../TestCorsOptions.cs | 0 .../UriHelpersTests.cs | 0 .../CorsMiddlewareWebSite.csproj | 0 .../CorsMiddlewareWebSite/EchoMiddleware.cs | 0 .../WebSites/CorsMiddlewareWebSite/Startup.cs | 0 .../WebSites/CorsMiddlewareWebSite/readme.md | 0 .../WebSites/CorsMiddlewareWebSite/web.config | 0 version.props => src/CORS/version.props | 0 81 files changed, 586 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .gitattributes delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE.txt delete mode 100644 NuGet.config delete mode 100644 build.cmd delete mode 100755 build.sh delete mode 100644 korebuild-lock.txt delete mode 100644 korebuild.json delete mode 100644 run.cmd delete mode 100644 run.ps1 delete mode 100755 run.sh rename .gitignore => src/CORS/.gitignore (100%) rename CORS.sln => src/CORS/CORS.sln (100%) rename Directory.Build.props => src/CORS/Directory.Build.props (100%) rename Directory.Build.targets => src/CORS/Directory.Build.targets (100%) rename NuGetPackageVerifier.json => src/CORS/NuGetPackageVerifier.json (100%) rename README.md => src/CORS/README.md (100%) rename {build => src/CORS/build}/Key.snk (100%) rename {build => src/CORS/build}/buildpipeline/linux.groovy (100%) rename {build => src/CORS/build}/buildpipeline/osx.groovy (100%) rename {build => src/CORS/build}/buildpipeline/pipeline.groovy (100%) rename {build => src/CORS/build}/buildpipeline/windows.groovy (100%) rename {build => src/CORS/build}/dependencies.props (100%) rename {build => src/CORS/build}/repo.props (100%) rename {build => src/CORS/build}/sources.props (100%) rename {samples => src/CORS/samples}/README.md (100%) rename {samples => src/CORS/samples}/SampleDestination/Program.cs (100%) rename {samples => src/CORS/samples}/SampleDestination/SampleDestination.csproj (100%) rename {samples => src/CORS/samples}/SampleDestination/Startup.cs (100%) rename {samples => src/CORS/samples}/SampleOrigin/Program.cs (100%) rename {samples => src/CORS/samples}/SampleOrigin/SampleOrigin.csproj (100%) rename {samples => src/CORS/samples}/SampleOrigin/Startup.cs (100%) rename {samples => src/CORS/samples}/SampleOrigin/wwwroot/Index.html (100%) rename src/{ => CORS/src}/Directory.Build.props (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsResult.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/DefaultCorsPolicyProvider.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/ICorsPolicyProvider.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/ICorsService.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/IDisableCorsAttribute.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/IEnableCorsAttribute.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Resources.Designer.cs (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/Resources.resx (100%) rename src/{ => CORS/src}/Microsoft.AspNetCore.Cors/baseline.netcore.json (100%) rename {test => src/CORS/test}/Directory.Build.props (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs (100%) rename {test => src/CORS/test}/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs (100%) rename {test => src/CORS/test}/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj (100%) rename {test => src/CORS/test}/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs (100%) rename {test => src/CORS/test}/WebSites/CorsMiddlewareWebSite/Startup.cs (100%) rename {test => src/CORS/test}/WebSites/CorsMiddlewareWebSite/readme.md (100%) rename {test => src/CORS/test}/WebSites/CorsMiddlewareWebSite/web.config (100%) rename version.props => src/CORS/version.props (100%) diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index d9c226b09f..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,13 +0,0 @@ -init: -- git config --global core.autocrlf true -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -build_script: -- ps: .\run.ps1 -CI default-build -clone_depth: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 97b827b758..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,51 +0,0 @@ -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - -*.jpg binary -*.png binary -*.gif binary - -*.cs text=auto diff=csharp -*.vb text=auto -*.resx text=auto -*.c text=auto -*.cpp text=auto -*.cxx text=auto -*.h text=auto -*.hxx text=auto -*.py text=auto -*.rb text=auto -*.java text=auto -*.html text=auto -*.htm text=auto -*.css text=auto -*.scss text=auto -*.sass text=auto -*.less text=auto -*.js text=auto -*.lisp text=auto -*.clj text=auto -*.sql text=auto -*.php text=auto -*.lua text=auto -*.m text=auto -*.asm text=auto -*.erl text=auto -*.fs text=auto -*.fsx text=auto -*.hs text=auto - -*.csproj text=auto -*.vbproj text=auto -*.fsproj text=auto -*.dbproj text=auto -*.sln text=auto eol=crlf -*.sh eol=lf diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 101a084f0a..0000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,3 +0,0 @@ -THIS ISSUE TRACKER IS CLOSED - please log new issues here: https://github.com/aspnet/Home/issues - -For information about this change, see https://github.com/aspnet/Announcements/issues/283 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1ad255d7b8..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: csharp -sudo: false -dist: trusty -mono: none -os: -- linux -- osx -osx_image: xcode8.2 -addons: - apt: - packages: - - libunwind8 -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -before_install: -- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s - /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib - /usr/local/lib/; fi -script: -- ./build.sh --ci diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 64ff041d5c..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributing -====== - -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 7b2956ecee..0000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index e32bddfd51..0000000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build.cmd b/build.cmd deleted file mode 100644 index c0050bda12..0000000000 --- a/build.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh deleted file mode 100755 index 98a4b22765..0000000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) -chmod +x "$DIR/run.sh"; sync -"$DIR/run.sh" default-build "$@" diff --git a/korebuild-lock.txt b/korebuild-lock.txt deleted file mode 100644 index 251c227c83..0000000000 --- a/korebuild-lock.txt +++ /dev/null @@ -1,2 +0,0 @@ -version:2.1.3-rtm-15802 -commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a diff --git a/korebuild.json b/korebuild.json deleted file mode 100644 index 678d8bb948..0000000000 --- a/korebuild.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", - "channel": "release/2.1" -} diff --git a/run.cmd b/run.cmd deleted file mode 100644 index d52d5c7e68..0000000000 --- a/run.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index 96c6c54c69..0000000000 --- a/run.ps1 +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/env powershell -#requires -version 4 - -<# -.SYNOPSIS -Executes KoreBuild commands. - -.DESCRIPTION -Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. - -.PARAMETER Command -The KoreBuild command to run. - -.PARAMETER Path -The folder to build. Defaults to the folder containing this script. - -.PARAMETER Channel -The channel of KoreBuild to download. Overrides the value from the config file. - -.PARAMETER DotNetHome -The directory where .NET Core tools will be stored. - -.PARAMETER ToolsSource -The base url where build tools can be downloaded. Overrides the value from the config file. - -.PARAMETER Update -Updates KoreBuild to the latest version even if a lock file is present. - -.PARAMETER Reinstall -Re-installs KoreBuild - -.PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to korebuild.json. - -.PARAMETER ToolsSourceSuffix -The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. - -.PARAMETER CI -Sets up CI specific settings and variables. - -.PARAMETER Arguments -Arguments to be passed to the command - -.NOTES -This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. -When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. - -The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set -in the file are overridden by command line parameters. - -.EXAMPLE -Example config file: -```json -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", - "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" -} -``` -#> -[CmdletBinding(PositionalBinding = $false)] -param( - [Parameter(Mandatory = $true, Position = 0)] - [string]$Command, - [string]$Path = $PSScriptRoot, - [Alias('c')] - [string]$Channel, - [Alias('d')] - [string]$DotNetHome, - [Alias('s')] - [string]$ToolsSource, - [Alias('u')] - [switch]$Update, - [switch]$Reinstall, - [string]$ToolsSourceSuffix, - [string]$ConfigFile = $null, - [switch]$CI, - [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$Arguments -) - -Set-StrictMode -Version 2 -$ErrorActionPreference = 'Stop' - -# -# Functions -# - -function Get-KoreBuild { - - $lockFile = Join-Path $Path 'korebuild-lock.txt' - - if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix - } - - $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 - if (!$version) { - Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" - } - $version = $version.TrimStart('version:').Trim() - $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) - - if ($Reinstall -and (Test-Path $korebuildPath)) { - Remove-Item -Force -Recurse $korebuildPath - } - - if (!(Test-Path $korebuildPath)) { - Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" - New-Item -ItemType Directory -Path $korebuildPath | Out-Null - $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" - - try { - $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { - # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath - } - else { - # Fallback to old approach for old installations of PowerShell - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) - } - } - catch { - Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore - throw - } - finally { - Remove-Item $tmpfile -ErrorAction Ignore - } - } - - return $korebuildPath -} - -function Join-Paths([string]$path, [string[]]$childPaths) { - $childPaths | ForEach-Object { $path = Join-Path $path $_ } - return $path -} - -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { - if ($RemotePath -notlike 'http*') { - Copy-Item $RemotePath $LocalPath - return - } - - $retries = 10 - while ($retries -gt 0) { - $retries -= 1 - try { - Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath - return - } - catch { - Write-Verbose "Request failed. $retries retries remaining" - } - } - - Write-Error "Download failed: '$RemotePath'." -} - -# -# Main -# - -# Load configuration or set defaults - -$Path = Resolve-Path $Path -if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } - -if (Test-Path $ConfigFile) { - try { - $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json - if ($config) { - if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } - if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} - } - } - catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] - } -} - -if (!$DotNetHome) { - $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` - elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` - elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` - else { Join-Path $PSScriptRoot '.dotnet'} -} - -if (!$Channel) { $Channel = 'dev' } -if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - -# Execute - -$korebuildPath = Get-KoreBuild -Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - -try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI - Invoke-KoreBuildCommand $Command @Arguments -} -finally { - Remove-Module 'KoreBuild' -ErrorAction Ignore -} diff --git a/run.sh b/run.sh deleted file mode 100755 index 4606a42e78..0000000000 --- a/run.sh +++ /dev/null @@ -1,245 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -YELLOW="\033[0;33m" -MAGENTA="\033[0;95m" -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -verbose=false -update=false -reinstall=false -repo_path="$DIR" -channel='' -tools_source='' -tools_source_suffix='' -ci=false - -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " command The command to be run." - echo " ... Arguments passed to the command. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo " --reinstall Reinstall KoreBuild." - echo " --ci Apply CI specific settings and environment variables." - echo "" - echo "Description:" - echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then - rm -rf "$korebuild_path" - fi - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}error: $*${RESET}" 1>&2 -} - -__warn() { - echo -e "${YELLOW}warning: $*${RESET}" -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - local remote_path_suffix=$3 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -# -# main -# - -command="${1:-}" -shift - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - if [ ! -f "$config_file" ]; then - __error "Invalid value for --config-file. $config_file does not exist." - exit 1 - fi - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - --tools-source-suffix|-ToolsSourceSuffix) - shift - tools_source_suffix="${1:-}" - [ -z "$tools_source_suffix" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --reinstall|-[Rr]einstall) - reinstall=true - ;; - --ci) - ci=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" -if [ -f "$config_file" ]; then - if __machine_has jq ; then - if jq '.' "$config_file" >/dev/null ; then - config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" - config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - elif __machine_has python ; then - if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" - config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' - fi - - [ ! -z "${config_channel:-}" ] && channel="$config_channel" - [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" -invoke_korebuild_command "$command" "$@" diff --git a/.gitignore b/src/CORS/.gitignore similarity index 100% rename from .gitignore rename to src/CORS/.gitignore diff --git a/CORS.sln b/src/CORS/CORS.sln similarity index 100% rename from CORS.sln rename to src/CORS/CORS.sln diff --git a/Directory.Build.props b/src/CORS/Directory.Build.props similarity index 100% rename from Directory.Build.props rename to src/CORS/Directory.Build.props diff --git a/Directory.Build.targets b/src/CORS/Directory.Build.targets similarity index 100% rename from Directory.Build.targets rename to src/CORS/Directory.Build.targets diff --git a/NuGetPackageVerifier.json b/src/CORS/NuGetPackageVerifier.json similarity index 100% rename from NuGetPackageVerifier.json rename to src/CORS/NuGetPackageVerifier.json diff --git a/README.md b/src/CORS/README.md similarity index 100% rename from README.md rename to src/CORS/README.md diff --git a/build/Key.snk b/src/CORS/build/Key.snk similarity index 100% rename from build/Key.snk rename to src/CORS/build/Key.snk diff --git a/build/buildpipeline/linux.groovy b/src/CORS/build/buildpipeline/linux.groovy similarity index 100% rename from build/buildpipeline/linux.groovy rename to src/CORS/build/buildpipeline/linux.groovy diff --git a/build/buildpipeline/osx.groovy b/src/CORS/build/buildpipeline/osx.groovy similarity index 100% rename from build/buildpipeline/osx.groovy rename to src/CORS/build/buildpipeline/osx.groovy diff --git a/build/buildpipeline/pipeline.groovy b/src/CORS/build/buildpipeline/pipeline.groovy similarity index 100% rename from build/buildpipeline/pipeline.groovy rename to src/CORS/build/buildpipeline/pipeline.groovy diff --git a/build/buildpipeline/windows.groovy b/src/CORS/build/buildpipeline/windows.groovy similarity index 100% rename from build/buildpipeline/windows.groovy rename to src/CORS/build/buildpipeline/windows.groovy diff --git a/build/dependencies.props b/src/CORS/build/dependencies.props similarity index 100% rename from build/dependencies.props rename to src/CORS/build/dependencies.props diff --git a/build/repo.props b/src/CORS/build/repo.props similarity index 100% rename from build/repo.props rename to src/CORS/build/repo.props diff --git a/build/sources.props b/src/CORS/build/sources.props similarity index 100% rename from build/sources.props rename to src/CORS/build/sources.props diff --git a/samples/README.md b/src/CORS/samples/README.md similarity index 100% rename from samples/README.md rename to src/CORS/samples/README.md diff --git a/samples/SampleDestination/Program.cs b/src/CORS/samples/SampleDestination/Program.cs similarity index 100% rename from samples/SampleDestination/Program.cs rename to src/CORS/samples/SampleDestination/Program.cs diff --git a/samples/SampleDestination/SampleDestination.csproj b/src/CORS/samples/SampleDestination/SampleDestination.csproj similarity index 100% rename from samples/SampleDestination/SampleDestination.csproj rename to src/CORS/samples/SampleDestination/SampleDestination.csproj diff --git a/samples/SampleDestination/Startup.cs b/src/CORS/samples/SampleDestination/Startup.cs similarity index 100% rename from samples/SampleDestination/Startup.cs rename to src/CORS/samples/SampleDestination/Startup.cs diff --git a/samples/SampleOrigin/Program.cs b/src/CORS/samples/SampleOrigin/Program.cs similarity index 100% rename from samples/SampleOrigin/Program.cs rename to src/CORS/samples/SampleOrigin/Program.cs diff --git a/samples/SampleOrigin/SampleOrigin.csproj b/src/CORS/samples/SampleOrigin/SampleOrigin.csproj similarity index 100% rename from samples/SampleOrigin/SampleOrigin.csproj rename to src/CORS/samples/SampleOrigin/SampleOrigin.csproj diff --git a/samples/SampleOrigin/Startup.cs b/src/CORS/samples/SampleOrigin/Startup.cs similarity index 100% rename from samples/SampleOrigin/Startup.cs rename to src/CORS/samples/SampleOrigin/Startup.cs diff --git a/samples/SampleOrigin/wwwroot/Index.html b/src/CORS/samples/SampleOrigin/wwwroot/Index.html similarity index 100% rename from samples/SampleOrigin/wwwroot/Index.html rename to src/CORS/samples/SampleOrigin/wwwroot/Index.html diff --git a/src/Directory.Build.props b/src/CORS/src/Directory.Build.props similarity index 100% rename from src/Directory.Build.props rename to src/CORS/src/Directory.Build.props diff --git a/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/CorsServiceCollectionExtensions.cs diff --git a/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/DisableCorsAttribute.cs diff --git a/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/EnableCorsAttribute.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsConstants.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddleware.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsMiddlewareExtensions.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsOptions.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicy.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyBuilder.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsPolicyExtensions.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsResult.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsResult.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsResult.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsResult.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/CorsService.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/DefaultCorsPolicyProvider.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/DefaultCorsPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/DefaultCorsPolicyProvider.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/DefaultCorsPolicyProvider.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsPolicyProvider.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsPolicyProvider.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsPolicyProvider.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsPolicyProvider.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsService.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsService.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsService.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/ICorsService.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/IDisableCorsAttribute.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/IDisableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/IDisableCorsAttribute.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/IDisableCorsAttribute.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/IEnableCorsAttribute.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/IEnableCorsAttribute.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/IEnableCorsAttribute.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/IEnableCorsAttribute.cs diff --git a/src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Infrastructure/UriHelpers.cs diff --git a/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Internal/CORSLoggerExtensions.cs diff --git a/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj b/src/CORS/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj rename to src/CORS/src/Microsoft.AspNetCore.Cors/Microsoft.AspNetCore.Cors.csproj diff --git a/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs b/src/CORS/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Resources.Designer.cs rename to src/CORS/src/Microsoft.AspNetCore.Cors/Resources.Designer.cs diff --git a/src/Microsoft.AspNetCore.Cors/Resources.resx b/src/CORS/src/Microsoft.AspNetCore.Cors/Resources.resx similarity index 100% rename from src/Microsoft.AspNetCore.Cors/Resources.resx rename to src/CORS/src/Microsoft.AspNetCore.Cors/Resources.resx diff --git a/src/Microsoft.AspNetCore.Cors/baseline.netcore.json b/src/CORS/src/Microsoft.AspNetCore.Cors/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore.Cors/baseline.netcore.json rename to src/CORS/src/Microsoft.AspNetCore.Cors/baseline.netcore.json diff --git a/test/Directory.Build.props b/src/CORS/test/Directory.Build.props similarity index 100% rename from test/Directory.Build.props rename to src/CORS/test/Directory.Build.props diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareFunctionalTest.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsMiddlewareTests.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsOptionsTest.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyBuilderTests.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyExtensionsTests.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsPolicyTests.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsResultTests.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsServiceTests.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/CorsTestFixtureOfT.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/DefaultCorsPolicyProviderTests.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/Microsoft.AspNetCore.Cors.Test.csproj diff --git a/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/TestCorsOptions.cs diff --git a/test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs b/src/CORS/test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs rename to src/CORS/test/Microsoft.AspNetCore.Cors.Test/UriHelpersTests.cs diff --git a/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj b/src/CORS/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj similarity index 100% rename from test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj rename to src/CORS/test/WebSites/CorsMiddlewareWebSite/CorsMiddlewareWebSite.csproj diff --git a/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs b/src/CORS/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs similarity index 100% rename from test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs rename to src/CORS/test/WebSites/CorsMiddlewareWebSite/EchoMiddleware.cs diff --git a/test/WebSites/CorsMiddlewareWebSite/Startup.cs b/src/CORS/test/WebSites/CorsMiddlewareWebSite/Startup.cs similarity index 100% rename from test/WebSites/CorsMiddlewareWebSite/Startup.cs rename to src/CORS/test/WebSites/CorsMiddlewareWebSite/Startup.cs diff --git a/test/WebSites/CorsMiddlewareWebSite/readme.md b/src/CORS/test/WebSites/CorsMiddlewareWebSite/readme.md similarity index 100% rename from test/WebSites/CorsMiddlewareWebSite/readme.md rename to src/CORS/test/WebSites/CorsMiddlewareWebSite/readme.md diff --git a/test/WebSites/CorsMiddlewareWebSite/web.config b/src/CORS/test/WebSites/CorsMiddlewareWebSite/web.config similarity index 100% rename from test/WebSites/CorsMiddlewareWebSite/web.config rename to src/CORS/test/WebSites/CorsMiddlewareWebSite/web.config diff --git a/version.props b/src/CORS/version.props similarity index 100% rename from version.props rename to src/CORS/version.props