public void Arrange()
        {
            _configuration = new EmployerLevyConfiguration
            {
                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, null);
        }
Ejemplo n.º 2
0
        public void Arrange()
        {
            _configuration = new EmployerLevyConfiguration
            {
                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, null);
        }
Ejemplo n.º 3
0
        public void Arrange()
        {
            _configuration = new EmployerLevyConfiguration
            {
                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, null);
        }
        public void Arrange()
        {
            _configuration = new EmployerLevyConfiguration
            {
                Hmrc = new HmrcConfiguration
                {
                    BaseUrl         = ExpectedBaseUrl,
                    ClientId        = ExpectedClientId,
                    Scope           = ExpectedScope,
                    ClientSecret    = ExpectedClientSecret,
                    OgdSecret       = "ABC1234FG",
                    OgdClientId     = ExpectedOgdClientId,
                    AzureAppKey     = "123TRG",
                    AzureClientId   = "TYG567",
                    AzureResourceId = "Resource1",
                    AzureTenant     = "test",
                    UseHiDataFeed   = false
                }
            };

            _httpClientWrapper = new Mock <IHttpClientWrapper>();

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

            _azureAdAuthService = new Mock <IAzureAdAuthenticationService>();
            _azureAdAuthService.Setup(x =>
                                      x.GetAuthenticationResult(_configuration.Hmrc.AzureClientId, _configuration.Hmrc.AzureAppKey,
                                                                _configuration.Hmrc.AzureResourceId, _configuration.Hmrc.AzureTenant))
            .ReturnsAsync(ExpectedAuthToken);

            _hmrcService = new HmrcService(_configuration, _httpClientWrapper.Object, _tokenService.Object, new NoopExecutionPolicy(), null, _azureAdAuthService.Object);
        }
        public HmrcService(EmployerLevyConfiguration configuration, IHttpClientWrapper httpClientWrapper, ITokenServiceApiClient tokenServiceApiClient, [RequiredPolicy(HmrcExecutionPolicy.Name)] ExecutionPolicy executionPolicy, ICacheProvider cacheProvider, IAzureAdAuthenticationService azureAdAuthenticationService)
        {
            _configuration = configuration;
            _httpClientWrapper = httpClientWrapper;
            _tokenServiceApiClient = tokenServiceApiClient;
            _executionPolicy = executionPolicy;
            _cacheProvider = cacheProvider;
            _azureAdAuthenticationService = azureAdAuthenticationService;

            _httpClientWrapper.BaseUrl = _configuration.Hmrc.BaseUrl;
            _httpClientWrapper.AuthScheme = "Bearer";
            _httpClientWrapper.MediaTypeWithQualityHeaderValueList = new List<MediaTypeWithQualityHeaderValue> { new MediaTypeWithQualityHeaderValue("application/vnd.hmrc.1.0+json") };
        }
Ejemplo n.º 6
0
        public void Arrange()
        {
            _configuration = new EmployerLevyConfiguration
            {
                Hmrc = new HmrcConfiguration
                {
                    BaseUrl         = ExpectedBaseUrl,
                    ClientId        = ExpectedClientId,
                    Scope           = ExpectedScope,
                    ClientSecret    = ExpectedClientSecret,
                    OgdClientId     = ExpectedOgdClientId,
                    AzureAppKey     = "123TRG",
                    AzureClientId   = "TYG567",
                    AzureResourceId = "Resource1",
                    AzureTenant     = "test",
                    UseHiDataFeed   = false
                }
            };

            _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
            });

            _azureAdAuthService = new Mock <IAzureAdAuthenticationService>();
            _azureAdAuthService.Setup(x =>
                                      x.GetAuthenticationResult(_configuration.Hmrc.AzureClientId, _configuration.Hmrc.AzureAppKey,
                                                                _configuration.Hmrc.AzureResourceId, _configuration.Hmrc.AzureTenant))
            .ReturnsAsync(ExpectedAuthToken);

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

            _httpClientWrapper = new Mock <IHttpClientWrapper>();
            _httpClientWrapper.Setup(x => x.SendMessage(It.IsAny <object>(), It.IsAny <string>())).ReturnsAsync(JsonConvert.SerializeObject(new HmrcTokenResponse()));

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

            _hmrcService = new HmrcService(_configuration, _httpClientWrapper.Object, _tokenService.Object, new NoopExecutionPolicy(), null, null);
        }
Ejemplo n.º 8
0
 public UpdateTransactionLine(EmployerLevyConfiguration configuration, ILog logger) : base(configuration.DatabaseConnectionString, logger)
 {
 }
 public DasLevyRepository(EmployerLevyConfiguration configuration, ILog logger)
     : base(configuration.DatabaseConnectionString, logger)
 {
     _configuration = configuration;
 }
Ejemplo n.º 10
0
 public PayeSchemesRepository(EmployerLevyConfiguration configuration, ILog logger)
     : base(configuration.DatabaseConnectionString, logger)
 {
 }
 public CleanTransactionsDatabase(EmployerLevyConfiguration configuration, ILog logger) : base(configuration.DatabaseConnectionString, logger)
 {
 }
Ejemplo n.º 12
0
 public EnglishFractionRepository(EmployerLevyConfiguration configuration, ILog logger)
     : base(configuration.DatabaseConnectionString, logger)
 {
 }