public async Task LocationController_GetWithValidWoeId_ReturnsValidLocationAsync(ILogger <LocationController> logger,
                                                                                         ApiOptions apiOptions,
                                                                                         IApiProxy apiProxy)
        {
            var expectedCount = 1;

            _apiProxy = apiProxy;

            // Arrange
            _apiProxy = Substitute.For <IApiProxy>();
            _locationResponseBuilder = new TestLocationResponseBuilder();

            _locationController = new LocationController(logger, apiOptions, _apiProxy);
            _apiProxy.SubmitLocationRequest(Arg.Any <ILocationRequest>())
            .Returns(_locationResponseBuilder.Default().WithBelfast().Build());

            // Act
            var locationResponse = await _locationController.Post(new LocationRequest()).ConfigureAwait(false);


            // Assert
            using (new AssertionScope())
            {
                locationResponse.Should().BeOkObjectResult().ValueAs <ILocationResponse>().Locations
                .Should()
                .HaveCount(expectedCount);
            }
        }
Ejemplo n.º 2
0
 public WeatherController(ILogger <WeatherController> logger, ApiOptions apiOptions, IApiProxy apiProxy)
 {
     _logger     = logger;
     _apiOptions =
         apiOptions ?? throw new ArgumentNullException(nameof(apiOptions));
     _apiProxy = apiProxy;
 }
        public Uri ResolveOutboundUri(HttpContext context, IApiProxy apiProxy)
        {
            var pathWithNoInboundPathBase = context.Request.Path.Value.Replace(apiProxy.Options.InboundPathBase, "/");
            var path = new PathString(pathWithNoInboundPathBase);

            var url = UriHelper.BuildAbsolute(apiProxy.Options.Scheme, apiProxy.Options.Host,
                                              apiProxy.Options.OutboundPathBase, path, context.Request.QueryString);

            url = QueryHelpers.AddQueryString(url, _apiProxyContextService.Get(context).Request.AppendQueryStringToApiRequest);

            return(new Uri(url));
        }
Ejemplo n.º 4
0
        public static void UseApiProxyRequestCaching(this IApplicationBuilder app, IApiProxy apiProxy)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (apiProxy == null)
            {
                throw new ArgumentNullException(nameof(apiProxy));
            }

            app.UseMiddleware <ApiProxyRequestCachingMiddleware>(apiProxy);
        }
Ejemplo n.º 5
0
        public ApiProxyRequestAuthenticationMiddleware(RequestDelegate next, IApiProxy apiProxy)
        {
            if (apiProxy == null)
            {
                throw new ArgumentNullException(nameof(apiProxy));
            }
            if (string.IsNullOrWhiteSpace(apiProxy.Identifier))
            {
                throw new ArgumentException("Api proxy must specify identifier.", nameof(apiProxy.Identifier));
            }

            _next     = next;
            _apiProxy = apiProxy;
        }
Ejemplo n.º 6
0
        static public void RegisterChtSwaggerDoc <TService>(this IApiProxy <TService> it, bool useApiGateway)
            where TService : class
        {
            //Ordering/api/v1/HelloWorld
            var host        = $"{it.ApiEndpoint.Scheme}://{it.ApiEndpoint.Host}:{it.ApiEndpoint.Port}";
            var swaggerPath = useApiGateway ?
                              string.Format(SwaggerExt.TakeSwaggerPathTemplate <TService>(), it.ApiVersion)
                : string.Format(SwaggerExt.SwaggerPathTemplate, it.ApiVersion);
            var swaggerEndpoint = new Uri($"{host}{swaggerPath}");

            it.RegisterSwaggerDoc(swaggerEndpoint);
            //if (useApiGateway)
            //{
            //    it.ApiEndpoint = new Uri($"{host}/{SwaggerExt.ResolveServiceName<TService>()}/api/v{it.ApiVersion}");
            //}
        }
