Updating tests to use moq.netcore
This commit is contained in:
parent
e2632d47f0
commit
130e8f0398
|
|
@ -8,9 +8,7 @@ using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.Extensions.OptionsModel;
|
using Microsoft.Extensions.OptionsModel;
|
||||||
using Microsoft.Extensions.WebEncoders.Testing;
|
using Microsoft.Extensions.WebEncoders.Testing;
|
||||||
#if DNX451
|
|
||||||
using Moq;
|
using Moq;
|
||||||
#endif
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Antiforgery
|
namespace Microsoft.AspNet.Antiforgery
|
||||||
|
|
@ -149,8 +147,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
exception.Message);
|
exception.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DNX451
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetHtml_ExistingInvalidCookieToken_GeneratesANewCookieAndAnAntiforgeryToken()
|
public void GetHtml_ExistingInvalidCookieToken_GeneratesANewCookieAndAnAntiforgeryToken()
|
||||||
{
|
{
|
||||||
|
|
@ -496,8 +492,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
Assert.Equal(expectedHeaderValue, xFrameOptions);
|
Assert.Equal(expectedHeaderValue, xFrameOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private DefaultAntiforgery GetAntiforgery(
|
private DefaultAntiforgery GetAntiforgery(
|
||||||
AntiforgeryOptions options = null,
|
AntiforgeryOptions options = null,
|
||||||
IAntiforgeryTokenGenerator tokenGenerator = null,
|
IAntiforgeryTokenGenerator tokenGenerator = null,
|
||||||
|
|
@ -525,8 +519,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
return httpContext;
|
return httpContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DNX451
|
|
||||||
|
|
||||||
private DefaultAntiforgery GetAntiforgery(AntiforgeryMockContext context)
|
private DefaultAntiforgery GetAntiforgery(AntiforgeryMockContext context)
|
||||||
{
|
{
|
||||||
return GetAntiforgery(
|
return GetAntiforgery(
|
||||||
|
|
@ -667,8 +659,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
public Mock<IAntiforgeryTokenSerializer> TokenSerializer { get; set; }
|
public Mock<IAntiforgeryTokenSerializer> TokenSerializer { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private class TestOptionsManager : IOptions<AntiforgeryOptions>
|
private class TestOptionsManager : IOptions<AntiforgeryOptions>
|
||||||
{
|
{
|
||||||
public AntiforgeryOptions Value { get; set; } = new AntiforgeryOptions();
|
public AntiforgeryOptions Value { get; set; } = new AntiforgeryOptions();
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ using System;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using Microsoft.AspNet.Http.Internal;
|
using Microsoft.AspNet.Http.Internal;
|
||||||
#if DNX451
|
|
||||||
using Moq;
|
using Moq;
|
||||||
#endif
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Antiforgery
|
namespace Microsoft.AspNet.Antiforgery
|
||||||
|
|
@ -54,8 +52,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
Assert.Empty(fieldToken.AdditionalData);
|
Assert.Empty(fieldToken.AdditionalData);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DNX451
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GenerateFormToken_AuthenticatedWithoutUsernameAndNoAdditionalData_NoAdditionalData()
|
public void GenerateFormToken_AuthenticatedWithoutUsernameAndNoAdditionalData_NoAdditionalData()
|
||||||
{
|
{
|
||||||
|
|
@ -191,7 +187,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
Assert.Null(fieldToken.ClaimUid);
|
Assert.Null(fieldToken.ClaimUid);
|
||||||
Assert.Empty(fieldToken.AdditionalData);
|
Assert.Empty(fieldToken.AdditionalData);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void IsCookieTokenValid_FieldToken_ReturnsFalse()
|
public void IsCookieTokenValid_FieldToken_ReturnsFalse()
|
||||||
|
|
@ -346,8 +341,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
exception.Message);
|
exception.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DNX451
|
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("the-user", "the-other-user")]
|
[InlineData("the-user", "the-other-user")]
|
||||||
[InlineData("http://example.com/uri-casing", "http://example.com/URI-casing")]
|
[InlineData("http://example.com/uri-casing", "http://example.com/URI-casing")]
|
||||||
|
|
@ -542,7 +535,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
// Assert
|
// Assert
|
||||||
// Nothing to assert - if we got this far, success!
|
// Nothing to assert - if we got this far, success!
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
private static ClaimsIdentity GetAuthenticatedIdentity(string identityUsername)
|
private static ClaimsIdentity GetAuthenticatedIdentity(string identityUsername)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
#if DNX451
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -185,5 +184,3 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
#if DNX451
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -446,5 +445,3 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -4,9 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
#if DNX451
|
|
||||||
using Moq;
|
using Moq;
|
||||||
#endif
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Antiforgery
|
namespace Microsoft.AspNet.Antiforgery
|
||||||
|
|
@ -26,7 +24,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
Assert.Null(claimUid);
|
Assert.Null(claimUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DNX451
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ExtractClaimUid_Unauthenticated()
|
public void ExtractClaimUid_Unauthenticated()
|
||||||
{
|
{
|
||||||
|
|
@ -61,7 +58,6 @@ namespace Microsoft.AspNet.Antiforgery
|
||||||
Assert.NotNull(claimUid);
|
Assert.NotNull(claimUid);
|
||||||
Assert.Equal("47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", claimUid);
|
Assert.Equal("47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", claimUid);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void DefaultUniqueClaimTypes_NotPresent_SerializesAllClaimTypes()
|
public void DefaultUniqueClaimTypes_NotPresent_SerializesAllClaimTypes()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.Extensions.OptionsModel;
|
using Microsoft.Extensions.OptionsModel;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Antiforgery
|
namespace Microsoft.AspNet.Antiforgery
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,28 @@
|
||||||
{
|
{
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"warningsAsErrors": true,
|
"warningsAsErrors": true,
|
||||||
"keyFile": "../../tools/Key.snk"
|
"keyFile": "../../tools/Key.snk"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.AspNet.Antiforgery": "1.0.0-*",
|
||||||
|
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||||
|
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
||||||
|
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||||
|
},
|
||||||
|
"commands": {
|
||||||
|
"run": "xunit.runner.aspnet",
|
||||||
|
"test": "xunit.runner.aspnet"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"dnx451": {
|
||||||
|
"dependencies": {
|
||||||
|
"Moq": "4.2.1312.1622"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dnxcore50": {
|
||||||
"Microsoft.AspNet.Antiforgery": "1.0.0-*",
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
"moq.netcore": "4.4.0-beta8"
|
||||||
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
}
|
||||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
|
||||||
},
|
|
||||||
"commands": {
|
|
||||||
"run": "xunit.runner.aspnet",
|
|
||||||
"test": "xunit.runner.aspnet"
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"dnx451": {
|
|
||||||
"dependencies": {
|
|
||||||
"Moq": "4.2.1312.1622"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dnxcore50": { }
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue