public void Arrange() { _secretRepository = new Mock <ISecretRepository>(); _secretRepository.Setup(r => r.GetSecretAsync(PrivilegedAccessSecretName)) .ReturnsAsync(OgdSecret); _totpService = new Mock <ITotpService>(); _totpService.Setup(g => g.Generate(OgdSecret)) .Returns(TotpCode); _hmrcAuthBrokenConfig = new Mock <IHmrcAuthTokenBrokerConfig>(); _hmrcAuthBrokenConfig.Setup(config => config.RetryDelay).Returns(TimeSpan.FromSeconds(0)); _oauthTokenService = new Mock <IOAuthTokenService>(); _oauthTokenService.Setup(s => s.GetAccessToken(TotpCode)) .ReturnsAsync(new OAuthAccessToken { AccessToken = AccessToken, RefreshToken = RefreshToken, ExpiresAt = ExpiresAt, Scope = Scope, TokenType = TokenType }); _oauthTokenService.Setup(s => s.GetAccessTokenFromRefreshToken(TotpCode, CachedRefreshToken)) .ReturnsAsync(new OAuthAccessToken { AccessToken = RefreshedAccessToken, RefreshToken = RefreshedRefreshToken, ExpiresAt = RefreshedExpiresAt, Scope = RefreshedScope, TokenType = RefreshedTokenType }); _logger = new Mock <ILogger>(); _tokenRefresher = new Mock <ITokenRefresher>(); var hmrcAuthTokenContainer = new HmrcAuthTokenBroker( new NoopExecutionPolicy(), _logger.Object, _oauthTokenService.Object, _secretRepository.Object, _totpService.Object, _tokenRefresher.Object, _hmrcAuthBrokenConfig.Object ); _handler = new PrivilegedAccessQueryHandler(hmrcAuthTokenContainer); _query = new PrivilegedAccessQuery(); }
public void Arrange() { _secretRepository = new Mock <ISecretRepository>(); _secretRepository.Setup(r => r.GetSecretAsync(PrivilegedAccessSecretName)) .ReturnsAsync(OgdSecret); _totpService = new Mock <ITotpService>(); _totpService.Setup(g => g.Generate(OgdSecret)) .Returns(TotpCode); _oauthTokenService = new Mock <IOAuthTokenService>(); _oauthTokenService.Setup(s => s.GetAccessToken(TotpCode)) .ReturnsAsync(new OAuthAccessToken { AccessToken = AccessToken, RefreshToken = RefreshToken, ExpiresAt = ExpiresAt, Scope = Scope, TokenType = TokenType }); _oauthTokenService.Setup(s => s.GetAccessTokenFromRefreshToken(TotpCode, CachedRefreshToken)) .ReturnsAsync(new OAuthAccessToken { AccessToken = RefreshedAccessToken, RefreshToken = RefreshedRefreshToken, ExpiresAt = RefreshedExpiresAt, Scope = RefreshedScope, TokenType = RefreshedTokenType }); _cacheProvider = new Mock <ICacheProvider>(); _logger = new Mock <ILogger>(); _handler = new PrivilegedAccessQueryHandler(_secretRepository.Object, _totpService.Object, _oauthTokenService.Object, _cacheProvider.Object, _logger.Object); _query = new PrivilegedAccessQuery(); }