Handle Form and helpers breaking changes.
This commit is contained in:
parent
87f895f2e6
commit
76017af97c
|
|
@ -33,7 +33,7 @@ namespace MusicStore.Controllers
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> AddressAndPayment(Order order)
|
public async Task<IActionResult> AddressAndPayment(Order order)
|
||||||
{
|
{
|
||||||
var formCollection = await Context.Request.GetFormAsync();
|
var formCollection = await Context.Request.ReadFormAsync();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace MusicStore.Controllers
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> RemoveFromCart(int id)
|
public async Task<IActionResult> RemoveFromCart(int id)
|
||||||
{
|
{
|
||||||
var formParameters = await Context.Request.GetFormAsync();
|
var formParameters = await Context.Request.ReadFormAsync();
|
||||||
var requestVerification = formParameters["RequestVerificationToken"];
|
var requestVerification = formParameters["RequestVerificationToken"];
|
||||||
string cookieToken = null;
|
string cookieToken = null;
|
||||||
string formToken = null;
|
string formToken = null;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Xunit;
|
using System.Net.Http;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace E2ETests
|
namespace E2ETests
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +29,7 @@ namespace E2ETests
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://www.facebook.com/v2.2/dialog/oauth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://www.facebook.com/v2.2/dialog/oauth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query));
|
||||||
Assert.Equal<string>("code", queryItems["response_type"]);
|
Assert.Equal<string>("code", queryItems["response_type"]);
|
||||||
Assert.Equal<string>("[AppId]", queryItems["client_id"]);
|
Assert.Equal<string>("[AppId]", queryItems["client_id"]);
|
||||||
Assert.Equal<string>(_applicationBaseUrl + "signin-facebook", queryItems["redirect_uri"]);
|
Assert.Equal<string>(_applicationBaseUrl + "signin-facebook", queryItems["redirect_uri"]);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Xunit;
|
using System.Net.Http;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace E2ETests
|
namespace E2ETests
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +29,7 @@ namespace E2ETests
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://accounts.google.com/o/oauth2/auth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://accounts.google.com/o/oauth2/auth", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query));
|
||||||
Assert.Equal<string>("code", queryItems["response_type"]);
|
Assert.Equal<string>("code", queryItems["response_type"]);
|
||||||
Assert.Equal<string>("offline", queryItems["access_type"]);
|
Assert.Equal<string>("offline", queryItems["access_type"]);
|
||||||
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Xunit;
|
using System.Net.Http;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace E2ETests
|
namespace E2ETests
|
||||||
{
|
{
|
||||||
|
|
@ -28,7 +29,7 @@ namespace E2ETests
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://login.live.com/oauth20_authorize.srf", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://login.live.com/oauth20_authorize.srf", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query));
|
||||||
Assert.Equal<string>("code", queryItems["response_type"]);
|
Assert.Equal<string>("code", queryItems["response_type"]);
|
||||||
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
Assert.Equal<string>("[ClientId]", queryItems["client_id"]);
|
||||||
Assert.Equal<string>(_applicationBaseUrl + "signin-microsoft", queryItems["redirect_uri"]);
|
Assert.Equal<string>(_applicationBaseUrl + "signin-microsoft", queryItems["redirect_uri"]);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Xunit;
|
using System.Net.Http;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
namespace E2ETests
|
namespace E2ETests
|
||||||
{
|
{
|
||||||
|
|
@ -31,7 +32,7 @@ namespace E2ETests
|
||||||
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
var content = new FormUrlEncodedContent(formParameters.ToArray());
|
||||||
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
response = _httpClient.PostAsync("Account/ExternalLogin", content).Result;
|
||||||
Assert.Equal<string>("https://twitter.com/oauth/authenticate", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
Assert.Equal<string>("https://twitter.com/oauth/authenticate", response.Headers.Location.AbsoluteUri.Replace(response.Headers.Location.Query, string.Empty));
|
||||||
var queryItems = QueryHelpers.ParseQuery(response.Headers.Location.Query);
|
var queryItems = new ReadableStringCollection(QueryHelpers.ParseQuery(response.Headers.Location.Query));
|
||||||
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
Assert.Equal<string>("custom", queryItems["custom_redirect_uri"]);
|
||||||
Assert.Equal<string>("valid_oauth_token", queryItems["oauth_token"]);
|
Assert.Equal<string>("valid_oauth_token", queryItems["oauth_token"]);
|
||||||
//Check for the correlation cookie
|
//Check for the correlation cookie
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
using MusicStore.Mocks.Common;
|
using MusicStore.Mocks.Common;
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ namespace MusicStore.Mocks.Facebook
|
||||||
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var response = new HttpResponseMessage();
|
var response = new HttpResponseMessage();
|
||||||
var queryParameters = QueryHelpers.ParseQuery(request.RequestUri.Query);
|
var queryParameters = new ReadableStringCollection(QueryHelpers.ParseQuery(request.RequestUri.Query));
|
||||||
|
|
||||||
if (request.RequestUri.AbsoluteUri.StartsWith("https://graph.facebook.com/v2.2/oauth/access_token"))
|
if (request.RequestUri.AbsoluteUri.StartsWith("https://graph.facebook.com/v2.2/oauth/access_token"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
|
||||||
namespace MusicStore.Mocks.Google
|
namespace MusicStore.Mocks.Google
|
||||||
|
|
@ -17,7 +18,7 @@ namespace MusicStore.Mocks.Google
|
||||||
|
|
||||||
if (request.RequestUri.AbsoluteUri.StartsWith("https://accounts.google.com/o/oauth2/token"))
|
if (request.RequestUri.AbsoluteUri.StartsWith("https://accounts.google.com/o/oauth2/token"))
|
||||||
{
|
{
|
||||||
var formData = FormHelpers.ParseForm(await request.Content.ReadAsStringAsync());
|
var formData = new FormCollection(await FormReader.ReadFormAsync(await request.Content.ReadAsStreamAsync()));
|
||||||
if (formData["grant_type"] == "authorization_code")
|
if (formData["grant_type"] == "authorization_code")
|
||||||
{
|
{
|
||||||
if (formData["code"] == "ValidCode")
|
if (formData["code"] == "ValidCode")
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
|
||||||
namespace MusicStore.Mocks.MicrosoftAccount
|
namespace MusicStore.Mocks.MicrosoftAccount
|
||||||
|
|
@ -17,7 +18,7 @@ namespace MusicStore.Mocks.MicrosoftAccount
|
||||||
|
|
||||||
if (request.RequestUri.AbsoluteUri.StartsWith("https://login.live.com/oauth20_token.srf"))
|
if (request.RequestUri.AbsoluteUri.StartsWith("https://login.live.com/oauth20_token.srf"))
|
||||||
{
|
{
|
||||||
var formData = FormHelpers.ParseForm(await request.Content.ReadAsStringAsync());
|
var formData = new FormCollection(await FormReader.ReadFormAsync(await request.Content.ReadAsStreamAsync()));
|
||||||
if (formData["grant_type"] == "authorization_code")
|
if (formData["grant_type"] == "authorization_code")
|
||||||
{
|
{
|
||||||
if (formData["code"] == "ValidCode")
|
if (formData["code"] == "ValidCode")
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNet.PipelineCore.Collections;
|
||||||
using Microsoft.AspNet.WebUtilities;
|
using Microsoft.AspNet.WebUtilities;
|
||||||
|
|
||||||
namespace MusicStore.Mocks.Twitter
|
namespace MusicStore.Mocks.Twitter
|
||||||
|
|
@ -20,7 +21,7 @@ namespace MusicStore.Mocks.Twitter
|
||||||
|
|
||||||
if (request.RequestUri.AbsoluteUri.StartsWith("https://api.twitter.com/oauth/access_token"))
|
if (request.RequestUri.AbsoluteUri.StartsWith("https://api.twitter.com/oauth/access_token"))
|
||||||
{
|
{
|
||||||
var formData = FormHelpers.ParseForm(await request.Content.ReadAsStringAsync());
|
var formData = new FormCollection(await FormReader.ReadFormAsync(await request.Content.ReadAsStreamAsync()));
|
||||||
if (formData["oauth_verifier"] == "valid_oauth_verifier")
|
if (formData["oauth_verifier"] == "valid_oauth_verifier")
|
||||||
{
|
{
|
||||||
if (_requestTokenEndpointInvoked)
|
if (_requestTokenEndpointInvoked)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue