Skip to content

Commit d783cbb

Browse files
committed
replicated tests to .net47 and .net46 projects
1 parent 4b96609 commit d783cbb

4 files changed

Lines changed: 89 additions & 30 deletions

File tree

UnitTestsNet46/SecurityVulnerabilitiesTest.cs

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System;
2-
using System.Security.Cryptography;
3-
using Jose;
1+
using Jose;
42
using Jose.keys;
3+
using Newtonsoft.Json;
4+
using System;
5+
using System.Security.Cryptography;
6+
using System.Text;
57
using Xunit;
68
using Xunit.Abstractions;
79

@@ -256,6 +258,47 @@ public void TruncatedGcmAuthTag()
256258
{
257259
Console.Out.WriteLine(e.ToString());
258260
}
259-
}
261+
}
262+
263+
[SkippableTheory]
264+
[InlineData("..")]
265+
[InlineData("eyJhbGciOjJ9.eyKhbGciOiJGciOjJ9.eyKhbGciOiJ")]
266+
[InlineData("eyJhbGciOjJ9..SH9typ9..")]
267+
[InlineData("eyJhbGciOiJkaXIiLCJlbmMiOjJ9..SH9typ9..")]
268+
public void MalformedTokenShouldThrowJoseException(string token)
269+
{
270+
try
271+
{
272+
// when decrypt a malformed token with non string alg, it should fail
273+
Jose.JWT.Decode(token, JwsAlgorithm.none);
274+
Assert.True(false, "Should fail with JoseException");
275+
}
276+
catch (JoseException e)
277+
{
278+
Console.Out.WriteLine(e.ToString());
279+
}
280+
}
281+
282+
[Fact]
283+
public void MalformedB64Header()
284+
{
285+
var ex = Assert.Throws<JoseException>(() => Jose.JWT.Decode(
286+
"eyJhbGciOiJIUzI1NiIsImI2NCI6ImZhbHNlIiwiY3JpdCI6WyJiNjQiLCJleHAiXSwiZXhwIjoxMzYzMjg0MDB9..9nZCB1H_OMmoTRBe2p5qeq38cyzcjJ6FzUZ9SkeZ4TU",
287+
Encoding.UTF8.GetBytes("a0a2abd8-6162-41c3-83d6-1cf559b46afc")
288+
));
289+
290+
Console.Out.WriteLine(ex.Message);
291+
}
292+
293+
[Fact]
294+
public void MalformedZipHeader()
295+
{
296+
byte[] aes512Key = new byte[] { 238, 71, 183, 66, 57, 207, 194, 93, 82, 80, 80, 152, 92, 242, 84, 206, 194, 46, 67, 43, 231, 118, 208, 168, 156, 212, 33, 105, 27, 45, 60, 160, 232, 63, 61, 235, 68, 171, 206, 35, 152, 11, 142, 121, 174, 165, 140, 11, 172, 212, 13, 101, 13, 190, 82, 244, 109, 113, 70, 150, 251, 82, 215, 226 };
297+
string token = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwiemlwIjp0cnVlfQ..nST6RFdA0NSofxIT9vKm7g.fD5P9Fh03XaW4dWpIUJqryH9fRHDdLLeMgWPTAFy4lg.Endy7B3S_qUuv6jE-Z6VX-bbbBl7ODFFMndIDMjslmg";
298+
299+
var ex = Assert.Throws<JoseException>(() => Jose.JWT.Decode(token, aes512Key));
300+
Console.Out.WriteLine(ex.Message);
301+
}
302+
260303
}
261304
}

