Beispiel #1
0
        public void MissingUserCredentialProfilePropertiesThrows()
        {
            string fixedDocType    = "CC";
            string randomDocNumber = new Random().Next(1000000000, int.MaxValue).ToString();
            string password        = Guid.Empty.ToString();
            RecognizedUserIdentity tempUserIdentity = new RecognizedUserIdentity(fixedDocType, randomDocNumber, password);

            TestContext.CurrentContext.DatabaseHelper().EnsureUserInfo(tempUserIdentity.DocType, tempUserIdentity.DocNumber);
            AspenException exception = Assert.Throws <AspenException>(() =>
            {
                DelegatedApp.Initialize(CachePolicy.BypassCache)
                .RoutingTo(TestingEndpointProvider.Default)
                .WithIdentity(DelegatedAppIdentity.Master)
                .Authenticate(tempUserIdentity)
                .GetClient();
            });

            TestContext.CurrentContext.DatabaseHelper().RemoveUserInfo(tempUserIdentity.DocType, tempUserIdentity.DocNumber);
            Assert.That(exception.EventId, Is.EqualTo("97416"));
            Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            StringAssert.IsMatch("Combinación de usuario y contraseña invalida. Por favor revise los valores ingresados e intente de nuevo", exception.Message);
        }
Beispiel #2
0
        public void NullOrEmptyTokenWhenSignedRequestThrows()
        {
            IDelegatedApp client = DelegatedApp.Initialize(CachePolicy.BypassCache)
                                   .RoutingTo(TestingEndpointProvider.Default)
                                   .WithIdentity(DelegatedAppIdentity.Master)
                                   .Authenticate(RecognizedUserIdentity.Master)
                                   .GetClient();

            IList <IPayloadClaimsManager> payloadBehaviors = new List <IPayloadClaimsManager>()
            {
                InvalidTokenPayloadClaim.WithClaimBehavior(() => null),
                InvalidTokenPayloadClaim.WithClaimBehavior(() => string.Empty),
                InvalidTokenPayloadClaim.WithClaimBehavior(() => "    ")
            };

            foreach (IPayloadClaimsManager behavior in payloadBehaviors)
            {
                ServiceLocator.Instance.RegisterPayloadClaimsManager(behavior);
                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);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Obtiene un cliente para a partir de la aplicación delegada de pruebas, omitiendo los valores almacenados en memoria.
 /// </summary>
 /// <param name="cachePolicy">La política para el tratamiento de la información almacenada por caché.</param>
 /// <returns>Instancia de <see cref="IDelegatedApp"/> para interactuar con el servicio.</returns>
 public IDelegatedApp GetDelegatedClient(CachePolicy cachePolicy = CachePolicy.BypassCache) =>
 DelegatedApp.Initialize(cachePolicy)
 .RoutingTo(TestingEndpointProvider.Default)
 .WithIdentity(DelegatedAppIdentity.Master)
 .Authenticate(RecognizedUserIdentity.Master)
 .GetClient();