Beispiel #1
0
 public ResendInvitationCommandHandler(IInvitationRepository invitationRepository, IMembershipRepository membershipRepository, IMediator mediator, EmployerApprenticeshipsServiceConfiguration employerApprenticeshipsServiceConfiguration, IUserRepository userRepository)
 {
     if (invitationRepository == null)
     {
         throw new ArgumentNullException(nameof(invitationRepository));
     }
     if (membershipRepository == null)
     {
         throw new ArgumentNullException(nameof(membershipRepository));
     }
     if (mediator == null)
     {
         throw new ArgumentNullException(nameof(mediator));
     }
     if (employerApprenticeshipsServiceConfiguration == null)
     {
         throw new ArgumentNullException(nameof(employerApprenticeshipsServiceConfiguration));
     }
     _invitationRepository = invitationRepository;
     _membershipRepository = membershipRepository;
     _mediator             = mediator;
     _employerApprenticeshipsServiceConfiguration = employerApprenticeshipsServiceConfiguration;
     _userRepository = userRepository;
     _validator      = new ResendInvitationCommandValidator();
 }
Beispiel #2
0
        public void Arrange()
        {
            _mediator = new Mock <IMediator>();
            _mediator.Setup(m => m.SendAsync(It.Is <GetEmployerAccountHashedQuery>(q => q.HashedAccountId == AccountId)))
            .ReturnsAsync(new GetEmployerAccountResponse
            {
                Account = new Domain.Data.Entities.Account.Account
                {
                    HashedId = AccountId,
                    Id       = 123,
                    Name     = "Account 1"
                }
            });
            _mediator.Setup(m => m.SendAsync(It.Is <GetUserAccountRoleQuery>(q => q.ExternalUserId == UserId)))
            .ReturnsAsync(new GetUserAccountRoleResponse
            {
                UserRole = Domain.Models.UserProfile.Role.Owner
            });
            _mediator.Setup(m => m.SendAsync(It.Is <GetAccountEmployerAgreementsRequest>(q => q.HashedAccountId == AccountId)))
            .ReturnsAsync(new GetAccountEmployerAgreementsResponse
            {
                EmployerAgreements = new List <Domain.Models.EmployerAgreement.EmployerAgreementView>
                {
                    new Domain.Models.EmployerAgreement.EmployerAgreementView {
                        Status = Domain.Models.EmployerAgreement.EmployerAgreementStatus.Pending
                    }
                }
            });

            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _configuration);
        }
