Fix tests, CodeAnalysis, StyleCop, warnings.
This commit is contained in:
Родитель
328ad847c1
Коммит
319b22c2b1
|
@ -203,6 +203,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Owin.Cors", "src\
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Owin.Cors.Tests", "tests\Microsoft.Owin.Cors.Tests\Microsoft.Owin.Cors.Tests.csproj", "{3DDAC01B-2567-4C0C-88E1-0A716729203E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Katana.Performance.ReferenceApp.Client", "tests\Katana.Performance.ReferenceApp.Client\Katana.Performance.ReferenceApp.Client.csproj", "{0D370C5B-7518-4D60-9D47-1AD59794F38F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -439,6 +441,10 @@ Global
|
|||
{3DDAC01B-2567-4C0C-88E1-0A716729203E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3DDAC01B-2567-4C0C-88E1-0A716729203E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3DDAC01B-2567-4C0C-88E1-0A716729203E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D370C5B-7518-4D60-9D47-1AD59794F38F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D370C5B-7518-4D60-9D47-1AD59794F38F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D370C5B-7518-4D60-9D47-1AD59794F38F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D370C5B-7518-4D60-9D47-1AD59794F38F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -488,6 +494,7 @@ Global
|
|||
{C232AB29-2F3C-4E18-9234-67B1C70CDAD5} = {923FBCC6-ACE8-462C-ACE1-927C3EC8E77B}
|
||||
{E38930BA-9F12-4609-B97C-55F08200A392} = {923FBCC6-ACE8-462C-ACE1-927C3EC8E77B}
|
||||
{8AE2E716-258A-4EF3-ADF1-D3B75D677F29} = {923FBCC6-ACE8-462C-ACE1-927C3EC8E77B}
|
||||
{0D370C5B-7518-4D60-9D47-1AD59794F38F} = {923FBCC6-ACE8-462C-ACE1-927C3EC8E77B}
|
||||
{558F65BE-E09D-4A9B-9DA8-C0983445726F} = {47488541-F6D1-4385-AE49-7E3C72042521}
|
||||
{73F1A72C-BCDE-4912-8AF7-6BE33D92FCC0} = {D79A7AE1-618E-4528-9A57-502877C0C2A6}
|
||||
{63988A9B-FA70-4BBA-8C7E-784145384F7C} = {D79A7AE1-618E-4528-9A57-502877C0C2A6}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<Word>Owin</Word>
|
||||
<Word>Ip</Word>
|
||||
<Word>Jwt</Word>
|
||||
<Word>Cors</Word>
|
||||
</Recognized>
|
||||
</Words>
|
||||
</Dictionary>
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace System.Web
|
|||
|
||||
/// <summary></summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="principal"></param>
|
||||
/// <param name="identity"></param>
|
||||
public static void SignIn(this HttpContextBase context, ClaimsIdentity identity)
|
||||
{
|
||||
if (context == null)
|
||||
|
@ -87,7 +87,7 @@ namespace System.Web
|
|||
|
||||
/// <summary></summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="principal"></param>
|
||||
/// <param name="identity"></param>
|
||||
/// <param name="extra"></param>
|
||||
public static void SignIn(this HttpContextBase context, ClaimsIdentity identity, AuthenticationExtra extra)
|
||||
{
|
||||
|
|
|
@ -17,16 +17,11 @@
|
|||
#if !NET40
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.Builder;
|
||||
using Microsoft.Owin.Mapping;
|
||||
|
||||
namespace Owin
|
||||
{
|
||||
using AppFunc = Func<IDictionary<string, object>, Task>;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for the MapMiddleware
|
||||
/// </summary>
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
#if !NET40
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Owin.Mapping
|
||||
{
|
||||
using AppFunc = Func<IDictionary<string, object>, Task>;
|
||||
|
||||
/// <summary>
|
||||
/// Used to create path based branches in your application pipeline.
|
||||
/// The owin.RequestPathBase is not included in the evaluation, only owin.RequestPath.
|
||||
|
@ -74,7 +70,7 @@ namespace Microsoft.Owin.Mapping
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="environment"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task Invoke(IOwinContext context)
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace Microsoft.Owin.Mapping
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="environment"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task Invoke(IOwinContext context)
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Katana.Sandbox.WebServer
|
|||
{
|
||||
public class Startup
|
||||
{
|
||||
readonly ConcurrentDictionary<string, string> _authenticationCodes = new ConcurrentDictionary<string, string>(StringComparer.Ordinal);
|
||||
private readonly ConcurrentDictionary<string, string> _authenticationCodes = new ConcurrentDictionary<string, string>(StringComparer.Ordinal);
|
||||
|
||||
public void Configuration(IAppBuilder app)
|
||||
{
|
||||
|
|
|
@ -29,13 +29,11 @@ namespace Microsoft.Owin.Host40.IntegrationTests
|
|||
namespace Microsoft.Owin.Host45.IntegrationTests
|
||||
#endif
|
||||
{
|
||||
using MsAppFunc = Func<IOwinContext, Task>;
|
||||
|
||||
public class ExceptionsTests : TestBase
|
||||
{
|
||||
public void UnhandledSyncException(IAppBuilder app)
|
||||
{
|
||||
app.Use(new MsAppFunc(context => { throw new Exception(); }));
|
||||
app.Use(context => { throw new Exception(); });
|
||||
}
|
||||
|
||||
public void UnhandledAsyncException(IAppBuilder app)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -28,13 +27,22 @@ namespace Microsoft.Owin.Host40.IntegrationTests
|
|||
namespace Microsoft.Owin.Host45.IntegrationTests
|
||||
#endif
|
||||
{
|
||||
using MsAppFunc = Func<IOwinContext, Task>;
|
||||
|
||||
public class ResponseBodyTests : TestBase
|
||||
{
|
||||
public void CloseResponseBodyAndWriteExtra(IAppBuilder app)
|
||||
{
|
||||
app.Use(new Func<MsAppFunc, MsAppFunc>(DelayedWrite));
|
||||
// Delayed write
|
||||
app.Use((context, next) =>
|
||||
{
|
||||
return next()
|
||||
.Then(() =>
|
||||
{
|
||||
var writer = new StreamWriter(context.Response.Body);
|
||||
writer.Write("AndExtra");
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
});
|
||||
});
|
||||
|
||||
app.Use(context =>
|
||||
{
|
||||
|
@ -46,21 +54,6 @@ namespace Microsoft.Owin.Host45.IntegrationTests
|
|||
});
|
||||
}
|
||||
|
||||
private MsAppFunc DelayedWrite(MsAppFunc next)
|
||||
{
|
||||
return context =>
|
||||
{
|
||||
return next(context)
|
||||
.Then(() =>
|
||||
{
|
||||
var writer = new StreamWriter(context.Response.Body);
|
||||
writer.Write("AndExtra");
|
||||
writer.Flush();
|
||||
writer.Close();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Microsoft.Owin.Host.SystemWeb")]
|
||||
[InlineData("Microsoft.Owin.Host.HttpListener")]
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace Microsoft.Owin.Host.SystemWeb.Tests45.CallHeaders
|
|||
[Fact]
|
||||
public void CreateEmptyRequestHeaders_Success()
|
||||
{
|
||||
|
||||
var headers = new AspNetRequestHeaders(new FakeHttpRequest());
|
||||
|
||||
Assert.Equal(0, headers.Count);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
@ -84,9 +86,11 @@ namespace Microsoft.Owin.Security.Tests
|
|||
{
|
||||
var server = new OAuth2TestServer
|
||||
{
|
||||
OnAuthorizeEndpoint = async ctx => ctx.Authentication.SignIn(
|
||||
new AuthenticationExtra(),
|
||||
CreateIdentity("epsilon"))
|
||||
OnAuthorizeEndpoint = ctx =>
|
||||
{
|
||||
ctx.Authentication.SignIn(new AuthenticationExtra(), CreateIdentity("epsilon"));
|
||||
return Task.FromResult<object>(null);
|
||||
}
|
||||
};
|
||||
|
||||
var transaction = await server.SendAsync("http://example.com/authorize?client_id=alpha&response_type=code");
|
||||
|
@ -99,12 +103,13 @@ namespace Microsoft.Owin.Security.Tests
|
|||
{
|
||||
var server = new OAuth2TestServer
|
||||
{
|
||||
OnAuthorizeEndpoint = async ctx =>
|
||||
OnAuthorizeEndpoint = ctx =>
|
||||
{
|
||||
ctx.Response.StatusCode = 404;
|
||||
ctx.Authentication.SignIn(
|
||||
new AuthenticationExtra(),
|
||||
CreateIdentity("epsilon"));
|
||||
return Task.FromResult<object>(null);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -132,9 +137,10 @@ namespace Microsoft.Owin.Security.Tests
|
|||
transaction2.ResponseToken["token_type"].Value<string>().ShouldBe("bearer");
|
||||
}
|
||||
|
||||
private async Task SignInEpsilon(IOwinContext ctx)
|
||||
private Task SignInEpsilon(IOwinContext ctx)
|
||||
{
|
||||
ctx.Authentication.SignIn(new AuthenticationExtra(), CreateIdentity("epsilon"));
|
||||
return Task.FromResult<object>(null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -316,7 +322,7 @@ namespace Microsoft.Owin.Security.Tests
|
|||
transaction5.Response.StatusCode.ShouldBe(HttpStatusCode.Unauthorized);
|
||||
}
|
||||
|
||||
//[Fact]
|
||||
// [Fact]
|
||||
public async Task CodeFlowClientIdMustMatch()
|
||||
{
|
||||
var server = new OAuth2TestServer(s =>
|
||||
|
@ -338,7 +344,6 @@ namespace Microsoft.Owin.Security.Tests
|
|||
transaction2.ResponseToken["error"].Value<string>().ShouldBe("invalid_grant");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task CodeFlowRedirectUriMustBeRepeatedIfOriginallyProvided()
|
||||
{
|
||||
|
@ -361,7 +366,7 @@ namespace Microsoft.Owin.Security.Tests
|
|||
transaction2.ResponseToken["error"].Value<string>().ShouldBe("invalid_grant");
|
||||
}
|
||||
|
||||
//[Fact]
|
||||
// [Fact]
|
||||
public async Task CodeFlowRedirectUriMustBeCorrectIfOriginallyProvided()
|
||||
{
|
||||
var server = new OAuth2TestServer(s =>
|
||||
|
@ -383,7 +388,7 @@ namespace Microsoft.Owin.Security.Tests
|
|||
transaction2.ResponseToken["error"].Value<string>().ShouldBe("invalid_grant");
|
||||
}
|
||||
|
||||
//[Fact]
|
||||
// [Fact]
|
||||
public async Task CodeFlowRedirectUriMustMatch()
|
||||
{
|
||||
var server = new OAuth2TestServer(s =>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
|
@ -19,12 +21,6 @@ namespace Microsoft.Owin.Security.Tests
|
|||
{
|
||||
public class OAuth2TestServer : TestServer
|
||||
{
|
||||
public OAuthAuthorizationServerOptions Options { get; set; }
|
||||
public OAuthAuthorizationServerProvider Provider { get { return Options.Provider as OAuthAuthorizationServerProvider; } }
|
||||
public TestClock Clock { get { return Options.SystemClock as TestClock; } }
|
||||
public Func<IOwinContext, Task> OnAuthorizeEndpoint { get; set; }
|
||||
public Func<IOwinContext, Task> OnTestpathEndpoint { get; set; }
|
||||
|
||||
public OAuth2TestServer(Action<OAuth2TestServer> configure = null)
|
||||
{
|
||||
Options = new OAuthAuthorizationServerOptions
|
||||
|
@ -33,7 +29,7 @@ namespace Microsoft.Owin.Security.Tests
|
|||
TokenEndpointPath = "/token",
|
||||
Provider = new OAuthAuthorizationServerProvider
|
||||
{
|
||||
OnLookupClient = async ctx =>
|
||||
OnLookupClient = ctx =>
|
||||
{
|
||||
if (ctx.ClientId == "alpha")
|
||||
{
|
||||
|
@ -61,6 +57,7 @@ namespace Microsoft.Owin.Security.Tests
|
|||
RedirectUri = "http://gamma3.com/return"
|
||||
});
|
||||
}
|
||||
return Task.FromResult<object>(null);
|
||||
}
|
||||
},
|
||||
AuthenticationCodeProvider = new InMemorySingleUseReferenceProvider(),
|
||||
|
@ -101,6 +98,21 @@ namespace Microsoft.Owin.Security.Tests
|
|||
});
|
||||
}
|
||||
|
||||
public OAuthAuthorizationServerOptions Options { get; set; }
|
||||
|
||||
public OAuthAuthorizationServerProvider Provider
|
||||
{
|
||||
get { return Options.Provider as OAuthAuthorizationServerProvider; }
|
||||
}
|
||||
|
||||
public TestClock Clock
|
||||
{
|
||||
get { return Options.SystemClock as TestClock; }
|
||||
}
|
||||
|
||||
public Func<IOwinContext, Task> OnAuthorizeEndpoint { get; set; }
|
||||
public Func<IOwinContext, Task> OnTestpathEndpoint { get; set; }
|
||||
|
||||
public async Task<Transaction> SendAsync(
|
||||
string uri,
|
||||
string cookieHeader = null,
|
||||
|
@ -154,7 +166,7 @@ namespace Microsoft.Owin.Security.Tests
|
|||
return transaction;
|
||||
}
|
||||
|
||||
private async Task MeEndpoint(IOwinContext ctx)
|
||||
private Task MeEndpoint(IOwinContext ctx)
|
||||
{
|
||||
if (ctx.Request.User == null ||
|
||||
!ctx.Request.User.Identity.IsAuthenticated ||
|
||||
|
@ -166,12 +178,13 @@ namespace Microsoft.Owin.Security.Tests
|
|||
{
|
||||
ctx.Response.Write(ctx.Request.User.Identity.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<object>(null);
|
||||
}
|
||||
|
||||
public class InMemorySingleUseReferenceProvider : AuthenticationTokenProvider
|
||||
{
|
||||
readonly ConcurrentDictionary<string, string> _database = new ConcurrentDictionary<string, string>(StringComparer.Ordinal);
|
||||
private readonly ConcurrentDictionary<string, string> _database = new ConcurrentDictionary<string, string>(StringComparer.Ordinal);
|
||||
|
||||
public override void Create(AuthenticationTokenCreateContext context)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Owin.Infrastructure;
|
||||
|
||||
namespace Microsoft.Owin.Security.Tests
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Owin.Builder;
|
||||
using Owin;
|
||||
|
@ -24,18 +23,16 @@ using Xunit.Extensions;
|
|||
|
||||
namespace Microsoft.Owin.Mapping.Tests
|
||||
{
|
||||
using AppFunc = Func<IOwinContext, Task>;
|
||||
using MsAppFunc = Func<IOwinContext, Task>;
|
||||
|
||||
public class MapPathMiddlewareTests
|
||||
{
|
||||
private static readonly Action<IAppBuilder> ActionNotImplemented = new Action<IAppBuilder>(_ => { throw new NotImplementedException(); });
|
||||
|
||||
private static async Task Success(IOwinContext context)
|
||||
private static Task Success(IOwinContext context)
|
||||
{
|
||||
context.Response.StatusCode = 200;
|
||||
context.Set("test.PathBase", context.Request.PathBase);
|
||||
context.Set("test.Path", context.Request.Path);
|
||||
return Task.FromResult<object>(null);
|
||||
}
|
||||
|
||||
private static void UseSuccess(IAppBuilder app)
|
||||
|
@ -43,7 +40,7 @@ namespace Microsoft.Owin.Mapping.Tests
|
|||
app.Use(Success);
|
||||
}
|
||||
|
||||
private static async Task NotImplemented(IOwinContext context)
|
||||
private static Task NotImplemented(IOwinContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -23,18 +23,18 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.Owin.Mapping.Tests
|
||||
{
|
||||
using AppFunc = Func<IDictionary<string, object>, Task>;
|
||||
using MsAppFunc = Func<IOwinContext, Task>;
|
||||
using Predicate = Func<IOwinContext, bool>;
|
||||
using PredicateAsync = Func<IOwinContext, Task<bool>>;
|
||||
|
||||
public class MapPredicateMiddlewareTests
|
||||
{
|
||||
private static readonly AppFunc AppFuncNotImplemented = new AppFunc(_ => { throw new NotImplementedException(); });
|
||||
private static readonly Predicate NotImplementedPredicate = new Predicate(envionment => { throw new NotImplementedException(); });
|
||||
private static readonly PredicateAsync NotImplementedPredicateAsync = new PredicateAsync(envionment => { throw new NotImplementedException(); });
|
||||
|
||||
private static async Task Success(IOwinContext context)
|
||||
private static Task Success(IOwinContext context)
|
||||
{
|
||||
context.Response.StatusCode = 200;
|
||||
return Task.FromResult<object>(null);
|
||||
}
|
||||
|
||||
private static void UseSuccess(IAppBuilder app)
|
||||
|
@ -42,7 +42,7 @@ namespace Microsoft.Owin.Mapping.Tests
|
|||
app.Use(Success);
|
||||
}
|
||||
|
||||
private static async Task NotImplemented(IOwinContext context)
|
||||
private static Task NotImplemented(IOwinContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -52,10 +52,6 @@ namespace Microsoft.Owin.Mapping.Tests
|
|||
app.Use(NotImplemented);
|
||||
}
|
||||
|
||||
|
||||
private static readonly Predicate NotImplementedPredicate = new Predicate(envionment => { throw new NotImplementedException(); });
|
||||
private static readonly PredicateAsync NotImplementedPredicateAsync = new PredicateAsync(envionment => { throw new NotImplementedException(); });
|
||||
|
||||
private bool TruePredicate(IOwinContext context)
|
||||
{
|
||||
return true;
|
||||
|
@ -66,14 +62,14 @@ namespace Microsoft.Owin.Mapping.Tests
|
|||
return false;
|
||||
}
|
||||
|
||||
private async Task<bool> TruePredicateAsync(IOwinContext context)
|
||||
private Task<bool> TruePredicateAsync(IOwinContext context)
|
||||
{
|
||||
return true;
|
||||
return Task.FromResult<bool>(true);
|
||||
}
|
||||
|
||||
private async Task<bool> FalsePredicateAsync(IOwinContext context)
|
||||
private Task<bool> FalsePredicateAsync(IOwinContext context)
|
||||
{
|
||||
return false;
|
||||
return Task.FromResult<bool>(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -143,7 +139,6 @@ namespace Microsoft.Owin.Mapping.Tests
|
|||
Assert.Equal(200, context.Response.StatusCode);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void PredicateAsyncFalseAction_PassThrough()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче