parent
eb3ff7fc32
commit
24d4694ec5
|
|
@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Identity.InMemory.Test
|
||||||
|
|
||||||
var context = new DefaultHttpContext();
|
var context = new DefaultHttpContext();
|
||||||
var auth = MockAuth(context);
|
var auth = MockAuth(context);
|
||||||
auth.Setup(a => a.AuthenticateAsync(context, It.IsAny<string>())).Returns(Task.FromResult(AuthenticateResult.None()));
|
auth.Setup(a => a.AuthenticateAsync(context, It.IsAny<string>())).Returns(Task.FromResult(AuthenticateResult.NoResult()));
|
||||||
var contextAccessor = new Mock<IHttpContextAccessor>();
|
var contextAccessor = new Mock<IHttpContextAccessor>();
|
||||||
contextAccessor.Setup(a => a.HttpContext).Returns(context);
|
contextAccessor.Setup(a => a.HttpContext).Returns(context);
|
||||||
var services = new ServiceCollection()
|
var services = new ServiceCollection()
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
httpContext.Setup(c => c.RequestServices).Returns(new ServiceCollection().BuildServiceProvider());
|
httpContext.Setup(c => c.RequestServices).Returns(new ServiceCollection().BuildServiceProvider());
|
||||||
var id = new ClaimsPrincipal(new ClaimsIdentity(IdentityConstants.ApplicationScheme));
|
var id = new ClaimsPrincipal(new ClaimsIdentity(IdentityConstants.ApplicationScheme));
|
||||||
var ticket = new AuthenticationTicket(id, new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow }, IdentityConstants.ApplicationScheme);
|
var ticket = new AuthenticationTicket(id, new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow }, IdentityConstants.ApplicationScheme);
|
||||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
|
||||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => SecurityStampValidator.ValidatePrincipalAsync(context));
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => SecurityStampValidator.ValidatePrincipalAsync(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
var ticket = new AuthenticationTicket(principal,
|
var ticket = new AuthenticationTicket(principal,
|
||||||
properties,
|
properties,
|
||||||
IdentityConstants.ApplicationScheme);
|
IdentityConstants.ApplicationScheme);
|
||||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
|
||||||
Assert.NotNull(context.Properties);
|
Assert.NotNull(context.Properties);
|
||||||
Assert.NotNull(context.Options);
|
Assert.NotNull(context.Options);
|
||||||
Assert.NotNull(context.Principal);
|
Assert.NotNull(context.Principal);
|
||||||
|
|
@ -136,7 +136,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
||||||
new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow.AddSeconds(-1) },
|
new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow.AddSeconds(-1) },
|
||||||
IdentityConstants.ApplicationScheme);
|
IdentityConstants.ApplicationScheme);
|
||||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
|
||||||
Assert.NotNull(context.Properties);
|
Assert.NotNull(context.Properties);
|
||||||
Assert.NotNull(context.Options);
|
Assert.NotNull(context.Options);
|
||||||
Assert.NotNull(context.Principal);
|
Assert.NotNull(context.Principal);
|
||||||
|
|
@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
||||||
new AuthenticationProperties(),
|
new AuthenticationProperties(),
|
||||||
IdentityConstants.ApplicationScheme);
|
IdentityConstants.ApplicationScheme);
|
||||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
|
||||||
Assert.NotNull(context.Properties);
|
Assert.NotNull(context.Properties);
|
||||||
Assert.NotNull(context.Options);
|
Assert.NotNull(context.Options);
|
||||||
Assert.NotNull(context.Principal);
|
Assert.NotNull(context.Principal);
|
||||||
|
|
@ -209,7 +209,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
|
||||||
new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow },
|
new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow },
|
||||||
IdentityConstants.ApplicationScheme);
|
IdentityConstants.ApplicationScheme);
|
||||||
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), ticket, new CookieAuthenticationOptions());
|
var context = new CookieValidatePrincipalContext(httpContext.Object, new AuthenticationSchemeBuilder(IdentityConstants.ApplicationScheme) { HandlerType = typeof(NoopHandler) }.Build(), new CookieAuthenticationOptions(), ticket);
|
||||||
Assert.NotNull(context.Properties);
|
Assert.NotNull(context.Properties);
|
||||||
Assert.NotNull(context.Options);
|
Assert.NotNull(context.Options);
|
||||||
Assert.NotNull(context.Principal);
|
Assert.NotNull(context.Principal);
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ namespace Microsoft.AspNetCore.Identity.Test
|
||||||
}
|
}
|
||||||
// REVIEW: auth changes we lost the ability to mock is persistent
|
// REVIEW: auth changes we lost the ability to mock is persistent
|
||||||
//var properties = new AuthenticationProperties { IsPersistent = isPersistent };
|
//var properties = new AuthenticationProperties { IsPersistent = isPersistent };
|
||||||
var authResult = AuthenticateResult.None();
|
var authResult = AuthenticateResult.NoResult();
|
||||||
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme))
|
auth.Setup(a => a.AuthenticateAsync(context, IdentityConstants.ApplicationScheme))
|
||||||
.Returns(Task.FromResult(authResult)).Verifiable();
|
.Returns(Task.FromResult(authResult)).Verifiable();
|
||||||
var manager = SetupUserManager(user);
|
var manager = SetupUserManager(user);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue