This commit is contained in:
Victor Hurdugaci 2016-01-11 15:53:38 -08:00
Родитель 807cd77307
Коммит 9e032102f6
10 изменённых файлов: 87 добавлений и 75 удалений

1
.gitattributes поставляемый
Просмотреть файл

@ -48,3 +48,4 @@
*.fsproj text=auto
*.dbproj text=auto
*.sln text=auto eol=crlf
*.sh eol=lf

4
.gitignore поставляемый
Просмотреть файл

@ -34,4 +34,6 @@ nuget.exe
*.sln.ide
node_modules
**/[Cc]ompiler/[Rr]esources/**/*.js
*launchSettings.json
*launchSettings.json
.build/
.testPublish/

Просмотреть файл

@ -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 --quiet verify

Просмотреть файл

@ -1,7 +1,7 @@
init:
- git config --global core.autocrlf true
build_script:
- build.cmd --quiet --parallel verify
- build.cmd --quiet verify
clone_depth: 1
test: off
deploy: off

Просмотреть файл

@ -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" %*

Просмотреть файл

@ -1,5 +1,10 @@
#!/usr/bin/env bash
buildFolder=.build
koreBuildFolder=$buildFolder/KoreBuild-dotnet
nugetPath=$buildFolder/nuget.exe
if test `uname` = Darwin; then
cachedir=~/Library/Caches/KBuild
else
@ -11,33 +16,30 @@ 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
chmod +x $koreBuildFolder/build/KoreBuild.sh
fi
if ! type dnvm > /dev/null 2>&1; then
source packages/KoreBuild/build/dnvm.sh
makeFile=makefile.shade
if [ ! -e $makeFile ]; then
makeFile=$koreBuildFolder/build/makefile.shade
fi
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 "$@"
./$koreBuildFolder/build/KoreBuild.sh -n $nugetPath -m $makeFile "$@"

Просмотреть файл

@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Antiforgery.FunctionalTests
var builder = new WebApplicationBuilder()
.UseConfiguration(configurationBuilder.Build())
.UseStartup(typeof(AntiforgerySample.Startup))
.UseApplicationBasePath("../../samples/AntiforgerySample");
.UseApplicationBasePath("../../../../samples/AntiforgerySample");
_server = new TestServer(builder);

Просмотреть файл

@ -27,8 +27,6 @@ namespace Microsoft.AspNet.Antiforgery.FunctionalTests
var response = await Client.GetAsync("http://localhost/Index.html");
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var cookie = RetrieveAntiforgeryCookie(response);
Assert.NotNull(cookie.Value);
@ -40,6 +38,9 @@ namespace Microsoft.AspNet.Antiforgery.FunctionalTests
public async Task PostItem_NeedsHeader()
{
// Arrange
var httpResponse = await Client.GetAsync("http://localhost");
var cookie = RetrieveAntiforgeryCookie(httpResponse);
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/items");
// Act
@ -49,15 +50,14 @@ namespace Microsoft.AspNet.Antiforgery.FunctionalTests
});
// Assert
Assert.Contains("The required antiforgery cookie \"3Cs-jwHTMFk\" is not present.", exception.Message);
Assert.Contains($"The required antiforgery cookie \"{cookie.Key}\" is not present.", exception.Message);
}
[Fact]
public async Task PostItem_XSRFWorks()
{
// Arrange
var content = new StringContent("{'name': 'Todoitem'}");
var httpResponse = await Client.GetAsync("http://localhost/Index.html");
var httpResponse = await Client.GetAsync("/Index.html");
var cookie = RetrieveAntiforgeryCookie(httpResponse);
var token = RetrieveAntiforgeryToken(httpResponse);
@ -71,7 +71,6 @@ namespace Microsoft.AspNet.Antiforgery.FunctionalTests
var response = await Client.SendAsync(httpRequestMessage);
// Assert
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
}

Просмотреть файл

@ -2,23 +2,24 @@
"dependencies": {
"AntiforgerySample": "1.0.0-*",
"Microsoft.AspNet.TestHost": "1.0.0-*",
"Microsoft.AspNet.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
"Microsoft.AspNet.Testing": "1.0.0-*"
},
"testRunner": "xunit",
"commands": {
"run": "xunit.runner.aspnet",
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622",
"System.Net.Http": "4.0.1-rc2-23621"
"System.Net.Http": "4.0.1-rc2-23621",
"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-*"
}
}
}

Просмотреть файл

@ -8,21 +8,26 @@
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.WebEncoders": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
"xunit": "2.1.0-*"
},
"testRunner": "xunit",
"commands": {
"run": "xunit.runner.aspnet",
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Threading.Tasks": ""
},
"dependencies": {
"Moq": "4.2.1312.1622"
"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-*"
}
}
}