public void GetAccountsSafelyRequestWorks()
        {
            IAutonomousApp            client         = this.GetAutonomousClient();
            IUserIdentity             userIdentity   = RecognizedUserIdentity.Master;
            string                    docType        = userIdentity.DocType;
            string                    docNumber      = userIdentity.DocNumber;
            IList <AccountResultInfo> inquiryResults = client.InquiriesV11.GetAccounts(docType, docNumber);

            CollectionAssert.IsNotEmpty(inquiryResults);
            Assert.That(inquiryResults.Count, Is.EqualTo(1));

            const string AccountIdPattern     = @"^[\d]*$";
            const string AccountNumberPattern = @".*\d{4}";

            foreach (AccountResultInfo inquiryResult in inquiryResults)
            {
                CollectionAssert.IsNotEmpty(inquiryResult.Data);
                Assert.IsNotEmpty(inquiryResult.Reason);
                Assert.That(inquiryResult.Status, Is.EqualTo(SubsystemStatus.Available));
                Assert.That(inquiryResult.Subsystem, Is.EqualTo(Subsystem.Tup));

                foreach (AccountInfo account in inquiryResult.Data)
                {
                    Assert.That(account.Balance, Is.AssignableTo(typeof(decimal)));
                    Assert.That(account.Id, Is.Not.Null.And.Match(AccountIdPattern));
                    Assert.That(account.SourceAccountId, Is.Not.Null.And.Match(AccountIdPattern));
                    Assert.That(account.MaskedPan, Is.Not.Null.And.Match(AccountNumberPattern));
                    Assert.That(account.Name, Is.Not.Empty);
                    CollectionAssert.IsNotEmpty(account.Properties);
                }
            }
        }
Exemple #2
0
        public void MismatchTokenBetweenAppsWhenAppSignedRequestThrows()
        {
            IAppIdentity   appIdentityMaster = AutonomousAppIdentity.Master;
            IAutonomousApp clientAppMaster   = AutonomousApp.Initialize(CachePolicy.BypassCache)
                                               .RoutingTo(TestingEndpointProvider.Default)
                                               .WithIdentity(appIdentityMaster)
                                               .Authenticate()
                                               .GetClient();

            Assert.That(clientAppMaster, Is.Not.Null);
            Assert.That(clientAppMaster.AuthToken, Is.Not.Null);
            Assert.That(clientAppMaster.AuthToken.Token, Is.Not.Null);

            IAppIdentity   appIdentityHelper = AutonomousAppIdentity.Helper;
            IAutonomousApp clientAppHelper   = AutonomousApp.Initialize(CachePolicy.BypassCache)
                                               .RoutingTo(TestingEndpointProvider.Default)
                                               .WithIdentity(appIdentityHelper)
                                               .Authenticate()
                                               .GetClient();

            Assert.That(clientAppHelper, Is.Not.Null);
            Assert.That(clientAppHelper.AuthToken, Is.Not.Null);
            Assert.That(clientAppHelper.AuthToken.Token, Is.Not.Null);

            IPayloadClaimsManager mismatchTokenClaimBehavior = InvalidTokenPayloadClaim.WithClaimBehavior(() => clientAppHelper.AuthToken.Token);

            ServiceLocator.Instance.RegisterPayloadClaimsManager(mismatchTokenClaimBehavior);
            AspenException exception = Assert.Throws <AspenException>(() => clientAppMaster.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15846"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            StringAssert.IsMatch("No coinciden los datos recibidos del token vs los valores esperados. ¿Se modificaron los valores en tránsito o está utilizando el ApiKey en otra aplicación?", exception.Message);
        }
        public void GetBalancesByAliasRequestWorks()
        {
            IAutonomousApp      client          = this.GetAutonomousClient();
            string              channelId       = "5845EDE2-6593-4183-A2B5-280EA15F89E4";
            string              enrollmentAlias = "52080323";
            IList <AccountInfo> accounts        = client.Inquiries.GetAccountsByAlias(channelId, enrollmentAlias);

            CollectionAssert.IsNotEmpty(accounts);
            AccountInfo accountInfo = accounts.FirstOrDefault(account => account.Source == Subsystem.Tup);

            Assert.IsNotNull(accountInfo);
            string accountId             = accountInfo.SourceAccountId;
            IList <BalanceInfo> balances = client.Inquiries.GetBalancesByAlias(channelId, enrollmentAlias, accountId);

            CollectionAssert.IsNotEmpty(balances);
            Assert.That(balances.Count, Is.EqualTo(5));
            const string AccountTypesPattern  = "80|81|82|83|84";
            const string AccountNumberPattern = @".*\d{4}";

            foreach (BalanceInfo balance in balances)
            {
                Assert.That(balance.Balance, Is.AssignableTo(typeof(decimal)));
                Assert.That(balance.Number, Is.Not.Null.And.Match(AccountNumberPattern));
                Assert.That(balance.SourceAccountId, Is.Not.Empty);
                Assert.That(balance.TypeId, Is.Not.Null.And.Match(AccountTypesPattern));
                Assert.That(balance.TypeName, Is.Not.Empty);
            }
        }
        public void RecognizedEndpoint()
        {
            IAutonomousApp client    = this.GetAutonomousClient();
            AspenException exception = Assert.Throws <AspenException>(() => client.Dynamics.Post("client/test/calc", new KeyValuePair <string, object>("Input", "20")));

            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
        }
        public void GetBalancesRequestWorks()
        {
            IAutonomousApp      client       = this.GetAutonomousClient();
            IUserIdentity       userIdentity = RecognizedUserIdentity.Master;
            string              docType      = userIdentity.DocType;
            string              docNumber    = userIdentity.DocNumber;
            IList <AccountInfo> accounts     = client.Inquiries.GetAccounts(docType, docNumber);

            CollectionAssert.IsNotEmpty(accounts);
            AccountInfo accountInfo = accounts.FirstOrDefault(account => account.Source == Subsystem.Tup);

            Assert.IsNotNull(accountInfo);
            string accountId             = accountInfo.SourceAccountId;
            IList <BalanceInfo> balances = client.Inquiries.GetBalances(docType, docNumber, accountId);

            CollectionAssert.IsNotEmpty(balances);
            Assert.That(balances.Count, Is.EqualTo(5));
            const string AccountTypesPattern  = "80|81|82|83|84";
            const string AccountNumberPattern = @".*\d{4}";

            foreach (BalanceInfo balance in balances)
            {
                Assert.That(balance.Balance, Is.AssignableTo(typeof(decimal)));
                Assert.That(balance.Number, Is.Not.Null.And.Match(AccountNumberPattern));
                Assert.That(balance.SourceAccountId, Is.Not.Empty);
                Assert.That(balance.TypeId, Is.Not.Null.And.Match(AccountTypesPattern));
                Assert.That(balance.TypeName, Is.Not.Empty);
            }
        }
        public void GetAccountsByAliasRequestWorks()
        {
            IAutonomousApp      client          = this.GetAutonomousClient();
            string              channelId       = "5845EDE2-6593-4183-A2B5-280EA15F89E4";
            string              enrollmentAlias = "52080323";
            IList <AccountInfo> accounts        = client.Inquiries.GetAccountsByAlias(channelId, enrollmentAlias);

            CollectionAssert.IsNotEmpty(accounts);
            Assert.That(accounts.Count, Is.EqualTo(1));

            const string AccountIdPattern     = @"^[\d]*$";
            const string AccountNumberPattern = @".*\d{4}";

            foreach (AccountInfo account in accounts)
            {
                Assert.That(account.Balance, Is.AssignableTo(typeof(decimal)));
                Assert.That(account.Id, Is.Not.Null.And.Match(AccountIdPattern));
                Assert.That(account.SourceAccountId, Is.Not.Null.And.Match(AccountIdPattern));
                Assert.That(account.MaskedPan, Is.Not.Null.And.Match(AccountNumberPattern));
                Assert.That(account.Name, Is.Not.Empty);
                CollectionAssert.IsNotEmpty(account.Properties);
            }

            IList <AccountProperty> properties = accounts.First().Properties.ToList();

            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranName"), Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranDate"), Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranCardAcceptor"), Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "CardStatusName"), Is.Not.Null);
        }
        public void GetTopUpValuesWorks()
        {
            IAutonomousApp    client      = this.GetAutonomousClient();
            IList <TopUpInfo> topUpValues = client.Settings.GetTopUpValues();

            CollectionAssert.IsNotEmpty(topUpValues);
        }
        public void GetTranTypesWorks()
        {
            IAutonomousApp       client    = this.GetAutonomousClient();
            IList <TranTypeInfo> tranTypes = client.Settings.GetTranTypes();

            CollectionAssert.IsNotEmpty(tranTypes);
        }
        public void GetCarriersWorks()
        {
            IAutonomousApp      client   = this.GetAutonomousClient();
            IList <CarrierInfo> carriers = client.Settings.GetCarriers();

            CollectionAssert.IsNotEmpty(carriers);
        }
        public void GetAccountsRequestWorks()
        {
            IAutonomousApp      client       = this.GetAutonomousClient();
            IUserIdentity       userIdentity = RecognizedUserIdentity.Master;
            string              docType      = userIdentity.DocType;
            string              docNumber    = userIdentity.DocNumber;
            IList <AccountInfo> accounts     = client.Inquiries.GetAccounts(docType, docNumber);

            CollectionAssert.IsNotEmpty(accounts);

            const string AccountIdPattern     = @"^[\d]*$";
            const string AccountNumberPattern = @".*\d{4}";

            foreach (AccountInfo account in accounts)
            {
                Assert.That(account.Balance, Is.AssignableTo(typeof(decimal)));
                Assert.That(account.Id, Is.Not.Null.And.Match(AccountIdPattern));
                Assert.That(account.SourceAccountId, Is.Not.Null.And.Match(AccountIdPattern));
                Assert.That(account.MaskedPan, Is.Not.Null.And.Match(AccountNumberPattern));
                Assert.That(account.Name, Is.Not.Empty);
                CollectionAssert.IsNotEmpty(account.Properties);
            }

            IList <AccountProperty> properties = accounts.First().Properties.ToList();

            Assert.That(properties.Count, Is.EqualTo(4));
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranName"), Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranDate"), Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "LastTranCardAcceptor"), Is.Not.Null);
            Assert.That(properties.SingleOrDefault(p => p.Key == "CardStatusName"), Is.Not.Null);
        }
        public void AppSigninRequestWorks()
        {
            IAutonomousApp client = this.GetAutonomousClient();

            Assert.That(client, Is.Not.Null);
            Assert.That(client.AuthToken, Is.Not.Null);
            Assert.That(client.AuthToken.Token, Is.Not.Null);
        }
        public void DumpTraceNotFoundWorks()
        {
            IAutonomousApp client    = this.GetAutonomousClient();
            AspenException exception = Assert.Throws <AspenException>(() => client.Dynamics.Post("diagnostics/dump/998fdd73"));

            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
            Assert.That(exception.EventId, Is.EqualTo("15840"));
        }
