Skip to content

Commit

Permalink
Update Microsoft.IdentityModel from 7.3.1 to 7.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Juris Gekiss authored and Juris Gekiss committed Apr 26, 2024
1 parent 4e85421 commit b490999
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Reference Include="System.IdentityModel" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.5.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="7.5.1" />
<PackageReference Include="Apache.Ignite" Version="2.16.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

<ItemGroup>
<PackageReference Include="Abc.Diagnostics" Version="[1.2.6, 1.3.0)" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.5.1" />
<!--<PackageReference Include="System.ServiceModel.Http" Version="4.7.0" />-->
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Abc.IdentityModel.Xml/Abc.IdentityModel.Xml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.5.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net451' Or '$(TargetFramework)' == 'net461'">
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Copyright>© ABC software. All rights reserved.</Copyright>
<Product>Abc.IdentityModel</Product>
<AssemblyVersion>2.0</AssemblyVersion>
<Version>2.1.1-dev01</Version>
<Version>2.1.1</Version>

<LangVersion>8.0</LangVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.30.0">
<PackageReference Include="FluentAssertions.Analyzers" Version="0.31.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens.Saml" Version="7.5.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.30.0">
<PackageReference Include="FluentAssertions.Analyzers" Version="0.31.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.5.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void ReadToken(SamlTheoryData theoryData) {
}
catch (Exception ex) when (theoryData.ExpectedException != null) {
Assert.IsType(theoryData.ExpectedException.GetType(), ex);
Assert.StartsWith(theoryData.ExpectedException.Message, ex.Message);
}
}