Beispiel #3
0
        public void Arrange()
        {
            _configuration = new EmployerApprenticeshipsServiceConfiguration
            {
                Hmrc = new HmrcConfiguration
                {
                    BaseUrl      = ExpectedBaseUrl,
                    ClientId     = ExpectedClientId,
                    Scope        = ExpectedScope,
                    ClientSecret = ExpectedClientSecret
                }
            };

            _httpClientWrapper = new Mock <IHttpClientWrapper>();
            _httpClientWrapper.Setup(x => x.Get <EmpRefLevyInformation>(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(new EmpRefLevyInformation {
                Employer = new Employer {
                    Name = new Name {
                        EmprefAssociatedName = ExpectedName
                    }
                }, Links = new Links()
            });

            _tokenService = new Mock <ITokenServiceApiClient>();
            _tokenService.Setup(x => x.GetPrivilegedAccessTokenAsync()).ReturnsAsync(new PrivilegedAccessToken {
                AccessCode = ExpectedAuthToken
            });

            _hmrcService = new HmrcService(_configuration, _httpClientWrapper.Object, _tokenService.Object, new NoopExecutionPolicy(), null);
        }
        public void Arrange()
        {
            _configuration = new EmployerApprenticeshipsServiceConfiguration
            {
                Hmrc = new HmrcConfiguration
                {
                    BaseUrl      = ExpectedBaseUrl,
                    ClientId     = ExpectedClientId,
                    Scope        = ExpectedScope,
                    ClientSecret = ExpectedClientSecret,
                    OgdClientId  = ExpectedOgdClientId
                }
            };

            _httpClientWrapper = new Mock <IHttpClientWrapper>();
            _httpClientWrapper.Setup(x => x.SendMessage("", $"oauth/token?client_secret={ExpectedTotpToken}&client_id={ExpectedOgdClientId}&grant_type=client_credentials&scopes=read:apprenticeship-levy")).ReturnsAsync(JsonConvert.SerializeObject(new HmrcTokenResponse {
                AccessToken = ExpectedAuthToken
            }));

            _tokenService = new Mock <ITokenServiceApiClient>();
            _tokenService.Setup(x => x.GetPrivilegedAccessTokenAsync()).ReturnsAsync(new PrivilegedAccessToken {
                AccessCode = ExpectedAuthToken
            });

            _hmrcService = new HmrcService(_configuration, _httpClientWrapper.Object, _tokenService.Object, new NoopExecutionPolicy(), null);
        }
        public void Setup()
        {
            _invitationRepository = new Mock <IInvitationRepository>();
            _invitationRepository.Setup(x => x.Get(ExpectedAccountId, ExpectedCallerEmail)).ReturnsAsync(null);
            _invitationRepository.Setup(x => x.Create(It.IsAny <Invitation>())).ReturnsAsync(ExpectedInvitationId);

            _membershipRepository = new Mock <IMembershipRepository>();
            _membershipRepository.Setup(x => x.GetCaller(ExpectedHashedId, ExpectedExternalUserId)).ReturnsAsync(new MembershipView {
                AccountId = ExpectedAccountId, UserId = ExpectedUserId
            });

            _userRepository = new Mock <IUserRepository>();
            _userRepository.Setup(x => x.GetByEmailAddress(ExpectedExistingUserEmail)).ReturnsAsync(new User {
                Email = ExpectedExistingUserEmail, UserRef = Guid.NewGuid().ToString()
            });

            _mediator = new Mock <IMediator>();

            _validator = new Mock <IValidator <CreateInvitationCommand> >();
            _validator.Setup(x => x.ValidateAsync(It.IsAny <CreateInvitationCommand>())).ReturnsAsync(new ValidationResult());

            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _handler = new CreateInvitationCommandHandler(_invitationRepository.Object, _membershipRepository.Object, _mediator.Object, _configuration, _validator.Object, _userRepository.Object);
            _command = new CreateInvitationCommand
            {
                HashedAccountId = ExpectedHashedId,
                Email           = ExpectedCallerEmail,
                Name            = "Test User",
                RoleId          = Role.Owner,
                ExternalUserId  = ExpectedExternalUserId
            };
            DateTimeProvider.Current = new FakeTimeProvider(DateTime.UtcNow);
        }
        public void Setup()
        {
            _command = new ResendInvitationCommand
            {
                Email          = "*****@*****.**",
                AccountId      = ExpectedHashedId,
                ExternalUserId = Guid.NewGuid().ToString(),
            };

            var owner = new MembershipView
            {
                AccountId       = ExpectedAccountId,
                UserId          = 2,
                RoleId          = (int)Role.Owner,
                HashedAccountId = ExpectedHashedId
            };

            _userRepository = new Mock <IUserRepository>();
            _userRepository.Setup(x => x.GetByEmailAddress(ExpectedExistingUserEmail)).ReturnsAsync(new User {
                Email = ExpectedExistingUserEmail, UserRef = Guid.NewGuid().ToString()
            });

            _membershipRepository = new Mock <IMembershipRepository>();
            _membershipRepository.Setup(x => x.GetCaller(owner.HashedAccountId, _command.ExternalUserId)).ReturnsAsync(owner);
            _invitationRepository = new Mock <IInvitationRepository>();
            _mediator             = new Mock <IMediator>();

            _config = new EmployerApprenticeshipsServiceConfiguration();

            _handler = new ResendInvitationCommandHandler(_invitationRepository.Object, _membershipRepository.Object, _mediator.Object, _config, _userRepository.Object);
        }
Beispiel #7
0
 public HomeController(IOwinWrapper owinWrapper, HomeOrchestrator homeOrchestrator,
                       EmployerApprenticeshipsServiceConfiguration configuration, IFeatureToggle featureToggle, IMultiVariantTestingService multiVariantTestingService, ICookieStorageService <FlashMessageViewModel> flashMessage)
     : base(owinWrapper, featureToggle, multiVariantTestingService, flashMessage)
 {
     _homeOrchestrator = homeOrchestrator;
     _configuration    = configuration;
 }
Beispiel #8
0
        public void Arrange()
        {
            _mediator      = new Mock <IMediator>();
            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _configuration);
        }
        public void Arrange()
        {
            _configuration = new EmployerApprenticeshipsServiceConfiguration
            {
                Hmrc = new HmrcConfiguration
                {
                    BaseUrl      = ExpectedBaseUrl,
                    ClientId     = ExpectedClientId,
                    Scope        = ExpectedScope,
                    ClientSecret = ExpectedClientSecret,
                    ServerToken  = "token1234"
                }
            };

            _httpClientWrapper = new Mock <IHttpClientWrapper>();

            _tokenService = new Mock <ITokenServiceApiClient>();
            _tokenService.Setup(x => x.GetPrivilegedAccessTokenAsync()).ReturnsAsync(new PrivilegedAccessToken {
                AccessCode = ExpectedAccessCode
            });

            _cacheProvider = new Mock <ICacheProvider>();
            _cacheProvider.SetupSequence(c => c.Get <DateTime?>("HmrcFractionLastCalculatedDate"))
            .Returns(null)
            .Returns(new DateTime());

            _hmrcService = new HmrcService(_configuration, _httpClientWrapper.Object, _tokenService.Object, new NoopExecutionPolicy(), _cacheProvider.Object);
        }
 public EmployerAccountOrchestrator(IMediator mediator, ILogger logger, ICookieStorageService <EmployerAccountData> cookieService,
                                    EmployerApprenticeshipsServiceConfiguration configuration)
     : base(mediator, logger, cookieService, configuration)
 {
     _mediator = mediator;
     _logger   = logger;
 }
        public void Arrange()
        {
            _configuration = new EmployerApprenticeshipsServiceConfiguration
            {
                Hmrc = new HmrcConfiguration
                {
                    BaseUrl      = ExpectedBaseUrl,
                    ClientId     = ExpectedClientId,
                    Scope        = ExpectedScope,
                    ClientSecret = ExpectedClientSecret
                }
            };

            _httpClientWrapper = new Mock <IHttpClientWrapper>();
            _httpClientWrapper.Setup(x => x.Get <EmprefDiscovery>(It.IsAny <string>(), "apprenticeship-levy/")).ReturnsAsync(new EmprefDiscovery {
                Emprefs = new List <string> {
                    ExpectedEmpref
                }
            });

            _tokenService = new Mock <ITokenServiceApiClient>();
            _tokenService.Setup(x => x.GetPrivilegedAccessTokenAsync()).ReturnsAsync(new PrivilegedAccessToken {
                AccessCode = ExpectedAuthToken
            });

            _hmrcService = new HmrcService(_configuration, _httpClientWrapper.Object, _tokenService.Object, new NoopExecutionPolicy(), null);
        }
        public void Arrange()
        {
            _cookieService = new Mock <ICookieStorageService <EmployerAccountData> >();
            _logger        = new Mock <ILogger>();
            _mediator      = new Mock <IMediator>();
            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _account = new Account
            {
                Id       = 123,
                HashedId = "ABC123",
                Name     = "Test Account"
            };

            _mediator.Setup(x => x.SendAsync(It.IsAny <GetEmployerAccountHashedQuery>()))
            .ReturnsAsync(new GetEmployerAccountResponse {
                Account = _account
            });

            _mediator.Setup(x => x.SendAsync(It.IsAny <GetUserAccountRoleQuery>()))
            .ReturnsAsync(new GetUserAccountRoleResponse {
                UserRole = Role.Owner
            });

            _orchestrator = new EmployerAccountOrchestrator(_mediator.Object, _logger.Object, _cookieService.Object, _configuration);
        }
        public void Setup()
        {
            _validCommand = new SubmitCommitmentCommand {
                EmployerAccountId = 12L, CommitmentId = 2L, UserDisplayName = "Test User", UserEmailAddress = "*****@*****.**", UserId = "externalUserId"
            };
            _repositoryCommitment = new CommitmentView
            {
                ProviderId        = 456L,
                EmployerAccountId = 12L,
                AgreementStatus   = AgreementStatus.NotAgreed
            };

            _mockCommitmentApi = new Mock <IEmployerCommitmentApi>();
            _mockCommitmentApi.Setup(x => x.GetEmployerCommitment(It.IsAny <long>(), It.IsAny <long>()))
            .ReturnsAsync(_repositoryCommitment);

            _mockMediator = new Mock <IMediator>();
            var config = new EmployerApprenticeshipsServiceConfiguration
            {
                CommitmentNotification = new CommitmentNotificationConfiguration {
                    SendEmail = true
                }
            };

            _mockEmailLookup = new Mock <IProviderEmailLookupService>();
            _mockEmailLookup.Setup(m => m.GetEmailsAsync(It.IsAny <long>(), It.IsAny <string>())).ReturnsAsync(new List <string>());

            _handler = new SubmitCommitmentCommandHandler(_mockCommitmentApi.Object, _mockMediator.Object, config, _mockEmailLookup.Object, Mock.Of <ILogger>());
        }
 protected EmployerVerificationOrchestratorBase(IMediator mediator, ILogger logger, ICookieStorageService <EmployerAccountData> cookieService, EmployerApprenticeshipsServiceConfiguration configuration)
 {
     Mediator      = mediator;
     Logger        = logger;
     CookieService = cookieService;
     Configuration = configuration;
 }
        public EmployerAgreementOrchestrator(
            IMediator mediator,
            ILog logger,
            IMapper mapper,
            EmployerApprenticeshipsServiceConfiguration configuration,
            IReferenceDataService referenceDataService) : base(mediator)
        {
            if (mediator == null)
            {
                throw new ArgumentNullException(nameof(mediator));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (referenceDataService == null)
            {
                throw new ArgumentNullException(nameof(referenceDataService));
            }

            _mediator             = mediator;
            _logger               = logger;
            _mapper               = mapper;
            _configuration        = configuration;
            _referenceDataService = referenceDataService;
        }
Beispiel #16
0
        public HashingService(EmployerApprenticeshipsServiceConfiguration configuration)
        {
            var hashstring = string.IsNullOrEmpty(configuration.Hashstring)
                    ? Hashstring
                    : configuration.Hashstring;

            _hashIds = new Hashids(hashstring, 6, AllowedCharacters);
        }
 public AddressLookupService(
     IRestServiceFactory restServiceFactory,
     EmployerApprenticeshipsServiceConfiguration configuration)
 {
     _configuration         = configuration.PostcodeAnywhere;
     _findByPostCodeService = restServiceFactory.Create(_configuration.FindPartsBaseUrl);
     _findByIdService       = restServiceFactory.Create(_configuration.RetrieveServiceBaseUrl);
 }
Beispiel #18
0
        public void Arrange()
        {
            _mediator      = new Mock <IMediator>();
            _logger        = new Mock <ILogger>();
            _cookieService = new Mock <ICookieStorageService <EmployerAccountData> >();
            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _employerAccountOrchestrator = new EmployerAccountOrchestrator(_mediator.Object, _logger.Object, _cookieService.Object, _configuration);
        }
Beispiel #19
0
 public EmployerTeamOrchestrator(IMediator mediator, EmployerApprenticeshipsServiceConfiguration configuration)
     : base(mediator)
 {
     if (mediator == null)
     {
         throw new ArgumentNullException(nameof(mediator));
     }
     _mediator      = mediator;
     _configuration = configuration;
 }
 public CompaniesHouseEmployerVerificationService(EmployerApprenticeshipsServiceConfiguration configuration, ILogger logger, IHttpClientWrapper httpClientWrapper,
                                                  [RequiredPolicy(CompaniesHouseExecutionPolicy.Name)] ExecutionPolicy executionPolicy)
 {
     _configuration                = configuration;
     _logger                       = logger;
     _httpClientWrapper            = httpClientWrapper;
     _executionPolicy              = executionPolicy;
     _httpClientWrapper.AuthScheme = "Basic";
     _httpClientWrapper.BaseUrl    = _configuration.CompaniesHouse.BaseUrl;
 }
Beispiel #21
0
 public InvitationController(InvitationOrchestrator invitationOrchestrator, IOwinWrapper owinWrapper,
                             IFeatureToggle featureToggle, IMultiVariantTestingService multiVariantTestingService, EmployerApprenticeshipsServiceConfiguration configuration, ICookieStorageService <FlashMessageViewModel> flashMessage)
     : base(owinWrapper, featureToggle, multiVariantTestingService, flashMessage)
 {
     if (invitationOrchestrator == null)
     {
         throw new ArgumentNullException(nameof(invitationOrchestrator));
     }
     _invitationOrchestrator = invitationOrchestrator;
     _configuration          = configuration;
 }
Beispiel #22
0
 public IdamsEmailServiceWrapper(
     ILogger logger,
     EmployerApprenticeshipsServiceConfiguration configuration,
     IHttpClientWrapper httpClient,
     [RequiredPolicy(IdamsExecutionPolicy.Name)] ExecutionPolicy executionPolicy)
 {
     _logger            = logger;
     _configuration     = configuration.CommitmentNotification;
     _httpClientWrapper = httpClient;
     _executionPolicy   = executionPolicy;
 }
Beispiel #23
0
 public ProviderEmailLookupService(
     ILogger logger,
     IdamsEmailServiceWrapper idamsEmailServiceWrapper,
     EmployerApprenticeshipsServiceConfiguration employerConfiguration,
     IApprenticeshipInfoServiceWrapper apprenticeshipInfoService)
 {
     _logger = logger;
     _idamsEmailServiceWrapper  = idamsEmailServiceWrapper;
     _apprenticeshipInfoService = apprenticeshipInfoService;
     _configuration             = employerConfiguration.CommitmentNotification;
 }
Beispiel #24
0
        public void Arrange()
        {
            _mediator = new Mock <IMediator>();
            _mediator.Setup(x => x.SendAsync(It.IsAny <GetAccountTeamMembersQuery>())).ReturnsAsync(new GetAccountTeamMembersResponse {
                TeamMembers = new List <TeamMember> {
                    new TeamMember()
                }
            });
            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _orchestrator = new EmployerTeamOrchestrator(_mediator.Object, _configuration);
        }
Beispiel #25
0
        public HmrcService(EmployerApprenticeshipsServiceConfiguration configuration, IHttpClientWrapper httpClientWrapper, ITokenServiceApiClient tokenServiceApiClient, [RequiredPolicy(HmrcExecutionPolicy.Name)] ExecutionPolicy executionPolicy, ICacheProvider cacheProvider)
        {
            _configuration = configuration;
            _httpClientWrapper = httpClientWrapper;
            _tokenServiceApiClient = tokenServiceApiClient;
            _executionPolicy = executionPolicy;
            _cacheProvider = cacheProvider;

            _httpClientWrapper.BaseUrl = _configuration.Hmrc.BaseUrl;
            _httpClientWrapper.AuthScheme = "Bearer";
            _httpClientWrapper.MediaTypeWithQualityHeaderValueList = new List<MediaTypeWithQualityHeaderValue> { new MediaTypeWithQualityHeaderValue("application/vnd.hmrc.1.0+json") };
        }
        public void Arrange()
        {
            base.Arrange();

            _owinWrapper            = new Mock <IOwinWrapper>();
            _featureToggle          = new Mock <IFeatureToggle>();
            _userViewTestingService = new Mock <IMultiVariantTestingService>();
            _flashMessage           = new Mock <ICookieStorageService <FlashMessageViewModel> >();

            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _invitationOrchestrator = new Mock <InvitationOrchestrator>();
        }
        public void Arrange()
        {
            _mediator = new Mock <IMediator>();
            //RemoveLegalEntityCommand

            _logger = new Mock <ILog>();

            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _referenceDataService = new Mock <IReferenceDataService>();

            _orchestrator = new EmployerAgreementOrchestrator(_mediator.Object, _logger.Object, Mock.Of <IMapper>(), _configuration, _referenceDataService.Object);
        }
        public void Arrange()
        {
            _model = new ConfirmNewPayeSchemeViewModel
            {
                AccessToken     = Guid.NewGuid().ToString(),
                RefreshToken    = Guid.NewGuid().ToString(),
                HashedAccountId = ExpectedHashedId,
                PayeScheme      = ExpectedEmpref,
                PayeName        = ExpectedEmprefName
            };

            _configuration = new EmployerApprenticeshipsServiceConfiguration {
                Hmrc = new HmrcConfiguration()
            };

            _logger        = new Mock <ILogger>();
            _cookieService = new Mock <ICookieStorageService <EmployerAccountData> >();

            _mediator = new Mock <IMediator>();
            _mediator.Setup(x => x.SendAsync(It.IsAny <GetAccountLegalEntitiesRequest>())).ReturnsAsync(new GetAccountLegalEntitiesResponse {
                Entites = new LegalEntities {
                    LegalEntityList = new List <LegalEntity>()
                }
            });
            _mediator.Setup(x => x.SendAsync(It.Is <GetGatewayTokenQuery>(c => c.AccessCode.Equals("1")))).ReturnsAsync(new GetGatewayTokenQueryResponse {
                HmrcTokenResponse = new HmrcTokenResponse {
                    AccessToken = "1"
                }
            });
            _mediator.Setup(x => x.SendAsync(It.Is <GetHmrcEmployerInformationQuery>(c => c.AuthToken.Equals("1")))).ReturnsAsync(new GetHmrcEmployerInformationResponse {
                Empref = "123/ABC", EmployerLevyInformation = new EmpRefLevyInformation {
                    Employer = new Employer {
                        Name = new Name {
                            EmprefAssociatedName = ExpectedEmprefName
                        }
                    }
                }
            });
            _mediator.Setup(x => x.SendAsync(It.Is <GetHmrcEmployerInformationQuery>(c => c.AuthToken.Equals("2")))).ReturnsAsync(new GetHmrcEmployerInformationResponse {
                Empref = "456/ABC", EmployerLevyInformation = new EmpRefLevyInformation {
                    Employer = new Employer {
                        Name = new Name {
                            EmprefAssociatedName = ExpectedEmprefName
                        }
                    }
                }
            });

            _employerAccountPayeOrchestrator = new EmployerAccountPayeOrchestrator(_mediator.Object, _logger.Object, _cookieService.Object, _configuration);
        }
        public void Arrange()
        {
            _mediator      = new Mock <IMediator>();
            _logger        = new Mock <ILogger>();
            _cookieService = new Mock <ICookieStorageService <EmployerAccountData> >();
            _configuration = new EmployerApprenticeshipsServiceConfiguration();

            _employerAccountOrchestrator = new EmployerAccountOrchestrator(_mediator.Object, _logger.Object, _cookieService.Object, _configuration);
            _mediator.Setup(x => x.SendAsync(It.IsAny <CreateAccountCommand>()))
            .ReturnsAsync(new CreateAccountCommandResponse()
            {
                HashedAccountId = "ABS10"
            });
        }
        public void Arrange()
        {
            _apiConfiguration = new EmployerApprenticeshipApiConfiguration
            {
                BaseUrl = "api/test/"
            };

            var configuration = new EmployerApprenticeshipsServiceConfiguration
            {
                EmployerApprenticeshipApi = _apiConfiguration
            };

            _factory = new EmployerAgreementEventFactory(configuration);
        }