Exemple #13
0
        public void MissingApiVersionHeaderWhenAppSigninRequestWorks()
        {
            ServiceLocator.Instance.RegisterHeadersManager(InvalidApiVersionHeader.AvoidingHeader());
            IAutonomousApp client = this.GetAutonomousClient();

            Assert.That(client, Is.Not.Null);
            Assert.That(client.AuthToken, Is.Not.Null);
            Assert.That(client.AuthToken.Token, Is.Not.Null);
        }
        public void GetAccountsUnrecognizedUserResponseIsEmpty()
        {
            IAutonomousApp      client                = this.GetAutonomousClient();
            string              fixedDocType          = "CC";
            string              unrecognizedDocNumber = new Random().Next(1000000000, int.MaxValue).ToString();
            IList <AccountInfo> accounts              = client.Inquiries.GetAccounts(fixedDocType, unrecognizedDocNumber);

            CollectionAssert.IsEmpty(accounts);
        }
        public void GetBalancesUnrecognizedUserResponseIsEmpty()
        {
            IAutonomousApp      client                = this.GetAutonomousClient();
            string              fixedDocType          = "CC";
            string              unrecognizedDocNumber = new Random().Next(1000000000, int.MaxValue).ToString();
            string              accountId             = new Random().Next(99, 9999).ToString();
            IList <BalanceInfo> balances              = client.Inquiries.GetBalances(fixedDocType, unrecognizedDocNumber, accountId);

            CollectionAssert.IsEmpty(balances);
        }
        public void GetStatementsSafelyRequestWorks()
        {
            IAutonomousApp      client       = this.GetAutonomousClient();
            IUserIdentity       userIdentity = RecognizedUserIdentity.Master;
            string              docType      = userIdentity.DocType;
            string              docNumber    = userIdentity.DocNumber;
            IList <AccountInfo> accounts     = client.Inquiries.GetAccounts(docType, docNumber);

            CollectionAssert.IsNotEmpty(accounts);
            AccountInfo accountInfo = accounts.FirstOrDefault(account => account.Source == Subsystem.Tup);

            Assert.IsNotNull(accountInfo);
            string accountId = accountInfo.SourceAccountId;

            Assert.IsNotEmpty(accountId);
            IList <BalanceInfo> balances = client.Inquiries.GetBalances(docType, docNumber, accountId);

            CollectionAssert.IsNotEmpty(balances);

            void AssertStatementsSafeResults(IList <MiniStatementResultInfo> statementInquiryResults)
            {
                CollectionAssert.IsNotEmpty(statementInquiryResults);
                foreach (MiniStatementResultInfo inquiryResult in statementInquiryResults)
                {
                    Assert.IsNotEmpty(inquiryResult.Reason);
                    Assert.That(inquiryResult.Status, Is.EqualTo(SubsystemStatus.Available));
                    Assert.That(inquiryResult.Subsystem, Is.EqualTo(Subsystem.Tup));
                    IList <MiniStatementInfo> statements = inquiryResult.Data;
                    CollectionAssert.IsNotEmpty(statements);
                    Assert.That(statements.Count, Is.EqualTo(5));

                    const string AccountTypesPattern = "80|81|82|83|84";
                    foreach (MiniStatementInfo statement in statements)
                    {
                        Assert.That(statement.AccountTypeId, Is.Not.Null.And.Match(AccountTypesPattern));
                        Assert.That(statement.Amount, Is.AssignableTo(typeof(decimal)));
                        Assert.That(statement.CardAcceptor, Is.Not.Null);
                        Assert.That(statement.TranName, Is.Not.Null);
                        Assert.That(statement.TranType, Is.Not.Null);
                    }
                }
            }

            // Los movimientos más recientes realizados por la cuenta...
            IList <MiniStatementResultInfo> inquiryResults = client.InquiriesV11.GetStatements(docType, docNumber, accountId);

            AssertStatementsSafeResults(inquiryResults);

            // Los movimientos más recientes realizados por la cuenta y el bolsillo específico...
            string accountTypeId = balances.First().TypeId;

            Assert.IsNotEmpty(accountTypeId);
            inquiryResults = client.InquiriesV11.GetStatements(docType, docNumber, accountId, accountTypeId);
            AssertStatementsSafeResults(inquiryResults);
        }
        public void EpochZeroWhenSignedRequestThrows()
        {
            IAutonomousApp client = this.GetAutonomousClient();

            ServiceLocator.Instance.RegisterEpochGenerator(FixedEpochGenerator.FromStaticSeconds(0));
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15851"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.RequestedRangeNotSatisfiable));
            StringAssert.IsMatch("Epoch está fuera de rango admitido", exception.Message);
        }
        public void MissingTokenWhenSignedRequestThrows()
        {
            IAutonomousApp client = this.GetAutonomousClient();

            ServiceLocator.Instance.RegisterPayloadClaimsManager(InvalidTokenPayloadClaim.AvoidingClaim());
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15852"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("'Token' no puede ser nulo ni vacío", exception.Message);
        }
        public void MissingPayloadHeaderWhenUserSignedRequestThrows()
        {
            IAutonomousApp client = this.GetAutonomousClient();

            ServiceLocator.Instance.RegisterHeadersManager(InvalidPayloadHeader.AvoidingHeader());
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("20002"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("Se requiere la cabecera personalizada 'X-PRO-Auth-Payload'", exception.Message);
        }
        public void GetAccountsByAliasUnrecognizedChannelThrows()
        {
            IAutonomousApp client = this.GetAutonomousClient();
            string         unrecognizedChannelId = Guid.NewGuid().ToString();
            string         enrollmentAlias       = "52080323";
            AspenException exception             = Assert.Throws <AspenException>(() => client.Inquiries.GetAccountsByAlias(unrecognizedChannelId, enrollmentAlias));

            Assert.That(exception.EventId, Is.EqualTo("15881"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
            StringAssert.IsMatch("No se ha encontrado información de enrolamiento con los valores suministrados", exception.Message);
        }
        public void GetAccountsByAliasUnrecognizedEnrollmentAliasThrows()
        {
            IAutonomousApp client    = this.GetAutonomousClient();
            string         channelId = "5845EDE2-6593-4183-A2B5-280EA15F89E4";
            string         unrecognizedEnrollmentAlias = new Random().Next(1000000000, int.MaxValue).ToString();
            AspenException exception = Assert.Throws <AspenException>(() => client.Inquiries.GetAccountsByAlias(channelId, unrecognizedEnrollmentAlias));

            Assert.That(exception.EventId, Is.EqualTo("15881"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
            StringAssert.IsMatch("No se ha encontrado información de enrolamiento con los valores suministrados", exception.Message);
        }
        public void RecognizedEndpointWorks()
        {
            IAutonomousApp client   = this.GetAutonomousClient();
            int            a        = new Random(Guid.NewGuid().GetHashCode()).Next(10, 100);
            int            b        = new Random(Guid.NewGuid().GetHashCode()).Next(10, 100);
            CustomRequest  request  = new CustomRequest(a, b, '+');
            CustomResponse response = client.Dynamics.Post <CustomRequest, CustomResponse>("client/test/calc", request);

            Assert.That(response.Result, Is.EqualTo(a + b));
            Assert.That(response.Text, Is.Null.Or.Empty);
        }
        public void GetStatementsSafelyUnavailableRecognizedDataProviderRequestWorks()
        {
            IAutonomousApp      client       = this.GetAutonomousClient();
            IUserIdentity       userIdentity = RecognizedUserIdentity.Master;
            string              docType      = userIdentity.DocType;
            string              docNumber    = userIdentity.DocNumber;
            IList <AccountInfo> accounts     = client.Inquiries.GetAccounts(docType, docNumber);

            CollectionAssert.IsNotEmpty(accounts);
            AccountInfo accountInfo = accounts.FirstOrDefault(account => account.Source == Subsystem.Tup);

            Assert.IsNotNull(accountInfo);
            string accountId = accountInfo.SourceAccountId;

            Assert.IsNotEmpty(accountId);
            IList <BalanceInfo> balances = client.Inquiries.GetBalances(docType, docNumber, accountId);

            CollectionAssert.IsNotEmpty(balances);

            void AssertStatementsSafeResults(IList <MiniStatementResultInfo> statementInquiryResults)
            {
                CollectionAssert.IsNotEmpty(statementInquiryResults);
                Assert.That(statementInquiryResults.Count, Is.EqualTo(1));
                foreach (MiniStatementResultInfo inquiryResult in statementInquiryResults)
                {
                    CollectionAssert.IsEmpty(inquiryResult.Data);
                    Assert.IsNotEmpty(inquiryResult.Reason);
                    Assert.That(inquiryResult.Subsystem, Is.EqualTo(Subsystem.Tup));
                    Assert.That(inquiryResult.Status, Is.EqualTo(SubsystemStatus.Unavailable));
                }
            }

            // Se configura una conexión inválida para el proveedor de datos de TUP para esperar que falle la consulta de saldos...
            IAppIdentity appIdentity = AutonomousAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().SetAppSettingsKey(appIdentity.ApiKey, "Bifrost:ConnectionStringName", "RabbitMQ:Broken:Tests");
            TestContext.CurrentContext.DatabaseHelper().SetAppSettingsKey(appIdentity.ApiKey, "TUP:ConnectionStringName", "Aspen");

            // Los movimientos más recientes realizados por la cuenta...
            IList <MiniStatementResultInfo> inquiryResults = client.InquiriesV11.GetStatements(docType, docNumber, accountId);

            AssertStatementsSafeResults(inquiryResults);

            // Los movimientos más recientes realizados por la cuenta y el bolsillo específico...
            string accountTypeId = balances.First().TypeId;

            Assert.IsNotEmpty(accountTypeId);
            inquiryResults = client.InquiriesV11.GetStatements(docType, docNumber, accountId, accountTypeId);
            AssertStatementsSafeResults(inquiryResults);

            // Se reestablece las conexión valida al proveedor de datos de TUP...
            TestContext.CurrentContext.DatabaseHelper().SetAppSettingsKey(appIdentity.ApiKey, "Bifrost:ConnectionStringName", "RabbitMQ:Bifrost:Tests");
            TestContext.CurrentContext.DatabaseHelper().SetAppSettingsKey(appIdentity.ApiKey, "TUP:ConnectionStringName", "Sql:TupCompensar");
        }
Exemple #24
0
        public void NotFoundValidTokenWhenAppSignedRequestThrows()
        {
            IAutonomousApp client      = this.GetAutonomousClient();
            IAppIdentity   appIdentity = AutonomousAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().RemoveAppAuthToken(appIdentity.ApiKey);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15847"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            StringAssert.IsMatch("No hay un token de autenticación vigente", exception.Message);
        }
        public void InvalidFormatTokenWhenSignedRequestThrows()
        {
            IAutonomousApp        client = this.GetAutonomousClient();
            IPayloadClaimsManager invalidTokenClaimBehavior = InvalidTokenPayloadClaim.WithClaimBehavior(() => "gXjyhrYqannHUA$LLV&7guTHmF&1X5JB$Uobx3@!rPn9&x4BzE");

            ServiceLocator.Instance.RegisterPayloadClaimsManager(invalidTokenClaimBehavior);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("20007"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("El contenido de la cabecera personalizada 'X-PRO-Auth-Payload' no es válido", exception.Message);
        }
        public void InvalidFormatPayloadWhenUserSignedRequestThrows()
        {
            IAutonomousApp  client = this.GetAutonomousClient();
            IHeadersManager invalidPayloadHeaderBehavior = InvalidPayloadHeader.WithHeaderBehavior(() => "Lorem ipsum dolor sit amet, consetetur sadipscing elitr");

            ServiceLocator.Instance.RegisterHeadersManager(invalidPayloadHeaderBehavior);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("20007"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("El contenido de la cabecera personalizada 'X-PRO-Auth-Payload' no es válido", exception.Message);
        }
        public void GetStatementsUnrecognizedUserResponseIsEmpty()
        {
            IAutonomousApp client                = this.GetAutonomousClient();
            string         fixedDocType          = "CC";
            string         unrecognizedDocNumber = new Random().Next(1000000000, int.MaxValue).ToString();
            string         accountId             = new Random().Next(999, 9999).ToString();

            IList <MiniStatementInfo> GetStatements() => client.Inquiries.GetStatements(fixedDocType, unrecognizedDocNumber, accountId);

            Assert.DoesNotThrow(() => GetStatements());
            CollectionAssert.IsEmpty(GetStatements());
        }
        public void EpochNegativeWhenSignedRequestThrows()
        {
            IAutonomousApp client          = this.GetAutonomousClient();
            double         negativeSeconds = -DateTimeOffset.Now.ToUnixTimeSeconds();

            ServiceLocator.Instance.RegisterEpochGenerator(FixedEpochGenerator.FromStaticSeconds(negativeSeconds));
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15850"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("Formato de Epoch no es valido. Debe ser un número.", exception.Message);
        }
Exemple #29
0
        public void MismatchTokenSignatureWhenAppSignedRequestThrows()
        {
            IAutonomousApp client            = this.GetAutonomousClient();
            IAppIdentity   appIdentityMaster = AutonomousAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().EnsureMismatchAppAuthToken(appIdentityMaster.ApiKey);
            AspenException exception = Assert.Throws <AspenException>(() => client.Settings.GetDocTypes());

            Assert.That(exception.EventId, Is.EqualTo("15846"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            StringAssert.IsMatch("No coinciden los datos recibidos del token vs los valores esperados. ¿Se modificaron los valores en tránsito o está utilizando el ApiKey en otra aplicación?", exception.Message);
        }
        public void GetStatementsRequestWorks()
        {
            IAutonomousApp      client       = this.GetAutonomousClient();
            IUserIdentity       userIdentity = RecognizedUserIdentity.Master;
            string              docType      = userIdentity.DocType;
            string              docNumber    = userIdentity.DocNumber;
            IList <AccountInfo> accounts     = client.Inquiries.GetAccounts(docType, docNumber);

            CollectionAssert.IsNotEmpty(accounts);
            AccountInfo accountInfo = accounts.FirstOrDefault(account => account.Source == Subsystem.Tup);

            Assert.IsNotNull(accountInfo);
            string accountId = accountInfo.SourceAccountId;

            Assert.IsNotEmpty(accountId);
            IList <BalanceInfo> balances = client.Inquiries.GetBalances(docType, docNumber, accountId);

            CollectionAssert.IsNotEmpty(balances);

            // Los movimientos más recientes realizados por todas las cuentas...
            IList <MiniStatementInfo> statements = client.Inquiries.GetStatements(docType, docNumber, accountId);

            CollectionAssert.IsNotEmpty(statements);
            Assert.That(statements.Count, Is.EqualTo(5));
            const string AccountTypesPattern = "80|81|82|83|84";

            foreach (MiniStatementInfo statement in statements)
            {
                Assert.That(statement.AccountTypeId, Is.Not.Null.And.Match(AccountTypesPattern));
                Assert.That(statement.Amount, Is.AssignableTo(typeof(decimal)));
                Assert.That(statement.CardAcceptor, Is.Not.Null);
                Assert.That(statement.TranName, Is.Not.Null);
                Assert.That(statement.TranType, Is.Not.Null);
            }

            // Los movimientos realizados por una cuenta específica...
            string accountTypeId = balances.First().TypeId;

            Assert.IsNotEmpty(accountTypeId);
            IList <MiniStatementInfo> statementsByAccountType = client.Inquiries.GetStatements(docType, docNumber, accountId, accountTypeId);

            CollectionAssert.IsNotEmpty(statementsByAccountType);
            Assert.That(statements.Count, Is.EqualTo(5));
            foreach (MiniStatementInfo statement in statementsByAccountType)
            {
                Assert.That(statement.AccountTypeId, Is.EqualTo(accountTypeId));
                Assert.That(statement.Amount, Is.AssignableTo(typeof(decimal)));
                Assert.That(statement.CardAcceptor, Is.Not.Null);
                Assert.That(statement.TranName, Is.Not.Null);
                Assert.That(statement.TranType, Is.Not.Null);
            }
        }