From 7bb59a287c3c89efeece1248efd1e77c5e45cca0 Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 28 Aug 2015 14:23:17 -0700 Subject: [PATCH] React to string[] -> StringValues changes. --- .../DefaultAntiforgery.cs | 2 +- .../DefaultAntiforgeryTokenStoreTest.cs | 37 ++++++++----------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.AspNet.Antiforgery/DefaultAntiforgery.cs b/src/Microsoft.AspNet.Antiforgery/DefaultAntiforgery.cs index b4497eb..18a11c7 100644 --- a/src/Microsoft.AspNet.Antiforgery/DefaultAntiforgery.cs +++ b/src/Microsoft.AspNet.Antiforgery/DefaultAntiforgery.cs @@ -149,7 +149,7 @@ namespace Microsoft.AspNet.Antiforgery // Adding X-Frame-Options header to prevent ClickJacking. See // http://tools.ietf.org/html/draft-ietf-websec-x-frame-options-10 // for more information. - context.Response.Headers.Set("X-Frame-Options", "SAMEORIGIN"); + context.Response.Headers["X-Frame-Options"] = "SAMEORIGIN"; } } diff --git a/test/Microsoft.AspNet.Antiforgery.Test/DefaultAntiforgeryTokenStoreTest.cs b/test/Microsoft.AspNet.Antiforgery.Test/DefaultAntiforgeryTokenStoreTest.cs index 5c12c50..8e73c9d 100644 --- a/test/Microsoft.AspNet.Antiforgery.Test/DefaultAntiforgeryTokenStoreTest.cs +++ b/test/Microsoft.AspNet.Antiforgery.Test/DefaultAntiforgeryTokenStoreTest.cs @@ -4,11 +4,11 @@ #if DNX451 using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Primitives; using Moq; using Xunit; @@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Antiforgery // Arrange var requestCookies = new Mock(); requestCookies - .Setup(o => o.Get(It.IsAny())) + .Setup(o => o[It.IsAny()]) .Returns(string.Empty); var mockHttpContext = new Mock(); mockHttpContext @@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Antiforgery // Arrange var requestCookies = new Mock(); requestCookies - .Setup(o => o.Get(It.IsAny())) + .Setup(o => o[It.IsAny()]) .Returns(string.Empty); var mockHttpContext = new Mock(); mockHttpContext @@ -165,8 +165,8 @@ namespace Microsoft.AspNet.Antiforgery { // Arrange var httpContext = new DefaultHttpContext(); - httpContext.Request.Form = new FormCollection(new Dictionary()); - httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary()); + httpContext.Request.Form = new FormCollection(new Dictionary()); + httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary()); var options = new AntiforgeryOptions() { @@ -195,9 +195,9 @@ namespace Microsoft.AspNet.Antiforgery // Will not be accessed httpContext.Request.Form = null; - httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary() + httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary() { - { "cookie-name", new string[] { "cookie-value" } }, + { "cookie-name", "cookie-value" }, }); var options = new AntiforgeryOptions() @@ -224,10 +224,10 @@ namespace Microsoft.AspNet.Antiforgery // Arrange var httpContext = new DefaultHttpContext(); httpContext.Request.ContentType = "application/x-www-form-urlencoded"; - httpContext.Request.Form = new FormCollection(new Dictionary()); - httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary() + httpContext.Request.Form = new FormCollection(new Dictionary()); + httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary() { - { "cookie-name", new string[] { "cookie-value" } }, + { "cookie-name", "cookie-value" }, }); var options = new AntiforgeryOptions() @@ -254,13 +254,13 @@ namespace Microsoft.AspNet.Antiforgery // Arrange var httpContext = new DefaultHttpContext(); httpContext.Request.ContentType = "application/x-www-form-urlencoded"; - httpContext.Request.Form = new FormCollection(new Dictionary() + httpContext.Request.Form = new FormCollection(new Dictionary() { - { "form-field-name", new string[] { "form-value" } }, + { "form-field-name", "form-value" }, }); - httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary() + httpContext.Request.Cookies = new ReadableStringCollection(new Dictionary() { - { "cookie-name", new string[] { "cookie-value" } }, + { "cookie-name", "cookie-value" }, }); var options = new AntiforgeryOptions() @@ -419,22 +419,17 @@ namespace Microsoft.AspNet.Antiforgery return this[key]; } - public IList GetValues(string key) - { - throw new NotImplementedException(); - } - public bool ContainsKey(string key) { return _dictionary.ContainsKey(key); } - public string this[string key] + public StringValues this[string key] { get { return _dictionary[key]; } } - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() { throw new NotImplementedException(); }