public void GetSettingsAsynchronouslyWorks()
        {
            IDelegatedApp client = this.GetDelegatedClient();

            IList <CarrierInfo>     carriers      = Enumerable.Empty <CarrierInfo>().ToList();
            IList <DocTypeInfo>     docTypes      = Enumerable.Empty <DocTypeInfo>().ToList();
            IList <MenuItemInfo>    menuItems     = Enumerable.Empty <MenuItemInfo>().ToList();
            MiscellaneousSettings   miscellaneous = new MiscellaneousSettings();
            IList <PaymentTypeInfo> paymentTypes  = Enumerable.Empty <PaymentTypeInfo>().ToList();
            IList <TopUpInfo>       topUpValues   = Enumerable.Empty <TopUpInfo>().ToList();
            IList <TranTypeInfo>    tranTypes     = Enumerable.Empty <TranTypeInfo>().ToList();

            Assert.DoesNotThrowAsync(async() => carriers      = await client.Settings.GetCarriersAsync());
            Assert.DoesNotThrowAsync(async() => docTypes      = await client.Settings.GetDocTypesAsync());
            Assert.DoesNotThrowAsync(async() => menuItems     = await client.Settings.GetMenuAsync());
            Assert.DoesNotThrowAsync(async() => miscellaneous = await client.Settings.GetMiscellaneousSettingsAsync());
            Assert.DoesNotThrowAsync(async() => paymentTypes  = await client.Settings.GetPaymentTypesAsync());
            Assert.DoesNotThrowAsync(async() => topUpValues   = await client.Settings.GetTopUpValuesAsync());
            Assert.DoesNotThrowAsync(async() => tranTypes     = await client.Settings.GetTranTypesAsync());
            CollectionAssert.IsNotEmpty(carriers);
            CollectionAssert.IsNotEmpty(docTypes);
            CollectionAssert.IsNotEmpty(menuItems);
            CollectionAssert.IsNotEmpty(miscellaneous);
            CollectionAssert.IsNotEmpty(paymentTypes);
            CollectionAssert.IsNotEmpty(topUpValues);
            CollectionAssert.IsNotEmpty(tranTypes);
        }
        /// <summary>
        /// Restablece y registra cuentas para transferencia al usuario de pruebas reconocido.
        /// </summary>
        private void LinkTransferAccountsToRecognizedUser()
        {
            IDelegatedApp client = this.GetDelegatedClient();
            List <(string, string, string)> recognizedCardHolders = new List <(string, string, string)>
            {
                ("CC", "79483129", "6039590286132628"),
                ("CC", "52150900", "6039594610201554"),
                ("CC", "3262308", "6039590635149836"),
                ("CC", "52582664", "6039594246705697"),
                ("CC", "35512889", "6039599272117600")
            };

            const string RecognizedPinNumber = "141414";

            foreach ((string cardHolderDocType, string cardHolderDocNumber, string accountNumber) in recognizedCardHolders)
            {
                string randomAlias = new Random().Next(9999, 99999).ToString();
                LinkTransferAccountInfo linkTransferAccountInfo = new LinkTransferAccountInfo(
                    cardHolderDocType,
                    cardHolderDocNumber,
                    randomAlias,
                    accountNumber,
                    RecognizedPinNumber);
                client.Management.LinkTransferAccount(linkTransferAccountInfo);
            }
        }
        public void GetAccountsRequestWorks()
        {
            IDelegatedApp client = this.GetDelegatedClient();
            IList <AccountExtendedInfo> accounts = client.Inquiries.GetAccounts();

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

            const string AccountIdPattern       = @"^[\d]*$";
            const string AccountNumberPattern   = @".*\d{4}";
            const string BackgroundColorPattern = @"^#(?:[0-9a-fA-F]{3}){1,2}$";

            foreach (AccountExtendedInfo 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);
                Assert.That(account.ShortName, Is.Not.Empty);
                Assert.That(account.BackgroundColor, Is.Not.Null.And.Match(BackgroundColorPattern));
                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 LinkTransferAccountWorks()
        {
            this.DeleteTransferAccountsFromRecognizedUser();
            IDelegatedApp           client = this.GetDelegatedClient();
            string                  recognizedPinNumber           = "141414";
            string                  recognizedCardHolderDocType   = "CC";
            string                  recognizedCardHolderDocNumber = "79483129";
            string                  recognizedAlias         = "MyTransferAccount";
            string                  accountNumber           = "6039590286132628";
            LinkTransferAccountInfo linkTransferAccountInfo = new LinkTransferAccountInfo(
                recognizedCardHolderDocType,
                recognizedCardHolderDocNumber,
                recognizedAlias,
                accountNumber,
                recognizedPinNumber);

            Assert.DoesNotThrow(() => client.Management.LinkTransferAccount(linkTransferAccountInfo));
            IList <TransferAccountInfo> transferAccounts = client.Management.GetTransferAccounts();

            CollectionAssert.IsNotEmpty(transferAccounts);
            TransferAccountInfo transferAccountInfo = transferAccounts.FirstOrDefault(info => info.Alias == recognizedAlias);

            Assert.NotNull(transferAccountInfo);
            Assert.That(transferAccountInfo.CardHolderDocType, Is.EqualTo(recognizedCardHolderDocType));
            Assert.That(transferAccountInfo.CardHolderDocNumber, Is.EqualTo(recognizedCardHolderDocNumber));
            Assert.IsNotEmpty(transferAccountInfo.CardHolderName);
            const string MaskedPanPattern = @".*\d{4}";

            Assert.That(transferAccountInfo.MaskedPan, Is.Not.Null.And.Match(MaskedPanPattern));
        }
Exemple #5
0
        public void MismatchTokenBetweenUsersWhenUserSignedRequestThrows()
        {
            IAppIdentity commonAppIdentity = DelegatedAppIdentity.Master;

            IUserIdentity userIdentityMaster = RecognizedUserIdentity.Master;
            IDelegatedApp clientAppMaster    = DelegatedApp.Initialize(CachePolicy.BypassCache)
                                               .RoutingTo(TestingEndpointProvider.Default)
                                               .WithIdentity(commonAppIdentity)
                                               .Authenticate(userIdentityMaster)
                                               .GetClient();

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

            IUserIdentity userIdentityHelper = RecognizedUserIdentity.Helper;
            IDelegatedApp clientAppHelper    = DelegatedApp.Initialize(CachePolicy.BypassCache)
                                               .RoutingTo(TestingEndpointProvider.Default)
                                               .WithIdentity(commonAppIdentity)
                                               .Authenticate(userIdentityHelper)
                                               .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 GenerateTokenWithUnrecognizedChannelFromRemoteProviderWorks()
        {
            IDelegatedApp client = this.GetDelegatedClient();

            UseRemoteTokenProvider();

            string        pinNumber            = "141414";
            List <string> unrecognizedChannels = new List <string>()
            {
                "XX",
                "00",
                "X0",
                "**"
            };

            foreach (string unrecognizedChannel in unrecognizedChannels)
            {
                TokenResponseInfo tokenResponseInfo = null;
                Assert.DoesNotThrow(() => tokenResponseInfo = client.Token.GenerateToken(pinNumber, channelKey: unrecognizedChannel));
                Printer.Print(tokenResponseInfo, "TokenResponseInfo");
                Assert.NotNull(tokenResponseInfo);
                Assert.IsNotEmpty(tokenResponseInfo.Token);
                Assert.That(tokenResponseInfo.ExpirationMinutes, Is.GreaterThan(0));
                Assert.That(tokenResponseInfo.ExpiresAt, Is.GreaterThan(DateTimeOffset.Now));
            }
        }
        public void GetBalancesRequestWorks()
        {
            IDelegatedApp client = this.GetDelegatedClient();
            IList <AccountExtendedInfo> accounts = client.Inquiries.GetAccounts();

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

            Assert.IsNotNull(tupAccountInfo);
            string accountId = tupAccountInfo.SourceAccountId;
            IList <BalanceExtendedInfo> balances = client.Inquiries.GetBalances(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 (BalanceExtendedInfo 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);
            }
        }
Exemple #8
0
        public void UserSigninRequestWorks()
        {
            IDelegatedApp client = this.GetDelegatedClient();

            Assert.That(client, Is.Not.Null);
            Assert.That(client.AuthToken, Is.Not.Null);
            Assert.That(client.AuthToken.Token, Is.Not.Null);
        }
        public void GetTransferAccountsNoContentWorks()
        {
            this.DeleteTransferAccountsFromRecognizedUser();
            IDelegatedApp client = this.GetDelegatedClient();
            IList <TransferAccountInfo> transferAccounts = client.Management.GetTransferAccounts();

            CollectionAssert.IsEmpty(transferAccounts);
        }
Exemple #10
0
        public void MissingApiVersionHeaderWhenUserSigninRequestWorks()
        {
            ServiceLocator.Instance.RegisterHeadersManager(InvalidApiVersionHeader.AvoidingHeader());
            IDelegatedApp client = this.GetDelegatedClient();

            Assert.That(client, Is.Not.Null);
            Assert.That(client.AuthToken, Is.Not.Null);
            Assert.That(client.AuthToken.Token, Is.Not.Null);
        }
        public void GetTokenChannelsWorks()
        {
            IDelegatedApp            client        = this.GetDelegatedClient();
            IList <TokenChannelInfo> tokenChannels = client.Token.GetChannels();

            CollectionAssert.IsNotEmpty(tokenChannels);
            CollectionAssert.IsNotEmpty(client.Token.GetChannelsAsync().Result);
            Printer.Print(tokenChannels, "TokenChannels");
        }
        public void GetStatementsUnrecognizedAccountResponseIsEmpty()
        {
            IDelegatedApp client = this.GetDelegatedClient();
            string        unrecognizedAccountId = new Random().Next(999, 9999).ToString();

            IList <MiniStatementInfo> GetStatements() => client.Inquiries.GetStatements(unrecognizedAccountId, "80");

            Assert.DoesNotThrow(() => GetStatements());
            CollectionAssert.IsEmpty(GetStatements());
        }
        /// <summary>
        /// Restablece y registra cuentas para transferencia al usuario de pruebas reconocido.
        /// </summary>
        private void DeleteTransferAccountsFromRecognizedUser()
        {
            IDelegatedApp client = this.GetDelegatedClient();
            IList <TransferAccountInfo> currentTransferAccounts = client.Management.GetTransferAccounts();

            foreach (TransferAccountInfo transferAccountInfo in currentTransferAccounts)
            {
                client.Management.UnlinkTransferAccount(transferAccountInfo.Alias);
            }
        }
        public void GetBalancesUnrecognizedAccountResponseIsEmpty()
        {
            IDelegatedApp client          = this.GetDelegatedClient();
            string        randomAccountId = new Random().Next(99, 9999).ToString();

            IList <BalanceExtendedInfo> GetBalances() => client.Inquiries.GetBalances(randomAccountId);

            Assert.DoesNotThrow(() => GetBalances());
            CollectionAssert.IsEmpty(GetBalances());
        }
Exemple #15
0
        public void EpochZeroWhenSignedRequestThrows()
        {
            IDelegatedApp client = this.GetDelegatedClient();

            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);
        }
Exemple #16
0
        public void MissingUsernameWhenSignedRequestThrows()
        {
            IDelegatedApp client = this.GetDelegatedClient();

            ServiceLocator.Instance.RegisterPayloadClaimsManager(InvalidUsernamePayloadClaim.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("'Username' no puede ser nulo ni vacío", exception.Message);
        }
Exemple #17
0
        public void MissingPayloadHeaderWhenUserSignedRequestThrows()
        {
            IDelegatedApp client = this.GetDelegatedClient();

            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);
        }
Exemple #18
0
        public void UsingRandomDeviceIdWhenUserSigninRequestWorks()
        {
            IPayloadClaimsManager randomDeviceIdClaimBehavior = InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => $"MyRandomDevice-{new Random().Next(999999, 9999999)}");

            ServiceLocator.Instance.RegisterPayloadClaimsManager(randomDeviceIdClaimBehavior);
            IDelegatedApp client = this.GetDelegatedClient();

            Assert.That(client, Is.Not.Null);
            Assert.That(client.AuthToken, Is.Not.Null);
            Assert.That(client.AuthToken.Token, Is.Not.Null);
        }
        public void GenerateTokenWithUnrecognizedTokenProviderNameThrows()
        {
            IDelegatedApp client    = this.GetDelegatedClient();
            string        pinNumber = "141414";

            UseUnrecognizedTokenProvider();
            AspenException exception = Assert.Throws <AspenException>(() => client.Token.GenerateToken(pinNumber));

            Assert.That(exception.EventId, Is.EqualTo("15898"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotImplemented));
            StringAssert.IsMatch("No se reconoce el nombre el proveedor de token transaccionales configurado para la aplicación", exception.Message);
        }