UnitTestsNet46/UnitTestsNet46.csproj

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,24 @@
5353
<Reference Include="System.Data" />
5454
<Reference Include="System.Net.Http" />
5555
<Reference Include="System.Xml" />
56+
<Reference Include="Validation, Version=2.4.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
57+
<HintPath>..\packages\Validation.2.4.18\lib\net45\Validation.dll</HintPath>
58+
</Reference>
5659
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
57-
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
60+
<HintPath>..\packages\xunit.abstractions.2.0.2\lib\net35\xunit.abstractions.dll</HintPath>
5861
<Private>True</Private>
5962
</Reference>
60-
<Reference Include="xunit.assert, Version=2.2.0.3444, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
61-
<HintPath>..\packages\xunit.assert.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.assert.dll</HintPath>
62-
<Private>True</Private>
63+
<Reference Include="xunit.assert, Version=2.4.0.4049, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
64+
<HintPath>..\packages\xunit.assert.2.4.0\lib\netstandard2.0\xunit.assert.dll</HintPath>
6365
</Reference>
64-
<Reference Include="xunit.core, Version=2.2.0.3444, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
65-
<HintPath>..\packages\xunit.extensibility.core.2.2.0-beta4-build3444\lib\net45\xunit.core.dll</HintPath>
66-
<Private>True</Private>
66+
<Reference Include="xunit.core, Version=2.4.0.4049, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
67+
<HintPath>..\packages\xunit.extensibility.core.2.4.0\lib\net452\xunit.core.dll</HintPath>
6768
</Reference>
68-
<Reference Include="xunit.execution.desktop, Version=2.2.0.3444, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
69-
<HintPath>..\packages\xunit.extensibility.execution.2.2.0-beta4-build3444\lib\net45\xunit.execution.desktop.dll</HintPath>
70-
<Private>True</Private>
69+
<Reference Include="xunit.execution.desktop, Version=2.4.0.4049, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
70+
<HintPath>..\packages\xunit.extensibility.execution.2.4.0\lib\net452\xunit.execution.desktop.dll</HintPath>
71+
</Reference>
72+
<Reference Include="Xunit.SkippableFact, Version=1.4.0.0, Culture=neutral, PublicKeyToken=b2b52da82b58eb73, processorArchitecture=MSIL">
73+
<HintPath>..\packages\Xunit.SkippableFact.1.4.13\lib\net452\Xunit.SkippableFact.dll</HintPath>
7174
</Reference>
7275
</ItemGroup>
7376
<ItemGroup>