Expand All @@ -105,14 +106,14 @@ public static TheoryData<SamlTheoryData> ReadTokenSourceData {
new SamlTheoryData {
Token = null,
XmlReader = XmlUtilities.CreateXmlReader(ReferenceTokens.SamlToken_Valid),
ExpectedException = new ArgumentNullException("token"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(ReadToken) + "_" + "Null token",
},

new SamlTheoryData {
Token = ReferenceTokens.SamlToken_Valid,
XmlReader = null,
ExpectedException = new ArgumentNullException("reader"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(ReadToken) + "_" + "Null XmlReader",
},

Expand All @@ -132,6 +133,7 @@ public void ValidateToken(SamlTheoryData theoryData) {
}
catch (Exception ex) when (theoryData.ExpectedException != null) {
Assert.IsType(theoryData.ExpectedException.GetType(), ex);
Assert.StartsWith(theoryData.ExpectedException.Message, ex.Message);
}
}

Expand All @@ -151,14 +153,14 @@ public static TheoryData<SamlTheoryData> ValidateTokenSourceData {
new SamlTheoryData {
Token = null,
ValidationParameters = validationParameters,
ExpectedException = new ArgumentNullException("token"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(ValidateToken) + "_" + "Null-Token",
},

new SamlTheoryData {
Token = ReferenceTokens.SamlToken_Valid,
ValidationParameters = null,
ExpectedException = new ArgumentNullException("validationParameters"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(ValidateToken) + "_" + "Null-TokenValidationParameters",
},

Expand Down Expand Up @@ -194,6 +196,7 @@ public void ValidateXmlToken(SamlTheoryData theoryData) {
}
catch (Exception ex) when (theoryData.ExpectedException != null) {
Assert.IsType(theoryData.ExpectedException.GetType(), ex);
Assert.StartsWith(theoryData.ExpectedException.Message, ex.Message);
}
}

Expand All @@ -213,21 +216,21 @@ public static TheoryData<SamlTheoryData> ValidateXmlTokenSourceData {
new SamlTheoryData {
XmlReader = null,
ValidationParameters = validationParameters,
ExpectedException = new ArgumentNullException("xmlReader"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(ValidateXmlToken) + "_" + "Null-XmlReader",
},

new SamlTheoryData {
XmlReader = XmlUtilities.CreateXmlReader(ReferenceTokens.Saml2Token_Valid),
ValidationParameters = validationParameters,
ExpectedException = new Microsoft.IdentityModel.Xml.XmlReadException(),
ExpectedException = new Microsoft.IdentityModel.Xml.XmlReadException("IDX30011:"),
TestId = nameof(ValidateXmlToken) + "_" + "InvalidSaml2Token",
},

new SamlTheoryData {
XmlReader = XmlUtilities.CreateXmlReader(ReferenceTokens.SamlToken_Valid),
ValidationParameters = null,
ExpectedException = new ArgumentNullException("validationParameters"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(ValidateXmlToken) + "_" + "Null-TokenValidationParameters",
},

Expand Down Expand Up @@ -266,6 +269,7 @@ public void WriteToken(SamlTheoryData theoryData) {
}
catch (Exception ex) when (theoryData.ExpectedException != null) {
Assert.IsType(theoryData.ExpectedException.GetType(), ex);
Assert.StartsWith(theoryData.ExpectedException.Message, ex.Message);
}
}

Expand Down Expand Up @@ -296,14 +300,14 @@ public static TheoryData<SamlTheoryData> WriteTokenSourceData {
new SamlTheoryData {
SecurityToken = null,
ValidationParameters = validationParameters,
ExpectedException = new ArgumentNullException("securityToken", "IDX10000:"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(WriteToken) + "_" + "Null securityToken",
},

new SamlTheoryData {
SecurityToken = ReferenceJwt.JwtToken,
ValidationParameters = validationParameters,
ExpectedException = new ArgumentException("IDX13400:"),
ExpectedException = new ArgumentException("IDX11400:"),
TestId = nameof(WriteToken) + "_" + nameof(ReferenceJwt.JwtToken),
},

Expand Down Expand Up @@ -341,6 +345,7 @@ public void WriteTokenXml(SamlTheoryData theoryData) {
}
catch (Exception ex) when (theoryData.ExpectedException != null) {
Assert.IsType(theoryData.ExpectedException.GetType(), ex);
Assert.StartsWith(theoryData.ExpectedException.Message, ex.Message);
}
}

Expand All @@ -363,21 +368,21 @@ public static TheoryData<SamlTheoryData> WriteTokenXmlSourceData {
new SamlTheoryData {
XmlWriter = XmlDictionaryWriter.CreateTextWriter(new MemoryStream()),
SecurityToken = null,
ExpectedException = new ArgumentNullException("securityToken", "IDX10000:"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(WriteTokenXml) + "_" + "Null securityToken",
},

new SamlTheoryData {
XmlWriter = null,
SecurityToken = ReferenceJwt.JwtToken,
ExpectedException = new ArgumentNullException("writer", "IDX10000:"),
ExpectedException = new ArgumentNullException("", "IDX10000:"),
TestId = nameof(WriteTokenXml) + "_" + "Null XmlWriter",
},

new SamlTheoryData {
XmlWriter = XmlDictionaryWriter.CreateTextWriter(new MemoryStream()),
SecurityToken = ReferenceJwt.JwtToken,
ExpectedException = new ArgumentException("IDX13150:"),
ExpectedException = new ArgumentException("IDX11400:"),
TestId = nameof(WriteTokenXml) + "_" + nameof(ReferenceJwt.JwtToken),
},

Expand All @@ -404,5 +409,66 @@ public static TheoryData<SamlTheoryData> WriteTokenXmlSourceData {
return theoryData;
}
}


[Theory, MemberData(nameof(CreateAttributeTheoryData))]
public void CreateAttribute(SamlTheoryData theoryData) {
try {
var attribute = (theoryData.Handler as SamlSecurityTokenHandlerPublic).CreateAttributePublic(theoryData.Claim);

Assert.Equal(attribute.Name, theoryData.SamlAttribute.Name);
Assert.Equal(attribute.Namespace, theoryData.SamlAttribute.Namespace);
Assert.Equal(attribute.Values, theoryData.SamlAttribute.Values);
Assert.Equal(attribute.AttributeValueXsiType, theoryData.SamlAttribute.AttributeValueXsiType);
Assert.Equal(attribute.ClaimType, theoryData.SamlAttribute.ClaimType);
Assert.Equal(attribute.OriginalIssuer, theoryData.SamlAttribute.OriginalIssuer);
}
catch (Exception ex) when (theoryData.ExpectedException != null) {
Assert.IsType(theoryData.ExpectedException.GetType(), ex);
Assert.StartsWith(theoryData.ExpectedException.Message, ex.Message);
}
}

public static TheoryData<SamlTheoryData> CreateAttributeTheoryData {
get {
return new TheoryData<SamlTheoryData>
{
new SamlTheoryData
{
ExpectedException = new ArgumentNullException("", "IDX10000:"),
Handler = new SamlSecurityTokenHandlerPublic(),
TestId = nameof(CreateAttribute) + "_" + "Null claim",
Claim = null,
},
new SamlTheoryData
{
ExpectedException = new SamlSecurityTokenException("IDX11523:"),
Handler = new SamlSecurityTokenHandlerPublic(),
TestId = nameof(CreateAttribute) + "_" + "claim type without namespace",
Claim = new Claim("sub", "value"),
},
new SamlTheoryData
{
Handler = new SamlSecurityTokenHandlerPublic(),
TestId = nameof(CreateAttribute),
Claim = new Claim(ClaimTypes.Name, "value", ClaimValueTypes.String),
SamlAttribute = new SamlAttribute("http://schemas.xmlsoap.org/ws/2005/05/identity/claims", "name", "value")
},
new SamlTheoryData
{
Handler = new SamlSecurityTokenHandlerPublic(),
TestId = nameof(CreateAttribute) + "_" + "with OriginalIssuer",
Claim = new Claim(ClaimTypes.Name, "value", ClaimValueTypes.String, null, "issuer"),
SamlAttribute = new SamlAttribute("http://schemas.xmlsoap.org/ws/2005/05/identity/claims", "name", "value") { OriginalIssuer = "issuer" },
},
};
}
}

private class SamlSecurityTokenHandlerPublic : SamlSecurityTokenHandler {
public SamlAttribute CreateAttributePublic(Claim claim) {
return base.CreateAttribute(claim);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;

Expand All @@ -19,5 +20,9 @@ public SamlTheoryData(TokenTheoryData tokenTheoryData)
public string InclusiveNamespacesPrefixList { get; set; }

public SamlSerializer SamlSerializer { get; set; } = new SamlSerializer();

public Claim Claim { get; set; }

public SamlAttribute SamlAttribute { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.3.1" />
<PackageReference Include="Microsoft.IdentityModel.Xml" Version="7.5.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit b490999

Please sign in to comment.