Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public partial class AuthenticationResult
/// <param name="claimsPrincipal">Claims from the ID token</param>
/// <param name="spaAuthCode">Auth Code returned by the Microsoft identity platform when you use AcquireTokenByAuthorizationCode.WithSpaAuthorizationCode(). This auth code is meant to be redeemed by the frontend code. See https://aka.ms/msal-net/spa-auth-code</param>
/// <param name="additionalResponseParameters">Other properties from the token response.</param>
[Obsolete("Direct constructor use is deprecated.", error: false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public AuthenticationResult( // for backwards compat with 4.16-
string accessToken,
bool isExtendedLifeTimeToken,
Expand Down Expand Up @@ -98,8 +96,6 @@ public partial class AuthenticationResult
/// <param name="authenticationResultMetadata">Contains metadata related to the Authentication Result.</param>
/// <param name="tokenType">The token type, defaults to Bearer. Note: this property is experimental and may change in future versions of the library.</param>
/// <remarks>For backwards compatibility with MSAL 4.17-4.20 </remarks>
[Obsolete("Direct constructor use is deprecated.", error: false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public AuthenticationResult(
string accessToken,
bool isExtendedLifeTimeToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,32 @@ namespace Microsoft.Identity.Test.Unit.PublicApiTests
public class AuthenticationResultTests : TestBase
{

[TestMethod]
public void PublicTestConstructorCoversAllProperties()
{
// The first public ctor that is meant only for tests (“for-test”)
var ctorParameters = typeof(AuthenticationResult)
.GetConstructors()
.First(ctor => ctor.GetParameters().Length > 3)
.GetParameters();

var classProperties = typeof(AuthenticationResult)
.GetProperties()
.Where(p => p.GetCustomAttribute(typeof(ObsoleteAttribute)) == null)
.Where(p => p.SetMethod == null || p.SetMethod.IsPublic)
.Where(p => p.Name != nameof(AuthenticationResult.BindingCertificate));

// +2 for the 2 obsolete ExtendedExpires* props that are deliberately
// not represented in the ctor.
Assert.AreEqual(
ctorParameters.Length,
classProperties.Count() + 2,
"The <for-test> constructor should include all public-settable or read-only properties of AuthenticationResult (except BindingCertificate and the obsolete ExtendedExpires* pair).");
}

[TestMethod]
public void GetAuthorizationHeader()
{
#pragma warning disable CS0618 // exercising obsolete constructors until full deprecation
var ar = new AuthenticationResult(
"at",
false,
Expand Down Expand Up @@ -64,7 +86,6 @@ public void GetHybridSpaAuthCode()
"one for backwards compat with 4.17+ and one for 4.16 and below")]
public void AuthenticationResult_PublicApi()
{
#pragma warning disable CS0618 // exercising obsolete constructors until full deprecation
// old constructor, before 4.16
var ar1 = new AuthenticationResult(
"at",
Expand Down