Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Microsoft.Owin* 4.2 and create a new package version for BIM Track #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
6 changes: 3 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Param(

gci .\source -Recurse "packages.config" |% {
"Restoring " + $_.FullName
.\source\.nuget\nuget.exe install $_.FullName -o .\source\packages
nuget.exe install $_.FullName -o .\source\packages
}

Import-Module .\source\packages\psake.4.4.1\tools\psake.psm1
Import-Module .\source\packages\psake.4.9.0\tools\psake

if(Test-Path Env:\APPVEYOR_BUILD_NUMBER){
$buildNumber = [int]$Env:APPVEYOR_BUILD_NUMBER
Expand All @@ -19,6 +19,6 @@ if(Test-Path Env:\APPVEYOR_BUILD_NUMBER){

"Build number $buildNumber"

Invoke-Psake .\default.ps1 $task -framework "4.0x64" -properties @{ buildNumber=$buildNumber; preRelease=$preRelease }
Invoke-Psake .\default.ps1 "default" -framework "4.8x64" -properties @{ buildNumber=$buildNumber; preRelease=$preRelease }

Remove-Module psake
20 changes: 10 additions & 10 deletions default.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
properties {
$base_directory = Resolve-Path .
$src_directory = "$base_directory\source"
$output_directory = "$base_directory\build"
$output_directory = "$base_directory\build\net48"
$dist_directory = "$base_directory\distribution"
$sln_file = "$src_directory\IdentityServer3.AccessTokenValidation.sln"
$target_config = "Release"
Expand All @@ -10,7 +10,7 @@ properties {
$nuget_path = "$src_directory\.nuget\nuget.exe"

$buildNumber = 0;
$version = "2.15.0.0"
$version = "2.15.1.0"
$preRelease = $null
}

Expand All @@ -24,7 +24,7 @@ task Clean {
}

task Compile -depends UpdateVersion {
exec { msbuild /nologo /verbosity:q $sln_file /p:Configuration=$target_config /p:TargetFrameworkVersion=v4.5 }
exec { msbuild /nologo /verbosity:q $sln_file /p:Configuration=$target_config /p:TargetFrameworkVersion=v4.8 }
}

task RunTests -depends Compile {
Expand Down Expand Up @@ -52,19 +52,19 @@ task UpdateVersion {
}

task ILMerge -depends Compile {
$input_dlls = "$output_directory\IdentityServer.v3.AccessTokenValidation.dll"
$input_dlls = "$output_directory\BIMOne.IdentityServer.v3.AccessTokenValidation.dll"

Get-ChildItem -Path $output_directory -Filter *.dll |
foreach-object {
# Exclude IdentityServer3.AccessTokenValidation.dll as that will be the primary assembly
if ("$_" -ne "IdentityServer3.AccessTokenValidation.dll" -and
# Exclude BIMOne.IdentityServer3.AccessTokenValidation.dll as that will be the primary assembly
if ("$_" -ne "BIMOne.IdentityServer3.AccessTokenValidation.dll" -and
"$_" -ne "Owin.dll") {
$input_dlls = "$input_dlls $output_directory\$_"
}
}

New-Item $dist_directory\lib\net45 -Type Directory
Invoke-Expression "$ilmerge_path /targetplatform:v4 /internalize:ilmerge.exclude /allowDup /target:library /out:$dist_directory\lib\net45\IdentityServer.v3.AccessTokenValidation.dll $input_dlls"
New-Item $dist_directory\lib\net48 -Type Directory
Invoke-Expression "$ilmerge_path /targetplatform:v4 /internalize:ilmerge.exclude /allowDup /target:library /out:$dist_directory\lib\net48\IdentityServer.v3.AccessTokenValidation.dll $input_dlls"
}

task CreateNuGetPackage -depends Compile {
Expand All @@ -85,8 +85,8 @@ task CreateNuGetPackage -depends Compile {
$packageVersion = $packageVersion + "-build" + $buildNumber.ToString().PadLeft(5,'0')
}

New-Item $dist_directory\lib\net45 -Type Directory
copy-item $output_directory\IdentityServer3.AccessTokenValidation.* $dist_directory\lib\net45
New-Item $dist_directory\lib\net48 -Type Directory
copy-item $output_directory\BIMOne.IdentityServer3.AccessTokenValidation.* $dist_directory\lib\net48

copy-item $src_directory\IdentityServer3.AccessTokenValidation.nuspec $dist_directory
exec { . $nuget_path pack $dist_directory\IdentityServer3.AccessTokenValidation.nuspec -BasePath $dist_directory -o $dist_directory -version $packageVersion }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="psake" version="4.4.1" />
<package id="psake" version="4.9.0" />
<package id="xunit.runner.console" version="2.0.0" />
</packages>
161 changes: 13 additions & 148 deletions source/AccessTokenValidation.Tests/AccessTokenValidation.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,164 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0243A9FA-E484-43AD-A86C-F399ED79CCF3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AccessTokenValidation.Tests</RootNamespace>
<AssemblyName>AccessTokenValidation.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<TargetFramework>net48</TargetFramework>
<AssemblyTitle>AccessTokenValidation.Tests</AssemblyTitle>
<Company>Xero</Company>
<Product>AccessTokenValidation.Tests</Product>
<Copyright>Copyright © Xero 2014</Copyright>
<OutputPath>..\..\build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FluentAssertions, Version=4.3.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.3.0\lib\net45\FluentAssertions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FluentAssertions.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.3.0\lib\net45\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="IdentityModel, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IdentityModel.1.9.2\lib\net45\IdentityModel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin.Security, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin.Security.Jwt, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Security.Jwt.3.0.1\lib\net45\Microsoft.Owin.Security.Jwt.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin.Security.OAuth, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Security.OAuth.3.0.1\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="OwinHttpMessageHandler, Version=1.3.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OwinHttpMessageHandler.1.3.4\lib\net45\OwinHttpMessageHandler.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=4.0.20622.1351, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.4.0.2.206221351\lib\net45\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InMemoryClaimsCacheTests.cs" />
<Compile Include="Integration Tests\DynamicLocal.cs" />
<Compile Include="Integration Tests\Introspection.cs" />
<Compile Include="Integration Tests\DynamicBoth.cs" />
<Compile Include="Integration Tests\ResponseHeaders.cs" />
<Compile Include="Integration Tests\StaticBoth.cs" />
<Compile Include="Integration Tests\StaticLocal.cs" />
<Compile Include="Integration Tests\TokenProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Util\DiscoveryEndpointHandler.cs" />
<Compile Include="Util\FailureDiscoveryEndpointHandler.cs" />
<Compile Include="Util\IntrospectionEndpointHandler.cs" />
<Compile Include="Util\SuccessValidationEndointHandler.cs" />
<Compile Include="Util\FailureValidationEndointHandler.cs" />
<Compile Include="Util\PipelineFactory.cs" />
<Compile Include="Util\TokenFactory.cs" />
<Compile Include="Util\Cert.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<EmbeddedResource Include="Util\idsrv3test.pfx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AccessTokenValidation\AccessTokenValidation.csproj">
<Project>{df867b5d-3a9e-443a-b95e-d8f11e2a88a3}</Project>
<Name>AccessTokenValidation</Name>
</ProjectReference>
<ProjectReference Include="..\AccessTokenValidation\AccessTokenValidation.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.14.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="OwinHttpMessageHandler" Version="2.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.4.1" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void WhenTokenExpiryClaimExpiresBeforeClaimsCacheDuration_CacheExpiry_Sho
Arrange(() =>
{
// mimic the DateTimeOffset rounding that happens via serialisation/deserialisation in the actual implementation
ExpectedCacheExpiry = ExpiryClaimSaysTokenExpiresAt.ToEpochTime().ToDateTimeOffsetFromEpoch();
ExpectedCacheExpiry = ExpiryClaimSaysTokenExpiresAt.ToUnixTimeSeconds().ToDateTimeFromEpoch();
});

// act
Expand Down Expand Up @@ -84,7 +84,7 @@ void Arrange(Action specifyExpectedCacheExpiry) {
CacheExpiryEvictsTokenAt = _clock.UtcNow.Add(_options.ValidationResultCacheDuration);

// setup claims to include expiry claim
Claims = new[] {new Claim("bar","baz"), new Claim(ClaimTypes.Expiration,ExpiryClaimSaysTokenExpiresAt.ToEpochTime().ToString()) };
Claims = new[] {new Claim("bar","baz"), new Claim(ClaimTypes.Expiration,ExpiryClaimSaysTokenExpiresAt.ToUnixTimeSeconds().ToString()) };

specifyExpectedCacheExpiry();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using IdentityModel.Client;
using Xunit;

namespace AccessTokenValidation.Tests.Integration_Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using FluentAssertions;
using IdentityServer3.AccessTokenValidation;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using IdentityModel.Client;
using Xunit;

namespace AccessTokenValidation.Tests.Integration_Tests
Expand All @@ -29,11 +29,9 @@ public async Task WhenDelayLoadMetadataIsTrue_MetadataRetrievalIsRetriedAfterFai
client.SetBearerToken(token);

Func<Task> action = async () => await client.GetAsync("http://test");
action.
ShouldThrow<InvalidOperationException>().
And.
Message.Should().Contain("IDX10803"); // IDX10803: Unable to create to obtain configuration from: https://discodoc

Assert.ThrowsAsync<InvalidOperationException>(action)
.Result.Message.Should().Contain("IDX20803"); // IDX20803: Unable to create to obtain configuration from: https://discodoc
_options.BackchannelHttpHandler = new DiscoveryEndpointHandler();

var result = await client.GetAsync("http://test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using FluentAssertions;
using IdentityServer3.AccessTokenValidation;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using IdentityModel.Client;
using Xunit;

namespace AccessTokenValidation.Tests.Integration_Tests
Expand Down
Loading