Skip to content

Commit

Permalink
Add cookies and claims transformation samples/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoK committed Nov 10, 2017
1 parent 8d5a61f commit 6e75c8e
Show file tree
Hide file tree
Showing 145 changed files with 47,913 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
init:
- git config --global core.autocrlf true
branches:
only:
- master
- release
- dev
- /^(.*\/)?ci-.*$/
- /^rel\/.*/
build_script:
- 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
os: Visual Studio 2017
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ BenchmarkDotNet.Artifacts/
BDN.Generated/
binaries/
global.json
korebuild-lock.txt
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: csharp
sudo: required
dist: trusty
env:
global:
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
addons:
apt:
packages:
- libunwind8
mono: none
os:
- linux
- osx
osx_image: xcode8.2
branches:
only:
- master
- release
- dev
- /^rel\/.*$/
- /^(.*\/)?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
71 changes: 71 additions & 0 deletions AuthSamples.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26823.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{CA4538F5-9DA8-4139-B891-A13279889F79}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{DA474CFD-7419-4747-A583-CCDC1FF71EB5}"
ProjectSection(SolutionItems) = preProject
build\common.props = build\common.props
build\dependencies.props = build\dependencies.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cookies", "samples\Cookies\Cookies.csproj", "{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClaimsTransformation", "samples\ClaimsTransformation\ClaimsTransformation.csproj", "{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{15E42EAC-5CBB-49EC-91FB-53743882CF2B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AuthSamples.FunctionalTests", "test\AuthSamples.FunctionalTests\AuthSamples.FunctionalTests.csproj", "{B5C26BE6-655E-4D7F-B756-F286750EF172}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Debug|x64.ActiveCfg = Debug|Any CPU
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Debug|x86.ActiveCfg = Debug|Any CPU
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Release|Any CPU.Build.0 = Release|Any CPU
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Release|x64.ActiveCfg = Release|Any CPU
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50}.Release|x86.ActiveCfg = Release|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Debug|Any CPU.Build.0 = Debug|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Debug|x64.ActiveCfg = Debug|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Debug|x86.ActiveCfg = Debug|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Release|Any CPU.ActiveCfg = Release|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Release|Any CPU.Build.0 = Release|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Release|x64.ActiveCfg = Release|Any CPU
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482}.Release|x86.ActiveCfg = Release|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Debug|x64.ActiveCfg = Debug|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Debug|x64.Build.0 = Debug|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Debug|x86.ActiveCfg = Debug|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Debug|x86.Build.0 = Debug|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Release|Any CPU.Build.0 = Release|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Release|x64.ActiveCfg = Release|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Release|x64.Build.0 = Release|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Release|x86.ActiveCfg = Release|Any CPU
{B5C26BE6-655E-4D7F-B756-F286750EF172}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5FA7ABB3-5285-4101-B25E-0C8178ECDA50} = {CA4538F5-9DA8-4139-B891-A13279889F79}
{526BE3AE-3DD3-4AB6-BC81-AC34ED735482} = {CA4538F5-9DA8-4139-B891-A13279889F79}
{B5C26BE6-655E-4D7F-B756-F286750EF172} = {15E42EAC-5CBB-49EC-91FB-53743882CF2B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {39E3AF62-B1FD-4156-92AA-F4FA99B5AD89}
EndGlobalSection
EndGlobal
16 changes: 16 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project>

<Import Project="build\dependencies.props" />

<PropertyGroup>
<Product>Microsoft ASP.NET Core</Product>
<RepositoryUrl>https://github.com/aspnet/AuthSamples</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkPackageVersion)" PrivateAssets="All" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
<add key="AspNetCoreTools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
2 changes: 2 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE"
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/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 "$@"
22 changes: 22 additions & 0 deletions build/dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<AspNetIntegrationTestingVersion>0.5.0-preview1-27534</AspNetIntegrationTestingVersion>
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview1-15559</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreMvcTestingPackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCoreMvcTestingPackageVersion>
<MicrosoftAspNetCorePackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCorePackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview1-27534</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCoreStaticFilesPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>2.1.0-preview1-27534</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
<XunitPackageVersion>2.3.0</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.3.0</XunitRunnerVisualStudioPackageVersion>
</PropertyGroup>
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
</Project>
7 changes: 7 additions & 0 deletions build/repo.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<!-- These properties are use by the automation that updates dependencies.props -->
<LineupPackageId>Internal.AspNetCore.Universe.Lineup</LineupPackageId>
<LineupPackageRestoreSource>https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json</LineupPackageRestoreSource>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions korebuild-lock.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version:2.1.0-preview1-15559
commithash:2c59937fbbe6f2ae5ceb6c5ff5a3bd35577d96ca
2 changes: 2 additions & 0 deletions run.cmd
Original file line number Diff line number Diff line change
@@ -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"
191 changes: 191 additions & 0 deletions run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#!/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 ConfigFile
The path to the configuration file that stores values. Defaults to korebuild.json.
.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,
[string]$ConfigFile,
[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
}

$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 {
# 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) {
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'."
}

#
# 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
Invoke-KoreBuildCommand $Command @Arguments
}
finally {
Remove-Module 'KoreBuild' -ErrorAction Ignore
}
Loading

0 comments on commit 6e75c8e

Please sign in to comment.