public void Arrange() { _user = new User { Id = UserId }; _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.Is <GetUserByIdQuery>(q => q.UserId == UserId))) .Returns(Task.FromResult(_user)); _mediator.Setup(m => m.SendAsync(It.IsAny <ChangeEmailCommand>())) .ThrowsAsync(new Exception("Called mediator with incorrect ChangeEmailCommand")); _mediator.Setup(m => m.SendAsync(It.Is <ChangeEmailCommand>(c => c.User == _user && c.SecurityCode == SecurityCode && c.Password == Password))) .Returns(Task.FromResult(new ChangeEmailCommandResult { ReturnUrl = ReturnUrl })); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _orchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); _model = new ConfirmChangeEmailViewModel { UserId = UserId, SecurityCode = SecurityCode, Password = Password }; }
public void Arrange() { _mediator = new Mock <IMediator>(); _mediator .Setup(x => x.Send(It.IsAny <GetProviderQueryRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new GetProviderQueryResponse { ProvidersView = new ProvidersView { CreatedDate = new DateTime(2000, 1, 1), Provider = new Provider() } }); _mediator.Setup(x => x.Send(It.Is <GetProviderHasRelationshipWithPermissionQueryRequest>(r => r.Permission == Operation.CreateCohort), It.IsAny <CancellationToken>())) .ReturnsAsync(() => new GetProviderHasRelationshipWithPermissionQueryResponse()); _currentDateTime = new Mock <ICurrentDateTime>(); _featureToggleService = new Mock <IFeatureToggleService>(); _orchestrator = new AccountOrchestrator( _mediator.Object, Mock.Of <ILog>(), _featureToggleService.Object ); }
public void Arrange() { _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.Is <GetRelyingPartyQuery>(q => q.Id == "MyClient"))) .ReturnsAsync(new Domain.RelyingParty { Id = "MyClient", ApplicationUrl = "http://unit.test" }); _mediator.Setup(m => m.SendAsync(It.Is <GetUserByIdQuery>(q => q.UserId == UserId))) .Returns(Task.FromResult(new Domain.User { Id = UserId })); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _orchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); _model = new ChangePasswordViewModel { UserId = UserId, CurrentPassword = CurrentPassword, NewPassword = NewPassword, ConfirmPassword = NewPassword, ClientId = "MyClient", ReturnUrl = "http://unit.test" }; }
public AccountController(AccountOrchestrator accountOrchestrator, IOwinWrapper owinWrapper, IdentityServerConfiguration identityServerConfiguration, ILogger logger) { _accountOrchestrator = accountOrchestrator; _owinWrapper = owinWrapper; _identityServerConfiguration = identityServerConfiguration; _logger = logger; }
public void Arrange() { _model = new ChangeEmailViewModel { UserId = UserId, NewEmailAddress = EmailAddress, ConfirmEmailAddress = EmailAddress, ClientId = "MyClient", ReturnUrl = ReturnUrl }; _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.Is <GetRelyingPartyQuery>(q => q.Id == "MyClient"))) .ReturnsAsync(new Domain.RelyingParty { Id = "MyClient", ApplicationUrl = "http://unit.test" }); _mediator.Setup(m => m.SendAsync(ItIsRequestChangeEmailCommandForModel())) .Returns(Task.FromResult(new RequestChangeEmailCommandResponse())); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _orchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); }
public void Arrange() { _mediator = new Mock <IMediator>(); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _accountOrchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); }
public void SetUp() { _fixture = new Fixture(); _mediator = new Mock <IMediator>(); _sut = new AccountOrchestrator(_mediator.Object, Mock.Of <IProviderCommitmentsLogger>()); _normalUser = _fixture.Build <User>().With(u => u.UserType, UserType.NormalUser).Create(); _superUser = _fixture.Build <User>().With(u => u.UserType, UserType.SuperUser).Create(); }
public void Arrange() { _mediator = new Mock <IMediator>(); _owinWrapper = new Mock <IOwinWrapper>(); _mediator.Setup(x => x.SendAsync(It.IsAny <GetUserByEmailAddressQuery>())).ReturnsAsync(new User()); _mediator.Setup(x => x.SendAsync(It.IsAny <GetUnlockCodeQuery>())).ReturnsAsync(new GetUnlockCodeResponse { UnlockCodeLength = 99 }); _logger = new Mock <ILogger>(); _accountOrchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); }
public void Arrange() { _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.Is <IsUserActiveQuery>(q => q.UserId == InactiveUserId))) .Returns(Task.FromResult(false)); _mediator.Setup(m => m.SendAsync(It.Is <IsUserActiveQuery>(q => q.UserId == ActiveUserId))) .Returns(Task.FromResult(true)); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _orchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); }
public void Setup() { _mediator = new Mock <IMediator>(); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _accountOrchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); _requestPasswordResetViewModel = new RequestPasswordResetViewModel { Email = "*****@*****.**" }; }
public void Arrange() { _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.Is <GetRelyingPartyQuery>(q => q.Id == ClientId))) .ReturnsAsync(new Domain.RelyingParty { Id = ClientId, ApplicationUrl = "http://unit.test" }); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _orchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); }
public void Arrange() { _mediator = new Mock <IMediator>(); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _accountOrchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); _registerUserViewModel = new RegisterViewModel { FirstName = "test", LastName = "tester", Email = "*****@*****.**", Password = "******", ConfirmPassword = "******", HasAcceptedTermsAndConditions = true }; }
public void Arrange() { _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.Is <GetUserByHashedIdQuery>(q => q.HashedUserId == HashedUserID))) .Returns(Task.FromResult(new Domain.User { Id = "1234RDF", Email = "*****@*****.**" })); _mediator.Setup(x => x.SendAsync(It.IsAny <GetUnlockCodeQuery>())).ReturnsAsync(new GetUnlockCodeResponse { UnlockCodeLength = 99 }); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _orchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); }
public void Arrange() { _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.IsAny <ActivateUserCommand>())) .ReturnsAsync(new ActivateUserCommandResult { ReturnUrl = ReturnUrl }); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _accountOrchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); _model = new ActivateUserViewModel { UserId = UserId, AccessCode = AccessCode }; }
public void Arrange() { _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(It.IsAny <AuthenticateUserCommand>())) .Returns(Task.FromResult(new Domain.User { Email = "*****@*****.**", IsActive = true })); _owinWrapper = new Mock <IOwinWrapper>(); _logger = new Mock <ILogger>(); _orchestrator = new AccountOrchestrator(_mediator.Object, _owinWrapper.Object, _logger.Object); _model = new LoginViewModel { EmailAddress = "*****@*****.**", Password = "******" }; }
public void SetUp() { _mediator = new Mock <IMediator>(); _sut = new AccountOrchestrator(_mediator.Object, Mock.Of <IProviderCommitmentsLogger>()); }
public AccountController(AccountOrchestrator accountOrchestrator, ICookieStorageService <FlashMessageViewModel> flashMessage) : base(flashMessage) { _accountOrchestrator = accountOrchestrator; }
public AccountController(AccountOrchestrator orchestrator, IProviderCommitmentsLogger logger) { _orchestrator = orchestrator; _logger = logger; }
public LoginController(AccountOrchestrator accountOrchestrator, IOwinWrapper owinWrapper, IdentityServerConfiguration identityServerConfiguration) { _accountOrchestrator = accountOrchestrator; _owinWrapper = owinWrapper; _identityServerConfiguration = identityServerConfiguration; }
private async Task SecurityTokenValidated(SecurityTokenValidatedNotification <WsFederationMessage, WsFederationAuthenticationOptions> notification, IProviderCommitmentsLogger logger, AuthenticationOrchestrator orchestrator, AccountOrchestrator accountOrchestrator) { logger.Info("SecurityTokenValidated notification called"); var identity = notification.AuthenticationTicket.Identity; var id = identity.Claims.FirstOrDefault(claim => claim.Type == (DasClaimTypes.Upn))?.Value; var displayName = identity.Claims.FirstOrDefault(claim => claim.Type == (DasClaimTypes.DisplayName))?.Value; var ukprn = identity.Claims.FirstOrDefault(claim => claim.Type == (DasClaimTypes.Ukprn))?.Value; var email = identity.Claims.FirstOrDefault(claim => claim.Type == (DasClaimTypes.Email))?.Value; long parsedUkprn; if (!long.TryParse(ukprn, out parsedUkprn)) { logger.Info($"Unable to parse Ukprn \"{ukprn}\" from claims for user \"{id}\""); return; } var showReservations = await accountOrchestrator.ProviderHasPermission(parsedUkprn, Operation.CreateCohort); identity.AddClaim(new Claim(DasClaimTypes.ShowReservations, showReservations.ToString(), "bool")); identity.MapClaimToRoles(); await orchestrator.SaveIdentityAttributes(id, parsedUkprn, displayName, email); }