Skip to content

Commit a94e3e8

Browse files
authored
Make TokenExtensions.UpdateTokenValue() tokenValue parameter nullable (#62482)
1 parent 8c4a36c commit a94e3e8

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
#nullable enable
2+
*REMOVED*static Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions.UpdateTokenValue(this Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties, string! tokenName, string! tokenValue) -> bool
3+
static Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions.UpdateTokenValue(this Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties, string! tokenName, string? tokenValue) -> bool

src/Http/Authentication.Abstractions/src/TokenExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ public static void StoreTokens(this AuthenticationProperties properties, IEnumer
7171
/// </summary>
7272
/// <param name="properties">The <see cref="AuthenticationProperties"/> to update.</param>
7373
/// <param name="tokenName">The token name.</param>
74-
/// <param name="tokenValue">The token value.</param>
74+
/// <param name="tokenValue">The token value. May be <c>null</c>.</param>
7575
/// <returns><see langword="true"/> if the token was updated, otherwise <see langword="false"/>.</returns>
76-
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue)
76+
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string? tokenValue)
7777
{
7878
ArgumentNullException.ThrowIfNull(properties);
7979
ArgumentNullException.ThrowIfNull(tokenName);

src/Http/Authentication.Core/test/TokenExtensionTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ public async Task GetTokenWorksWithExplicitScheme()
149149
Assert.Equal("3", await context.GetTokenAsync("simple", "Three"));
150150
}
151151

152+
[Fact]
153+
public void UpdateTokenValueWorksWithNullGetTokenValueResult()
154+
{
155+
var sourceProperties = new AuthenticationProperties();
156+
var targetProperties = new AuthenticationProperties();
157+
158+
var tokens = new List<AuthenticationToken>
159+
{
160+
new AuthenticationToken { Name = "refresh_token", Value = "refresh_value" }
161+
};
162+
163+
targetProperties.StoreTokens(tokens);
164+
targetProperties.UpdateTokenValue("refresh_token", sourceProperties.GetTokenValue("refresh_token"));
165+
Assert.Null(targetProperties.GetTokenValue("refresh_token"));
166+
}
167+
152168
private class SimpleAuth : IAuthenticationHandler
153169
{
154170
public Task<AuthenticateResult> AuthenticateAsync()

0 commit comments

Comments
 (0)