Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
@@ -1 +1,3 @@
#nullable enable
*REMOVED*static Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions.UpdateTokenValue(this Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties, string! tokenName, string! tokenValue) -> bool
static Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions.UpdateTokenValue(this Microsoft.AspNetCore.Authentication.AuthenticationProperties! properties, string! tokenName, string? tokenValue) -> bool
4 changes: 2 additions & 2 deletions src/Http/Authentication.Abstractions/src/TokenExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public static void StoreTokens(this AuthenticationProperties properties, IEnumer
/// </summary>
/// <param name="properties">The <see cref="AuthenticationProperties"/> to update.</param>
/// <param name="tokenName">The token name.</param>
/// <param name="tokenValue">The token value.</param>
/// <param name="tokenValue">The token value. May be <c>null</c>.</param>
/// <returns><see langword="true"/> if the token was updated, otherwise <see langword="false"/>.</returns>
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string tokenValue)
public static bool UpdateTokenValue(this AuthenticationProperties properties, string tokenName, string? tokenValue)
{
ArgumentNullException.ThrowIfNull(properties);
ArgumentNullException.ThrowIfNull(tokenName);
Expand Down
19 changes: 18 additions & 1 deletion src/Http/Authentication.Core/test/TokenExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Security.Claims;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.Security.Claims;
using static Microsoft.AspNetCore.Authentication.Core.Test.AuthenticationPropertiesTests;

namespace Microsoft.AspNetCore.Authentication.Core.Test;

Expand Down Expand Up @@ -149,6 +150,22 @@ public async Task GetTokenWorksWithExplicitScheme()
Assert.Equal("3", await context.GetTokenAsync("simple", "Three"));
}

[Fact]
public void UpdateTokenValueWorksWithNullGetTokenValueResult()
{
var sourceProperties = new AuthenticationProperties();
var targetProperties = new AuthenticationProperties();

var tokens = new List<AuthenticationToken>
{
new AuthenticationToken { Name = "refresh_token", Value = "refresh_value" }
};

targetProperties.StoreTokens(tokens);
targetProperties.UpdateTokenValue("refresh_token", sourceProperties.GetTokenValue("refresh_token"));
Assert.Null(targetProperties.GetTokenValue("refresh_token"));
}

private class SimpleAuth : IAuthenticationHandler
{
public Task<AuthenticateResult> AuthenticateAsync()
Expand Down
Loading