UnitTestsNet46/UnitTestsNet47.csproj

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\xunit.core.2.4.0\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.4.0\build\xunit.core.props')" />
34
<Import Project="..\packages\xunit.runner.visualstudio.2.4.2\build\net452\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.4.2\build\net452\xunit.runner.visualstudio.props')" />
45
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
56
<PropertyGroup>
@@ -51,21 +52,24 @@
5152
<Reference Include="System.Data" />
5253
<Reference Include="System.Net.Http" />
5354
<Reference Include="System.Xml" />
55+
<Reference Include="Validation, Version=2.4.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
56+
<HintPath>..\packages\Validation.2.4.18\lib\net45\Validation.dll</HintPath>
57+
</Reference>
5458
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
55-
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
59+
<HintPath>..\packages\xunit.abstractions.2.0.2\lib\net35\xunit.abstractions.dll</HintPath>
5660
<Private>True</Private>
5761
</Reference>
58-
<Reference Include="xunit.assert, Version=2.2.0.3444, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
59-
<HintPath>..\packages\xunit.assert.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.assert.dll</HintPath>
60-
<Private>True</Private>
62+
<Reference Include="xunit.assert, Version=2.4.0.4049, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
63+
<HintPath>..\packages\xunit.assert.2.4.0\lib\netstandard2.0\xunit.assert.dll</HintPath>
6164
</Reference>
62-
<Reference Include="xunit.core, Version=2.2.0.3444, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
63-
<HintPath>..\packages\xunit.extensibility.core.2.2.0-beta4-build3444\lib\net45\xunit.core.dll</HintPath>
64-
<Private>True</Private>
65+
<Reference Include="xunit.core, Version=2.4.0.4049, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
66+
<HintPath>..\packages\xunit.extensibility.core.2.4.0\lib\net452\xunit.core.dll</HintPath>
6567
</Reference>
66-
<Reference Include="xunit.execution.desktop, Version=2.2.0.3444, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
67-
<HintPath>..\packages\xunit.extensibility.execution.2.2.0-beta4-build3444\lib\net45\xunit.execution.desktop.dll</HintPath>
68-
<Private>True</Private>
68+
<Reference Include="xunit.execution.desktop, Version=2.4.0.4049, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
69+
<HintPath>..\packages\xunit.extensibility.execution.2.4.0\lib\net452\xunit.execution.desktop.dll</HintPath>
70+
</Reference>
71+
<Reference Include="Xunit.SkippableFact, Version=1.4.0.0, Culture=neutral, PublicKeyToken=b2b52da82b58eb73, processorArchitecture=MSIL">
72+
<HintPath>..\packages\Xunit.SkippableFact.1.4.13\lib\net452\Xunit.SkippableFact.dll</HintPath>
6973
</Reference>
7074
</ItemGroup>
7175
<ItemGroup>
@@ -117,12 +121,17 @@
117121
<Name>jose-jwt.net47</Name>
118122
</ProjectReference>
119123
</ItemGroup>
124+
<ItemGroup>
125+
<Analyzer Include="..\packages\xunit.analyzers.0.10.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
126+
</ItemGroup>
120127
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
121128
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
122129
<PropertyGroup>
123130
<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>
124131
</PropertyGroup>
125132
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.4.2\build\net452\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.4.2\build\net452\xunit.runner.visualstudio.props'))" />
133+
<Error Condition="!Exists('..\packages\xunit.core.2.4.0\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.0\build\xunit.core.props'))" />
134+
<Error Condition="!Exists('..\packages\xunit.core.2.4.0\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.0\build\xunit.core.targets'))" />
126135
</Target>
127136
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
128137
Other similar extension points exist, see Microsoft.Common.targets.
@@ -131,4 +140,5 @@
131140
<Target Name="AfterBuild">
132141
</Target>
133142
-->
143+
<Import Project="..\packages\xunit.core.2.4.0\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.4.0\build\xunit.core.targets')" />
134144
</Project>

UnitTestsNet46/packages.config

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
<package id="Microsoft.IdentityModel.Tokens" version="6.8.0" targetFramework="net461" />
55
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
66
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
7-
<package id="xunit" version="2.2.0-beta4-build3444" targetFramework="net461" />
8-
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" />
9-
<package id="xunit.assert" version="2.2.0-beta4-build3444" targetFramework="net461" />
10-
<package id="xunit.core" version="2.2.0-beta4-build3444" targetFramework="net461" />
11-
<package id="xunit.extensibility.core" version="2.2.0-beta4-build3444" targetFramework="net461" />
12-
<package id="xunit.extensibility.execution" version="2.2.0-beta4-build3444" targetFramework="net461" />
7+
<package id="Validation" version="2.4.18" targetFramework="net472" />
8+
<package id="xunit" version="2.4.0" targetFramework="net472" />
9+
<package id="xunit.abstractions" version="2.0.2" targetFramework="net472" />
10+
<package id="xunit.analyzers" version="0.10.0" targetFramework="net472" />
11+
<package id="xunit.assert" version="2.4.0" targetFramework="net472" />
12+
<package id="xunit.core" version="2.4.0" targetFramework="net472" />
13+
<package id="xunit.extensibility.core" version="2.4.0" targetFramework="net472" />
14+
<package id="xunit.extensibility.execution" version="2.4.0" targetFramework="net472" />
1315
<package id="xunit.runner.console" version="2.2.0-beta4-build3444" targetFramework="net461" developmentDependency="true" />
1416
<package id="xunit.runner.visualstudio" version="2.4.2" targetFramework="net461" developmentDependency="true" />
17+
<package id="Xunit.SkippableFact" version="1.4.13" targetFramework="net472" />
1518
</packages>

0 commit comments

Comments
 (0)