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 UseOlderSecretWhenAppSigninRequestThrows()
        {
            IAppIdentity appIdentity = AutonomousAppIdentity.Master;
            string apiKey = appIdentity.ApiKey;
            string currentApiSecret = appIdentity.ApiSecret;
            string newApiSecret = new Password(128).Next();

            Assert.DoesNotThrow(() => AutonomousApp.Initialize(CachePolicy.BypassCache)
                .RoutingTo(TestingEndpointProvider.Default)
                .WithIdentity(apiKey, currentApiSecret)
                .UpdateApiSecret(newApiSecret));

            AspenException exception = Assert.Throws<AspenException>(() =>
                {
                    AutonomousApp.Initialize(CachePolicy.BypassCache)
                        .RoutingTo(TestingEndpointProvider.Default)
                        .WithIdentity(apiKey, currentApiSecret)
                        .Authenticate()
                        .GetClient();
                });

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

            TestContext.CurrentContext.DatabaseHelper().UpdateApiSecret(apiKey, currentApiSecret);
        }
        public void PolicyAttemptsIsValidated()
        {
            // Este valor debe corresponder con la política definida para el ApiKey de la solicitud.
            int policyAttempts = 3;

            // Given
            DelegatedUserInfo userCredentials = GetDelegatedUserCredentials();
            IFluentClient     userClient      = AspenClient.Initialize(AppScope.Delegated)
                                                .RoutingTo(this.delegatedAppInfoProvider)
                                                .WithIdentity(this.delegatedAppInfoProvider)
                                                .Authenticate(userCredentials)
                                                .GetClient();

            // When
            string randomNickname = TestContext.CurrentContext.Random.GetString(10);

            // Agotar los intentos definidos en la política.
            for (int index = 1; index < policyAttempts; index++)
            {
                userClient.CurrentUser.RequestActivationCode(randomNickname);
            }

            void RequestCodeFailed() => userClient.CurrentUser.RequestActivationCode(randomNickname);

            AspenException exception = Assert.Throws <AspenException>(RequestCodeFailed);

            //Then
            Assert.That(exception, Is.ExpectedException(HttpStatusCode.ExpectationFailed, "15870", "Solicitud de código de activación inválida"));
            Assert.That(exception.Content["attempt"], NUnit.Framework.Is.EqualTo(policyAttempts));
            Assert.That(exception.Content["remainingTimeLapse"], NUnit.Framework.Is.GreaterThan(0));
        }
Exemple #4
0
        public void NullOrEmptyApiKeyHeaderWhenUserSigninRequestThrows()
        {
            IList <IHeadersManager> headerBehaviors = new List <IHeadersManager>()
            {
                InvalidApiKeyHeader.WithHeaderBehavior(() => null),
                InvalidApiKeyHeader.WithHeaderBehavior(() => string.Empty),
                InvalidApiKeyHeader.WithHeaderBehavior(() => "     ")
            };

            foreach (IHeadersManager behavior in headerBehaviors)
            {
                AspenException exception = Assert.Throws <AspenException>(() =>
                {
                    ServiceLocator.Instance.RegisterHeadersManager(behavior);
                    DelegatedApp.Initialize(CachePolicy.BypassCache)
                    .RoutingTo(TestingEndpointProvider.Default)
                    .WithIdentity(DelegatedAppIdentity.Master)
                    .Authenticate(RecognizedUserIdentity.Master)
                    .GetClient();
                });

                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-App'", exception.Message);
            }
        }
        public void GivenReedemTokenWhenAmountIsInvalidThenAnExceptionIsThrows()
        {
            IFluentClient client = AspenClient.Initialize()
                                   .RoutingTo(this.autonomousAppInfoProvider)
                                   .WithIdentity(this.autonomousAppInfoProvider)
                                   .Authenticate()
                                   .GetClient();

            void ValidateSingleUseTokenAvoidingValidation(object amount) =>
            ((AspenClient)client.Financial).ValidateSingleUseTokenAvoidingValidation("CC", "52080323", "000000", accountType: "80", amount: amount);

            // Cuando se establece vacío, la serialización lo interpreta como nulo
            AspenException exception = Assert.Throws <AspenException>(() => ValidateSingleUseTokenAvoidingValidation(string.Empty));

            AssertAspenResponseException(
                exception,
                "15852",
                HttpStatusCode.BadRequest,
                @"'Amount' no puede ser nulo ni vacío");

            // Valor menor a cero...
            exception = Assert.Throws <AspenException>(() => ValidateSingleUseTokenAvoidingValidation(-1));
            AssertAspenResponseException(
                exception,
                "15852",
                HttpStatusCode.BadRequest,
                @"'Amount' debe ser mayor que cero");

            // Valor menor a cero...
            exception = Assert.Throws <AspenException>(() => ValidateSingleUseTokenAvoidingValidation("-1"));
            AssertAspenResponseException(
                exception,
                "15852",
                HttpStatusCode.BadRequest,
                @"'Amount' debe ser mayor que cero");

            // Cuando no es un valor entero falla por serialización.
            exception = Assert.Throws <AspenException>(() => ValidateSingleUseTokenAvoidingValidation("   "));
            AssertAspenResponseException(
                exception,
                "15883",
                HttpStatusCode.BadRequest,
                @"Valor inesperado al analizar los datos de solicitud en formato JSON");

            // Cuando no es un valor entero falla por serialización.
            exception = Assert.Throws <AspenException>(() => ValidateSingleUseTokenAvoidingValidation("XXX"));
            AssertAspenResponseException(
                exception,
                "15883",
                HttpStatusCode.BadRequest,
                @"Valor inesperado al analizar los datos de solicitud en formato JSON");

            // Cuando no es un valor entero falla por serialización.
            exception = Assert.Throws <AspenException>(() => ValidateSingleUseTokenAvoidingValidation("10000000000000000"));
            AssertAspenResponseException(
                exception,
                "15883",
                HttpStatusCode.BadRequest,
                @"Valor inesperado al analizar los datos de solicitud en formato JSON");
        }