Exemple #20
0
        public void MismatchDeviceIdWhenUserSignedRequestThrows()
        {
            IDelegatedApp         client = this.GetDelegatedClient();
            IPayloadClaimsManager randomDeviceIdClaimBehavior = InvalidDeviceIdPayloadClaim.WithClaimBehavior(() => $"MyRandomDevice-{new Random().Next(999999, 9999999)}");

            ServiceLocator.Instance.RegisterPayloadClaimsManager(randomDeviceIdClaimBehavior);
            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);
        }
Exemple #21
0
        public void EpochNegativeWhenSignedRequestThrows()
        {
            IDelegatedApp client          = this.GetDelegatedClient();
            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 #22
0
        public void InvalidFormatTokenWhenSignedRequestThrows()
        {
            IDelegatedApp         client = this.GetDelegatedClient();
            IPayloadClaimsManager invalidFormatBehavior = InvalidTokenPayloadClaim.WithClaimBehavior(() => "gXjyhrYqannHUA$LLV&7guTHmF&1X5JB$Uobx3@!rPn9&x4BzE");

            ServiceLocator.Instance.RegisterPayloadClaimsManager(invalidFormatBehavior);
            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);
        }
Exemple #23
0
        public void InvalidFormatPayloadWhenUserSignedRequestThrows()
        {
            IDelegatedApp   client = this.GetDelegatedClient();
            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 SendTokenWhenRemoteProviderBrokenThrows()
        {
            IDelegatedApp client = this.GetDelegatedClient();

            UseRemoteTokenProvider();
            UseBrokenConnection();
            AspenException exception = Assert.Throws <AspenException>(() => client.Token.SendToken());

            Assert.That(exception.EventId, Is.EqualTo("355003"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadGateway));
            StringAssert.IsMatch("Se ha presentado un error general con el sistema externo que administra los tokens o claves transaccionales", exception.Message);
        }
        public void GetAccountsRecognizedDataProvidersRequestWorks()
        {
            // Se habilitan los proveedores actuales en la aplicación...
            IAppIdentity appIdentity = DelegatedAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().SetAppSettingsKey(appIdentity.ApiKey, "DataProvider:SubsystemEnabled", "TUP|Bancor");

            IDelegatedApp client = this.GetDelegatedClient();
            IList <AccountExtendedInfo> accounts = client.Inquiries.GetAccounts();

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

            const string AccountIdPattern       = @"^[\d]*$";
            const string AccountNumberPattern   = @".*\d{4}";
            const string BackgroundColorPattern = @"^#(?:[0-9a-fA-F]{3}){1,2}$";

            foreach (AccountExtendedInfo 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);
                Assert.That(account.ShortName, Is.Not.Empty);
                Assert.That(account.BackgroundColor, Is.Not.Null.And.Match(BackgroundColorPattern));
                CollectionAssert.IsNotEmpty(account.Properties);

                IList <AccountProperty> accountProperties = account.Properties;
                switch (account.Source)
                {
                case Subsystem.Tup:
                    Assert.That(accountProperties.Count, Is.EqualTo(4));
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "LastTranName"), Is.Not.Null);
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "LastTranDate"), Is.Not.Null);
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "LastTranCardAcceptor"), Is.Not.Null);
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "CardStatusName"), Is.Not.Null);
                    break;

                case Subsystem.Bancor:
                    Assert.That(accountProperties.Count, Is.EqualTo(4));
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "LastTran"), Is.Not.Null);
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "NextPayment"), Is.Not.Null);
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "FullPayment"), Is.Not.Null);
                    Assert.That(accountProperties.SingleOrDefault(p => p.Key == "PartialPayment"), Is.Not.Null);
                    break;
                }
            }

            // Se reestablece la aplicación para usar el proveedor predeterminando para pruebas...
            TestContext.CurrentContext.DatabaseHelper().SetAppSettingsKey(appIdentity.ApiKey, "DataProvider:SubsystemEnabled", "TUP");
        }
Exemple #26
0
        public void MismatchTokenWhenUserSignedRequestThrows()
        {
            IDelegatedApp client             = this.GetDelegatedClient();
            IAppIdentity  appIdentityMaster  = DelegatedAppIdentity.Master;
            IUserIdentity userIdentityMaster = RecognizedUserIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().EnsureMismatchUserAuthToken(appIdentityMaster.ApiKey, userIdentityMaster.DocType, userIdentityMaster.DocNumber, userIdentityMaster.Device.DeviceId);
            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);
        }
Exemple #27
0
        public void MismatchUsernameWhenUserSignedRequestThrows()
        {
            IDelegatedApp         client                        = this.GetDelegatedClient();
            IUserIdentity         userIdentityHelper            = RecognizedUserIdentity.Helper;
            IPayloadClaimsManager mismatchUsernameClaimBehavior = InvalidUsernamePayloadClaim.WithClaimBehavior(() => $"{userIdentityHelper.DocType}-{userIdentityHelper.DocNumber}");

            ServiceLocator.Instance.RegisterPayloadClaimsManager(mismatchUsernameClaimBehavior);
            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);
        }
Exemple #28
0
        public void UnrecognizedApiKeyWhenAppSignedRequestThrows()
        {
            IDelegatedApp   client               = this.GetDelegatedClient();
            string          unrecognizedApiKey   = Guid.NewGuid().ToString();
            IHeadersManager apiKeyHeaderBehavior = InvalidApiKeyHeader.WithHeaderBehavior(() => unrecognizedApiKey);

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

            Assert.That(exception.EventId, Is.EqualTo("20005"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("Identificador de ApiKey no válido para la cabecera personalizada 'X-PRO-Auth-App'", exception.Message);
        }
Exemple #29
0
        public void InvalidAppCredentialWhenAppSignedRequestThrows()
        {
            IDelegatedApp   client                   = this.GetDelegatedClient();
            string          invalidApiSecret         = Guid.NewGuid().ToString();
            IHeadersManager invalidAppSecretBehavior = InvalidPayloadHeader.WithCustomAppSecret(invalidApiSecret);

            ServiceLocator.Instance.RegisterHeadersManager(invalidAppSecretBehavior);
            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. Invalid signature. ¿Está utilizando las credenciales proporcionadas?", exception.Message);
        }
        public void GenerateTokenWorks()
        {
            IDelegatedApp     client            = this.GetDelegatedClient();
            string            pinNumber         = "141414";
            TokenResponseInfo tokenResponseInfo = null;

            Assert.DoesNotThrow(() => tokenResponseInfo = client.Token.GenerateToken(pinNumber));
            Printer.Print(tokenResponseInfo, "TokenResponseInfo");
            Assert.NotNull(tokenResponseInfo);
            Assert.IsNotEmpty(tokenResponseInfo.Token);
            Assert.That(tokenResponseInfo.ExpirationMinutes, Is.GreaterThan(0));
            Assert.That(tokenResponseInfo.ExpiresAt, Is.GreaterThan(DateTimeOffset.Now));
        }