Ejemplo n.º 7
0
        public ApiProxyRequestMiddleware(RequestDelegate next, IApiProxy apiProxy)
        {
            if (apiProxy == null)
            {
                throw new ArgumentNullException(nameof(apiProxy));
            }
            if (string.IsNullOrWhiteSpace(apiProxy.Options.Scheme))
            {
                throw new ArgumentException("Api proxy options must specify scheme.", nameof(apiProxy.Options));
            }
            if (!apiProxy.Options.Host.HasValue)
            {
                throw new ArgumentException("Api proxy options must specify host.", nameof(apiProxy.Options));
            }

            _apiProxy = apiProxy;
        }
Ejemplo n.º 8
0
        private void CallApi(IApiProxy <IHelloWorldService> proxy)
        {
            IHelloWorldService helloSvc = proxy.Svc;
            string             id1      = "*abc*";
            int      id2 = 99;
            DateTime id3 = DateTime.Today;
            var      id4 = new HelloInput()
            {
                UserName = "******", Date = DateTime.Today
            };
            var rlt = helloSvc.Hello(id1, id2, id3, id4);

            print($"API={nameof(IHelloWorldService.Hello)} User={rlt.UserName}\nDate={rlt.Date}\n{rlt.Summary}");

            var postrlt = helloSvc.HelloPost("CCC", "DDD");

            print($"API={nameof(IHelloWorldService.HelloPost)} result={postrlt}");

            var getrlt = proxy.Svc.HelloGet("EEE", "FFF");

            print($"API={nameof(IHelloWorldService.HelloGet)} result={getrlt}");
        }
Ejemplo n.º 9
0
 protected ClientBase(IApiProxy apiProxy)
 {
     ApiProxy = apiProxy;
 }
Ejemplo n.º 10
0
 public EmploymentsController(IApiProxy proxy)
 {
     _proxy = proxy;
 }
Ejemplo n.º 11
0
 public BaseController(IApiProxy proxy)
 {
     this.Proxy = proxy;
 }
Ejemplo n.º 12
0
 public InfuraApiService(IApiProxy apiProxy, ILogger <InfuraApiService> logger)
 {
     _apiProxy = apiProxy;
     _logger   = logger;
 }
Ejemplo n.º 13
0
 public ApiRequestHandler()
 {
     apiProxy = new ApiProxy();
 }
Ejemplo n.º 14
0
 public Functions(IApiProxy apiProxy)
 {
     _apiProxy = apiProxy;
 }
Ejemplo n.º 15
0
 public CotizacionesController(IConfiguration Configuration, IApiProxy proxy) : base(proxy)
 {
     this._config = Configuration;
     this.Proxy   = proxy;
 }
Ejemplo n.º 16
0
 public HomeController(IApiProxy apiProxy)
 {
     _apiProxy = apiProxy;
     _apiProxy.RegisterAsDummyUserAndUseBearerToken();
 }
Ejemplo n.º 17
0
 public GenericController(IApiProxy apiProxy)
 {
     _apiProxy = apiProxy;
 }
Ejemplo n.º 18
0
 public RecibosController(IConfiguration Configuration, IApiProxy proxy) : base(proxy)
 {
     this._config = Configuration;
     this.Proxy   = proxy;
 }
Ejemplo n.º 19
0
 public ApiProxyResponseMiddleware(RequestDelegate next, IApiProxy apiProxy)
 {
     _apiProxy = apiProxy;
     _next     = next;
 }
Ejemplo n.º 20
0
 public ProductosController(IConfiguration config, IApiProxy proxy) : base(proxy)
 {
     _config = config;
     Proxy   = proxy;
 }
Ejemplo n.º 21
0
 public UsuarioProxy(IApiProxy apiProxy) : base(apiProxy)
 {
 }
Ejemplo n.º 22
0
 public ProveedoresController(IConfiguration Configuration, IApiProxy proxy) : base(proxy)
 {
     this._config = Configuration;
     this.Proxy   = proxy;
 }
Ejemplo n.º 23
0
 public PersonsController(IApiProxy proxy)
 {
     _proxy = proxy;
 }
        public static void UseApiProxyResponseInterceptor(this IApplicationBuilder app, IApiProxy apiProxy)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (apiProxy == null)
            {
                throw new ArgumentNullException(nameof(apiProxy));
            }

            app.UseMiddleware <ApiProxyResponseInterceptorMiddleware>(apiProxy);
        }