Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 6650b45

Browse files
author
Nate McMaster
committed
Typo fix and react to change in antiforgery
1 parent 9d39c8a commit 6650b45

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

samples/MvcSandbox/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void ConfigureServices(IServiceCollection services)
2020

2121
services.Insert(0, ServiceDescriptor.Singleton(
2222
typeof(IConfigureOptions<AntiforgeryOptions>),
23-
new ConfigureOptions<AntiforgeryOptions>(options => options.CookieName = "<choose a name>")));
23+
new ConfigureOptions<AntiforgeryOptions>(options => options.Cookie.Name = "<choose a name>")));
2424
}
2525

2626
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

src/Microsoft.AspNetCore.Mvc.ViewFeatures/CookieTempDataProviderOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public CookieBuilder Cookie
3636
set => _cookieBuilder = value ?? throw new ArgumentNullException(nameof(value));
3737
}
3838

39+
#region Obsolete API
3940
/// <summary>
4041
/// <para>
4142
/// This property is obsolete and will be removed in a future version. The recommended alternative is <seealso cref="CookieBuilder.Path"/> on <see cref="Cookie"/>.
@@ -70,5 +71,6 @@ public CookieBuilder Cookie
7071
/// </summary>
7172
[Obsolete("This property is obsolete and will be removed in a future version. The recommended alternative is " + nameof(Cookie) + "." + nameof(CookieBuilder.Name) + ".")]
7273
public string CookieName { get; set; } = CookieTempDataProvider.CookieName;
74+
#endregion
7375
}
7476
}

test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/CookieTempDataProviderTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class CookieTempDataProviderTest
2121
public void SaveTempData_UsesCookieName_FromOptions()
2222
{
2323
// Arrange
24-
var exepectedCookieName = "TestCookieName";
24+
var expectedCookieName = "TestCookieName";
2525
var values = new Dictionary<string, object>();
2626
values.Add("int", 10);
2727

@@ -30,7 +30,7 @@ public void SaveTempData_UsesCookieName_FromOptions()
3030
var expectedDataInCookie = Base64UrlTextEncoder.Encode(expectedDataToProtect);
3131
var tempDataProvider = GetProvider(dataProtector: null, options: new CookieTempDataProviderOptions()
3232
{
33-
Cookie = { Name = exepectedCookieName }
33+
Cookie = { Name = expectedCookieName }
3434
});
3535

3636
var responseCookies = new MockResponseCookieCollection();
@@ -46,8 +46,8 @@ public void SaveTempData_UsesCookieName_FromOptions()
4646
tempDataProvider.SaveTempData(httpContext.Object, values);
4747

4848
// Assert
49-
Assert.Contains(responseCookies, (cookie) => cookie.Key == exepectedCookieName);
50-
var cookieInfo = responseCookies[exepectedCookieName];
49+
Assert.Contains(responseCookies, (cookie) => cookie.Key == expectedCookieName);
50+
var cookieInfo = responseCookies[expectedCookieName];
5151
Assert.Equal(expectedDataInCookie, cookieInfo.Value);
5252
Assert.Equal("/", cookieInfo.Options.Path);
5353
}

0 commit comments

Comments
 (0)