public async Task <AccountAccessContentResult> Handle(AddAccountAccessContentCommand request, CancellationToken cancellationToken)
        {
            var risk = request.Risk == null ? string.Empty : request.Risk.ToString();
            var accountAccessConsent = AccountAccessConsentAggregate.Create(request.Data.Permissions, request.Data.ExpirationDateTime, request.Data.TransactionFromDateTime, request.Data.TransactionToDateTime, risk);
            await _commandRepository.Commit(accountAccessConsent, cancellationToken);

            var url = $"{request.Issuer}/{Constants.RouteNames.AccountAccessContents}/{accountAccessConsent.AggregateId}";

            return(AccountAccessContentResult.ToDto(accountAccessConsent, url, 1));
        }
Exemple #2
0
        public async Task GivenAddRejectedAccountAccessConsent()
        {
            var accountAccessConsentRepository = _factory.Server.Host.Services.GetService(typeof(IAccountAccessConsentRepository)) as IAccountAccessConsentRepository;
            var accountAccessConsent           = AccountAccessConsentAggregate.Create(new List <string>
            {
                AccountAccessConsentPermission.ReadAccountsBasic.Name
            }, null, null, null, null);

            accountAccessConsent.Reject();
            await accountAccessConsentRepository.Add(accountAccessConsent, CancellationToken.None);

            _scenarioContext.Set(accountAccessConsent.AggregateId, "consentId");
        }
        public async Task GivenAddAuthorizedAccountAccessConsent(string clientId)
        {
            clientId = ParseValue(clientId).ToString();
            var accountAccessConsentRepository = _factory.Server.Host.Services.GetService(typeof(IAccountAccessConsentRepository)) as IAccountAccessConsentRepository;
            var accountAccessConsent           = AccountAccessConsentAggregate.Create(clientId, new List <string>
            {
                AccountAccessConsentPermission.ReadAccountsBasic.Name
            }, null, null, null, null);

            accountAccessConsent.Confirm(new List <string> {
            });
            await accountAccessConsentRepository.Add(accountAccessConsent, CancellationToken.None);

            _scenarioContext.Set(accountAccessConsent.AggregateId, "consentId");
        }
        public async Task <AccountAccessContentResult> Handle(AddAccountAccessContentCommand request, CancellationToken cancellationToken)
        {
            var risk  = request.Risk == null ? string.Empty : request.Risk.ToString();
            var token = await _tokenRepository.Get(request.Token, cancellationToken);

            if (token == null)
            {
                _logger.LogError($"Access token '{request.Token}' is invalid or has been revoked");
                throw new UnauthorizedException(string.Format(Global.AccessTokenInvalid, token));
            }

            var accountAccessConsent = AccountAccessConsentAggregate.Create(token.ClientId, request.Data.Permissions, request.Data.ExpirationDateTime, request.Data.TransactionFromDateTime, request.Data.TransactionToDateTime, risk);
            await _commandRepository.Commit(accountAccessConsent, cancellationToken);

            var url = $"{request.Issuer}/{Constants.RouteNames.AccountAccessContents}/{accountAccessConsent.AggregateId}";

            return(AccountAccessContentResult.ToDto(accountAccessConsent, url, 1));
        }