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 MissingApiKeyHeaderWhenAppSigninRequestThrows() { ServiceLocator.Instance.RegisterHeadersManager(InvalidApiKeyHeader.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-App'", exception.Message); }
public void MissingApiKeyHeaderWhenUserSignedRequestThrows() { IDelegatedApp client = this.GetDelegatedClient(); ServiceLocator.Instance.RegisterHeadersManager(InvalidApiKeyHeader.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-App'", exception.Message); }
public void UnrecognizedApiKeyWhenAppSignedRequestThrows() { IAutonomousApp client = this.GetAutonomousClient(); 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); }
public void MissingApiKeyHeaderWhenUserSigninRequestThrows() { AspenException exception = Assert.Throws <AspenException>(() => { ServiceLocator.Instance.RegisterHeadersManager(InvalidApiKeyHeader.AvoidingHeader()); 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 NullOrEmptyApiKeyHeaderWhenAppSigninRequestThrows() { IList <IHeadersManager> headerBehaviors = new List <IHeadersManager>() { InvalidApiKeyHeader.WithHeaderBehavior(() => null), InvalidApiKeyHeader.WithHeaderBehavior(() => string.Empty), InvalidApiKeyHeader.WithHeaderBehavior(() => " ") }; foreach (IHeadersManager behavior in headerBehaviors) { ServiceLocator.Instance.RegisterHeadersManager(behavior); 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-App'", exception.Message); } }