This commit is contained in:
Ajay Bhargav Baaskaran 2017-03-14 21:25:36 -07:00
parent 8c70684a9d
commit fc57e0aabd
3 changed files with 17 additions and 14 deletions

View File

@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -163,7 +164,7 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
{ {
var customUserInfoEndpoint = "https://graph.facebook.com/me?fields=email,timezone,picture"; var customUserInfoEndpoint = "https://graph.facebook.com/me?fields=email,timezone,picture";
var finalUserInfoEndpoint = string.Empty; var finalUserInfoEndpoint = string.Empty;
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("FacebookTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("FacebookTest"));
var server = CreateServer( var server = CreateServer(
app => app =>
{ {

View File

@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.Http.Features.Authentication; using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -293,7 +294,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[InlineData("CustomIssuer")] [InlineData("CustomIssuer")]
public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string claimsIssuer) public async Task ReplyPathWillAuthenticateValidAuthorizeCodeAndState(string claimsIssuer)
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -383,7 +384,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[InlineData(false)] [InlineData(false)]
public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect) public async Task ReplyPathWillThrowIfCodeIsInvalid(bool redirect)
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -436,7 +437,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[InlineData(false)] [InlineData(false)]
public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect) public async Task ReplyPathWillRejectIfAccessTokenIsMissing(bool redirect)
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -485,7 +486,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task AuthenticatedEventCanGetRefreshToken() public async Task AuthenticatedEventCanGetRefreshToken()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -565,7 +566,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task NullRedirectUriWillRedirectToSlash() public async Task NullRedirectUriWillRedirectToSlash()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -638,7 +639,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task ValidateAuthenticatedContext() public async Task ValidateAuthenticatedContext()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -736,7 +737,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task CanRedirectOnError() public async Task CanRedirectOnError()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -764,7 +765,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task AuthenticateAutomaticWhenAlreadySignedInSucceeds() public async Task AuthenticateAutomaticWhenAlreadySignedInSucceeds()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -807,7 +808,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds() public async Task AuthenticateGoogleWhenAlreadySignedInSucceeds()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -850,7 +851,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden() public async Task ChallengeGoogleWhenAlreadySignedInReturnsForbidden()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -886,7 +887,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull() public async Task AuthenticateFacebookWhenAlreadySignedWithGoogleReturnsNull()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",
@ -922,7 +923,7 @@ namespace Microsoft.AspNetCore.Authentication.Google
[Fact] [Fact]
public async Task ChallengeFacebookWhenAlreadySignedWithGoogleSucceeds() public async Task ChallengeFacebookWhenAlreadySignedWithGoogleSucceeds()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("GoogleTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("GoogleTest"));
var server = CreateServer(new GoogleOptions var server = CreateServer(new GoogleOptions
{ {
ClientId = "Test Id", ClientId = "Test Id",

View File

@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Authentication; using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Xunit; using Xunit;
@ -103,7 +104,7 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount
[Fact] [Fact]
public async Task AuthenticatedEventCanGetRefreshToken() public async Task AuthenticatedEventCanGetRefreshToken()
{ {
var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider().CreateProtector("MsftTest")); var stateFormat = new PropertiesDataFormat(new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("MsftTest"));
var server = CreateServer(new MicrosoftAccountOptions var server = CreateServer(new MicrosoftAccountOptions
{ {
ClientId = "Test Client Id", ClientId = "Test Client Id",