Exemple #6
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);
        }
Exemple #7
0
        public void InvalidSecretFormatUserProfilePropertiesThrows()
        {
            string        fixedDocType              = "CC";
            string        randomDocNumber           = new Random().Next(1000000000, int.MaxValue).ToString();
            string        password                  = Guid.Empty.ToString();
            IAppIdentity  appIdentity               = DelegatedAppIdentity.Master;
            IUserIdentity tempUserIdentity          = new RecognizedUserIdentity(fixedDocType, randomDocNumber, password);
            Dictionary <string, string> userProfile = new Dictionary <string, string>()
            {
                { "Secret", password },
                { "SecretFormat", "InvalidTypeName" }
            };

            TestContext.CurrentContext.DatabaseHelper().EnsureUserAndProfileInfo(
                appIdentity.ApiKey,
                tempUserIdentity.DocType,
                tempUserIdentity.DocNumber,
                userProfile);

            AspenException exception = Assert.Throws <AspenException>(() =>
            {
                DelegatedApp.Initialize(CachePolicy.BypassCache)
                .RoutingTo(TestingEndpointProvider.Default)
                .WithIdentity(appIdentity)
                .Authenticate(tempUserIdentity)
                .GetClient();
            });

            TestContext.CurrentContext.DatabaseHelper().RemoveUserInfo(tempUserIdentity.DocType, tempUserIdentity.DocNumber);
            Assert.That(exception.EventId, Is.EqualTo("97417"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
            StringAssert.IsMatch("No es posible verificar las credenciales del usuario.", exception.Message);
        }
        public void NewAndOlderApiSecretAreEqualsThrows()
        {
            IAppIdentity appIdentity = AutonomousAppIdentity.Master;
            string apiKey = appIdentity.ApiKey;
            string currentApiSecret = appIdentity.ApiSecret;
            string randomApiSecret = this.GetRandomSecret();

            // Ya que el secreto actual de la aplicación de pruebas sólo tiene letras,
            // para saltar las validaciones del nuevo secreto se establece en la aplicación,
            // un secreto aleatorio y a así validar que el nuevo secreto sea igual al actual.
            TestContext.CurrentContext.DatabaseHelper().UpdateApiSecret(apiKey, randomApiSecret);

            AspenException exception = Assert.Throws<AspenException>(() =>
                {
                    AutonomousApp.Initialize(CachePolicy.BypassCache)
                        .RoutingTo(TestingEndpointProvider.Default)
                        .WithIdentity(apiKey, randomApiSecret)
                        .UpdateApiSecret(randomApiSecret);
                });

            Assert.That(exception.EventId, Is.EqualTo("15864"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotAcceptable));
            StringAssert.IsMatch("El nuevo secreto no debe ser igual al actual.", exception.Message);

            // Se reestablece el secreto predeterminado.
            TestContext.CurrentContext.DatabaseHelper().UpdateApiSecret(apiKey, currentApiSecret);
        }
        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 #10
0
        public void MissingPasswordWhenUserSigninRequestThrows()
        {
            ServiceLocator.Instance.RegisterPayloadClaimsManager(InvalidPasswordPayloadClaim.AvoidingClaim());
            AspenException exception = Assert.Throws <AspenException>(() => GetDelegatedClient());

            Assert.That(exception.EventId, Is.EqualTo("15852"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
            StringAssert.IsMatch("'Password' no puede ser nulo ni vacío", exception.Message);
        }
Exemple #11
0
        public void EpochZeroWhenUserSigninRequestThrows()
        {
            ServiceLocator.Instance.RegisterEpochGenerator(FixedEpochGenerator.FromStaticSeconds(0));
            AspenException exception = Assert.Throws <AspenException>(() => GetDelegatedClient());

            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 #12
0
        /// <summary>
        /// Aplica las restricciones, devolviendo un ConstraintResult.
        /// </summary>
        /// <typeparam name="TActual">Tipo del valor que se está comprobando.</typeparam>
        /// <param name="actual">Valor para comprobar.</param>
        /// <returns>Instancia de <see cref="ConstraintResult" /> con los resultados de las validaciones.</returns>
        public override ConstraintResult ApplyTo <TActual>(TActual actual)
        {
            AspenException aspenException = actual as AspenException;

            Assert.That(aspenException?.StatusCode, NUnit.Framework.Is.EqualTo(this.httpStatusCode));
            Assert.That(aspenException?.EventId, NUnit.Framework.Is.Not.Null.And.Match(this.eventId));
            Assert.That(aspenException?.Message, NUnit.Framework.Is.Not.Null.And.Match(this.message));
            return(new ConstraintResult(this, aspenException, ConstraintStatus.Success));
        }
Exemple #13
0
        public void MissingPayloadHeaderWhenAppSigninRequestThrows()
        {
            ServiceLocator.Instance.RegisterHeadersManager(InvalidPayloadHeader.AvoidingHeader());
            AspenException exception = Assert.Throws <AspenException>(() => GetAutonomousClient());

            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 #14
0
 /// <summary>
 /// Lanza una excepción de aserción en caso de que no se cumplan las condiciones.
 /// </summary>
 /// <param name="exception">Isntancia de la excepción que se está evaluando.</param>
 /// <param name="expectedEventId">Identificador del evento que se espera en la excepción.</param>
 /// <param name="expectedStatusCode">HttpStatusCode que se espera en la excepción.</param>
 /// <param name="expectedMessagePattern">Texto o parte del texto, que se espera encontrar en la excepción.</param>
 private static void AssertAspenResponseException(
     AspenException exception,
     string expectedEventId,
     HttpStatusCode expectedStatusCode,
     string expectedMessagePattern = null)
 {
     Assert.That(exception.StatusCode, Is.EqualTo(expectedStatusCode));
     StringAssert.AreEqualIgnoringCase(expectedEventId ?? exception.EventId, exception.EventId);
     StringAssert.IsMatch(Regex.Escape(expectedMessagePattern ?? exception.Message), exception.Message);
 }
Exemple #15
0
        public void GetAppSettingsUnrecognizedApiKeyThrows()
        {
            IAnonymous     client             = this.GetAnonymousClient();
            string         unrecognizedApiKey = Guid.NewGuid().ToString();
            AspenException exception          = Assert.Throws <AspenException>(() => client.Settings.GetAppSettings(unrecognizedApiKey));

            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 #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);
        }
        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);
        }
Exemple #20
0
        public void InvalidFormatPayloadWhenUserSigninRequestThrows()
        {
            IHeadersManager invalidPayloadHeaderBehavior = InvalidPayloadHeader.WithHeaderBehavior(() => "Lorem ipsum dolor sit amet, consetetur sadipscing elitr");

            ServiceLocator.Instance.RegisterHeadersManager(invalidPayloadHeaderBehavior);
            AspenException exception = Assert.Throws <AspenException>(() => GetDelegatedClient());

            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 #21
0
        public void EpochExceededWhenUserSigninRequestThrows()
        {
            int randomDays = new Random().Next(5, 10);

            ServiceLocator.Instance.RegisterEpochGenerator(FixedEpochGenerator.FromDatePicker(randomDays));
            AspenException exception = Assert.Throws <AspenException>(() => GetDelegatedClient());

            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 #22
0
        public void EpochNegativeWhenUserSigninRequestThrows()
        {
            double negativeSeconds = -DateTimeOffset.Now.ToUnixTimeSeconds();

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

            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);
        }
        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 AppRequiresChangeSecretWhenSigninRequestThrows()
        {
            IAppIdentity appIdentity = AutonomousAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().UpdateChangeSecret(appIdentity.ApiKey, true);
            AspenException exception = Assert.Throws <AspenException>(() => this.GetAutonomousClient());

            Assert.That(exception.EventId, Is.EqualTo("20009"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.UpgradeRequired));
            StringAssert.IsMatch("Necesita actualizar el secreto de la aplicación.", exception.Message);
            TestContext.CurrentContext.DatabaseHelper().UpdateChangeSecret(appIdentity.ApiKey, false);
        }
        public void ApiKeyDisabledWhenAppSigninRequestThrows()
        {
            IAppIdentity appIdentity = AutonomousAppIdentity.Master;

            TestContext.CurrentContext.DatabaseHelper().UpdateEnabled(appIdentity.ApiKey, false);
            AspenException exception = Assert.Throws <AspenException>(() => this.GetAutonomousClient());

            Assert.That(exception.EventId, Is.EqualTo("20006"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Forbidden));
            StringAssert.IsMatch("ApiKey está desactivado. Póngase en contacto con el administrador", exception.Message);
            TestContext.CurrentContext.DatabaseHelper().UpdateEnabled(appIdentity.ApiKey, true);
        }
Exemple #26
0
        public void EpochExpiredWhenSignedRequestThrows()
        {
            IDelegatedApp client     = this.GetDelegatedClient();
            int           randomDays = new Random().Next(2, 10);

            ServiceLocator.Instance.RegisterEpochGenerator(FixedEpochGenerator.FromDatePicker(-randomDays));
            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 #27
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);
        }
        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 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 #30
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);
        }