public async Task Anonymous_User_must_SignIn() { var generator = new AuthorizeInteractionResponseGenerator(null, null, new DefaultLocalizationService()); var request = new ValidatedAuthorizeRequest { ClientId = "foo" }; var result = await generator.ProcessLoginAsync(request, Principal.Anonymous); result.IsLogin.Should().BeTrue(); }
public async Task Authenticated_User_must_not_SignIn() { var users = new Mock<IUserService>(); users.Setup(x => x.IsActiveAsync(It.IsAny<ClaimsPrincipal>())).Returns(Task.FromResult<bool>(true)); var generator = new AuthorizeInteractionResponseGenerator(null, users.Object, new DefaultLocalizationService()); var request = new ValidatedAuthorizeRequest { ClientId = "foo", }; var principal = IdentityServerPrincipal.Create("123", "dom"); var result = await generator.ProcessLoginAsync(request, principal); result.IsLogin.Should().BeFalse(); }
public async Task Authenticated_User_with_different_requested_Idp_must_SignIn() { var users = new Mock<IUserService>(); users.Setup(x => x.IsActiveAsync(It.IsAny<ClaimsPrincipal>())).Returns(Task.FromResult<bool>(true)); var generator = new AuthorizeInteractionResponseGenerator(options, null, users.Object, new DefaultLocalizationService()); var request = new ValidatedAuthorizeRequest { ClientId = "foo", AuthenticationContextReferenceClasses = new List<string>{ "idp:some_idp" }, }; var principal = IdentityServerPrincipal.Create("123", "dom"); var result = await generator.ProcessLoginAsync(request, principal); result.IsLogin.Should().BeTrue(); }
public async Task Authenticated_User_with_allowed_requested_Idp_must_not_SignIn() { var users = new Mock<IUserService>(); users.Setup(x => x.IsActiveAsync(It.IsAny<ClaimsPrincipal>())).Returns(Task.FromResult<bool>(true)); var generator = new AuthorizeInteractionResponseGenerator(null, users.Object); var request = new ValidatedAuthorizeRequest { ClientId = "foo", LoginHint = "idp:" + Constants.BuiltInIdentityProvider }; var principal = IdentityServerPrincipal.Create("123", "dom"); var result = await generator.ProcessLoginAsync(request, principal); result.IsLogin.Should().BeFalse(); }