Skip to content

Commit 990a2ba

Browse files
authored
Fixing 3212 and cleaning-up technical debt (#3213)
* Fixing 3212 and cleaning-up technical debt * Addressing PR feedback * Update version to 3.6.2
1 parent 95b1f8d commit 990a2ba

File tree

4 files changed

+11
-84
lines changed

4 files changed

+11
-84
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<!--This should be passed from the VSTS build-->
44
<!-- This needs to be greater than or equal to the validation baseline version -->
5-
<MicrosoftIdentityWebVersion Condition="'$(MicrosoftIdentityWebVersion)' == ''">3.2.3</MicrosoftIdentityWebVersion>
5+
<MicrosoftIdentityWebVersion Condition="'$(MicrosoftIdentityWebVersion)' == ''">3.6.2</MicrosoftIdentityWebVersion>
66
<!--This will generate AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion-->
77
<Version>$(MicrosoftIdentityWebVersion)</Version>
88

@@ -96,7 +96,7 @@
9696
<MicrosoftGraphVersion>4.36.0</MicrosoftGraphVersion>
9797
<MicrosoftGraphBetaVersion>4.57.0-preview</MicrosoftGraphBetaVersion>
9898
<MicrosoftExtensionsHttpVersion>3.1.3</MicrosoftExtensionsHttpVersion>
99-
<MicrosoftIdentityAbstractionsVersion>7.2.1</MicrosoftIdentityAbstractionsVersion>
99+
<MicrosoftIdentityAbstractionsVersion>8.0.0</MicrosoftIdentityAbstractionsVersion>
100100
<!--CVE-2024-43485-->
101101
<SystemTextJsonVersion>8.0.5</SystemTextJsonVersion>
102102
<!--CVE-2023-29331-->

src/Microsoft.Identity.Web.Certificate/CertificateDescription.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ public CertificateDescription()
2424
/// </summary>
2525
/// <param name="credentialDescription"></param>
2626
public CertificateDescription(CredentialDescription credentialDescription)
27+
: base(credentialDescription)
2728
{
2829
_ = Throws.IfNull(credentialDescription);
2930

3031
// TODO: Check credentialDescription is really a cert
3132
SourceType = (CertificateSource)credentialDescription.SourceType;
32-
Container = credentialDescription.Container;
33-
Certificate = credentialDescription.Certificate;
34-
ReferenceOrValue = credentialDescription.ReferenceOrValue;
3533
}
3634

3735
/// <summary>
@@ -160,26 +158,6 @@ public static CertificateDescription FromStoreWithDistinguishedName(
160158

161159
// Should Container and ReferenceOrValue be moved to
162160
// the tests (As extension methods)
163-
164-
#region Backwards compatibilty with 1.x
165-
/// <summary>
166-
/// <inheritdoc/>.
167-
/// </summary>
168-
internal new string? Container
169-
{
170-
get { return base.Container; }
171-
set { base.Container = value; }
172-
}
173-
174-
/// <summary>
175-
/// <inheritdoc/>.
176-
/// </summary>
177-
internal new string? ReferenceOrValue
178-
{
179-
get { return base.ReferenceOrValue; }
180-
set { base.ReferenceOrValue = value; }
181-
}
182-
183161
/// <summary>
184162
/// <inheritdoc/>.
185163
/// </summary>
@@ -197,6 +175,5 @@ public static CertificateDescription FromStoreWithDistinguishedName(
197175
get { return (CertificateSource)base.SourceType; }
198176
set { base.SourceType = (CredentialSource)value; }
199177
}
200-
#endregion
201178
}
202179
}

tests/Microsoft.Identity.Web.Test/Certificates/CertificateDescriptionTests.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public void TestFromKeyVault(string keyVaultUrl, string certificateName)
1414
{
1515
CertificateDescription certificateDescription = CertificateDescription.FromKeyVault(keyVaultUrl, certificateName);
1616
Assert.Equal(CertificateSource.KeyVault, certificateDescription.SourceType);
17-
Assert.Equal(keyVaultUrl, certificateDescription.Container);
18-
Assert.Equal(certificateName, certificateDescription.ReferenceOrValue);
17+
Assert.Equal(keyVaultUrl, certificateDescription.KeyVaultUrl);
1918
Assert.Equal(certificateName, certificateDescription.KeyVaultCertificateName);
2019
Assert.Equal(keyVaultUrl, certificateDescription.KeyVaultUrl);
2120
#if NET462
@@ -33,8 +32,6 @@ public void TestFromPath(string certificatePath, string password)
3332
{
3433
CertificateDescription certificateDescription = CertificateDescription.FromPath(certificatePath, password);
3534
Assert.Equal(CertificateSource.Path, certificateDescription.SourceType);
36-
Assert.Equal(certificatePath, certificateDescription.Container);
37-
Assert.Equal(password, certificateDescription.ReferenceOrValue);
3835
Assert.Equal(certificatePath, certificateDescription.CertificateDiskPath);
3936
Assert.Equal(password, certificateDescription.CertificatePassword);
4037
}
@@ -45,7 +42,6 @@ public void TestFromBase64Encoded(string base64Encoded)
4542
{
4643
CertificateDescription certificateDescription = CertificateDescription.FromBase64Encoded(base64Encoded);
4744
Assert.Equal(CertificateSource.Base64Encoded, certificateDescription.SourceType);
48-
Assert.Equal(base64Encoded, certificateDescription.ReferenceOrValue);
4945
Assert.Equal(base64Encoded, certificateDescription.Base64EncodedValue);
5046
}
5147

@@ -56,8 +52,6 @@ public void TestFromCertificateDistinguishedName(string certificateDistinguished
5652
CertificateDescription certificateDescription =
5753
CertificateDescription.FromStoreWithDistinguishedName(certificateDistinguishedName, storeLocation, storeName);
5854
Assert.Equal(CertificateSource.StoreWithDistinguishedName, certificateDescription.SourceType);
59-
Assert.Equal($"{storeLocation}/{storeName}", certificateDescription.Container);
60-
Assert.Equal(certificateDistinguishedName, certificateDescription.ReferenceOrValue);
6155
Assert.Equal(certificateDistinguishedName, certificateDescription.CertificateDistinguishedName);
6256
Assert.Equal($"{storeLocation}/{storeName}", certificateDescription.CertificateStorePath);
6357
}
@@ -69,8 +63,6 @@ public void TestFromStoreWithThumbprint(string certificateThumbprint, StoreLocat
6963
CertificateDescription certificateDescription =
7064
CertificateDescription.FromStoreWithThumbprint(certificateThumbprint, storeLocation, storeName);
7165
Assert.Equal(CertificateSource.StoreWithThumbprint, certificateDescription.SourceType);
72-
Assert.Equal($"{storeLocation}/{storeName}", certificateDescription.Container);
73-
Assert.Equal(certificateThumbprint, certificateDescription.ReferenceOrValue);
7466
Assert.Equal($"{storeLocation}/{storeName}", certificateDescription.CertificateStorePath);
7567
Assert.Equal(certificateThumbprint, certificateDescription.CertificateThumbprint);
7668
}

tests/Microsoft.Identity.Web.Test/Certificates/DefaultCertificateLoaderTests.cs

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -55,47 +55,22 @@ public void TestDefaultCertificateLoader(CertificateSource certificateSource, st
5555
Assert.NotNull(certificateDescription.Certificate);
5656
}
5757

58-
#pragma warning disable xUnit1012 // Null should only be used for nullable parameters
59-
[InlineData(CertificateSource.Base64Encoded, null, TestConstants.CertificateX5c)]
60-
#pragma warning restore xUnit1012 // Null should only be used for nullable parameters
61-
[Theory]
62-
public void TestLoadFirstCertificate(
63-
CertificateSource certificateSource,
64-
string container,
65-
string referenceOrValue)
58+
[Fact]
59+
public void TestLoadFirstCertificate()
6660
{
67-
IEnumerable<CertificateDescription> certDescriptions = CreateCertificateDescriptions(
68-
certificateSource,
69-
container,
70-
referenceOrValue);
71-
61+
IEnumerable<CertificateDescription> certDescriptions = [CertificateDescription.FromBase64Encoded(TestConstants.CertificateX5c)];
7262
X509Certificate2? certificate = DefaultCertificateLoader.LoadFirstCertificate(certDescriptions);
7363

7464
Assert.NotNull(certificate);
7565
Assert.Equal("CN=ACS2ClientCertificate", certificate.Issuer);
7666
}
7767

78-
#pragma warning disable xUnit1012 // Null should only be used for nullable parameters
79-
[InlineData(CertificateSource.Base64Encoded, null, TestConstants.CertificateX5c)]
80-
#pragma warning restore xUnit1012 // Null should only be used for nullable parameters
81-
[Theory]
82-
public void TestLoadAllCertificates(
83-
CertificateSource certificateSource,
84-
string container,
85-
string referenceOrValue)
68+
[Fact]
69+
public void TestLoadAllCertificates()
8670
{
87-
List<CertificateDescription> certDescriptions = CreateCertificateDescriptions(
88-
certificateSource,
89-
container,
90-
referenceOrValue).ToList();
91-
92-
certDescriptions.Add(new CertificateDescription
93-
{
94-
SourceType = certificateSource,
95-
Container = container,
96-
ReferenceOrValue = referenceOrValue,
97-
});
71+
List<CertificateDescription> certDescriptions = [CertificateDescription.FromBase64Encoded(TestConstants.CertificateX5c)];
9872

73+
certDescriptions.Add(CertificateDescription.FromBase64Encoded(TestConstants.CertificateX5c));
9974
certDescriptions.Add(CertificateDescription.FromCertificate(null!));
10075

10176
IEnumerable<X509Certificate2?> certificates = DefaultCertificateLoader.LoadAllCertificates(certDescriptions);
@@ -135,22 +110,5 @@ public void TestLoadCertificateWithPrivateKey(
135110
Assert.NotNull(certificateDescription.Certificate);
136111
Assert.True(certificateDescription.Certificate.HasPrivateKey);
137112
}
138-
139-
private IEnumerable<CertificateDescription> CreateCertificateDescriptions(
140-
CertificateSource certificateSource,
141-
string container,
142-
string referenceOrValue)
143-
{
144-
List<CertificateDescription> certificateDescription = new List<CertificateDescription>();
145-
146-
certificateDescription.Add(new CertificateDescription
147-
{
148-
SourceType = certificateSource,
149-
Container = container,
150-
ReferenceOrValue = referenceOrValue,
151-
});
152-
153-
return certificateDescription;
154-
}
155113
}
156114
}

0 commit comments

Comments
 (0)